]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/numa: remove unused _mask variants
authorSage Weil <sage@redhat.com>
Tue, 8 Jan 2019 15:54:04 +0000 (09:54 -0600)
committerSage Weil <sage@redhat.com>
Wed, 9 Jan 2019 15:44:48 +0000 (09:44 -0600)
These parse the 'local_cpus' file that has a hex bitmask, but I didn't end
up using them.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/numa.cc
src/common/numa.h
src/test/common/test_numa.cc

index ff51d871c940d2597e0360cbeb1f43a817dea35e..edf6861191951729ed959b83780c1af2088908bc 100644 (file)
@@ -102,89 +102,6 @@ std::set<int> cpu_set_to_set(size_t cpu_set_size,
   return r;
 }
 
-// mask
-static int from_hex(char c)
-{
-  if (c >= '0' && c <= '9') {
-    return c - '0';
-  }
-  if (c >= 'a' && c <= 'f') {
-    return c - 'a' + 10;
-  }
-  if (c >= 'A' && c <= 'F') {
-    return c - 'A' + 10;
-  }
-  return -1;
-}
-
-static char to_hex(int v)
-{
-  if (v < 10) {
-    return '0' + v;
-  }
-  return 'a' + (v - 10);
-}
-
-// FIXME: this is assuming the local_cpus value is little endian... is
-// that right?
-
-// FIXME: this assumes the cpu count is a multiple of 4 (a nibble)
-
-int parse_cpu_set_mask(
-  const char *s,
-  size_t *cpu_set_size,
-  cpu_set_t *cpu_set)
-{
-  char *b = new char[CPU_SETSIZE];
-  memset(b, 0, CPU_SETSIZE);
-  int r = -EINVAL;
-  unsigned cpu = 0;
-  int pos;
-  for (pos = 0; s[pos]; ++pos) {
-    if (pos/2 >= CPU_SETSIZE) {
-      goto out;
-    }
-  }
-  CPU_ZERO(cpu_set);
-  *cpu_set_size = pos * 4;
-  for (--pos; pos >= 0; --pos) {
-    int v = from_hex(s[pos]);
-    if (v < 0) {
-      goto out;
-    }
-    for (unsigned i = 0; i < 4; ++i, ++cpu) {
-      if (v & (1 << (cpu & 3))) {
-       CPU_SET(cpu, cpu_set);
-      }
-    }
-  }
-  r = 0;
-
- out:
-  delete b;
-  return r;
-}
-
-std::string cpu_set_to_str_mask(
-  size_t cpu_set_size,
-  const cpu_set_t *cpu_set)
-{
-  std::string r;
-  unsigned v = 0;
-  for (int i = cpu_set_size - 1; i >= 0; --i) {
-    if (CPU_ISSET(i, cpu_set)) {
-      v |= 1 << (i & 7);
-    }
-    if ((i & 7) == 0) {
-      if (i + 4 < (int)cpu_set_size) {
-       r += to_hex((v & 0xf0) >> 4);
-      }
-      r += to_hex(v & 0xf);
-      v = 0;
-    }
-  }
-  return r;
-}
 
 int get_numa_node_cpu_set(
   int node,
index 37f87872e6df5d8908229bb1d4dc66c21c18eab3..85f91b30eeb102d1c67873ee7f9391ebfc37de4a 100644 (file)
@@ -15,12 +15,6 @@ std::string cpu_set_to_str_list(size_t cpu_set_size,
 std::set<int> cpu_set_to_set(size_t cpu_set_size,
                             const cpu_set_t *cpu_set);
 
-int parse_cpu_set_mask(const char *s,
-                      size_t *cpu_set_size,
-                      cpu_set_t *cpu_set);
-std::string cpu_set_to_str_mask(size_t cpu_set_size,
-                               const cpu_set_t *cpu_set);
-
 int get_numa_node_cpu_set(int node,
                          size_t *cpu_set_size,
                          cpu_set_t *cpu_set);
index 6070fc710f7e01a5082de7e7608ee0991f9bf4b0..a3bbdf223df763156e3afd2504c60b73b75367a8 100644 (file)
@@ -60,92 +60,13 @@ TEST(cpu_set, round_trip_list)
        CPU_SET(i, &cpu_set);
       }
     }
-    std::string v = cpu_set_to_str_mask(size, &cpu_set);
+    std::string v = cpu_set_to_str_list(size, &cpu_set);
     cpu_set_t cpu_set_2;
     size_t size2;
-    ASSERT_EQ(0, parse_cpu_set_mask(v.c_str(), &size2, &cpu_set_2));
+    ASSERT_EQ(0, parse_cpu_set_list(v.c_str(), &size2, &cpu_set_2));
     for (unsigned i = 0; i < 32; ++i) {
       ASSERT_TRUE(CPU_ISSET(i, &cpu_set) == CPU_ISSET(i, &cpu_set_2));
     }
   }
 }
 
-
-
-TEST(cpu_set, parse_mask) {
-  cpu_set_t cpu_set;
-  size_t size;
-
-  ASSERT_EQ(0, parse_cpu_set_mask("f", &size, &cpu_set));
-  ASSERT_EQ(size, 4u);
-  for (unsigned i = 0; i < size; ++i) {
-    ASSERT_TRUE(CPU_ISSET(i, &cpu_set));
-  }
-
-  ASSERT_EQ(0, parse_cpu_set_mask("0f", &size, &cpu_set));
-  ASSERT_EQ(size, 8u);
-  for (unsigned i = 0; i < 4; ++i) {
-    ASSERT_TRUE(CPU_ISSET(i, &cpu_set));
-  }
-
-  ASSERT_EQ(0, parse_cpu_set_mask("ffff", &size, &cpu_set));
-  ASSERT_EQ(size, 16u);
-  for (unsigned i = 0; i < size; ++i) {
-    ASSERT_TRUE(CPU_ISSET(i, &cpu_set));
-  }
-
-  ASSERT_EQ(0, parse_cpu_set_mask("0000", &size, &cpu_set));
-  ASSERT_EQ(size, 16u);
-  for (unsigned i = 0; i < size; ++i) {
-    ASSERT_FALSE(CPU_ISSET(i, &cpu_set));
-  }
-
-  ASSERT_EQ(0, parse_cpu_set_mask("00ff00ff", &size, &cpu_set));
-  ASSERT_EQ(size, 32u);
-  for (unsigned i = 0; i < 8; ++i) {
-    ASSERT_TRUE(CPU_ISSET(i, &cpu_set));
-  }
-  for (unsigned i = 8; i < 16; ++i) {
-    ASSERT_FALSE(CPU_ISSET(i, &cpu_set));
-  }
-  for (unsigned i = 16; i < 24; ++i) {
-    ASSERT_TRUE(CPU_ISSET(i, &cpu_set));
-  }
-  for (unsigned i = 24; i < 32; ++i) {
-    ASSERT_FALSE(CPU_ISSET(i, &cpu_set));
-  }
-
-  ASSERT_EQ(0, parse_cpu_set_mask("ffffffffffffffffffffffffffffffff",
-                                 &size, &cpu_set));
-  ASSERT_EQ(size, 128u);
-  for (unsigned i = 0; i < size; ++i) {
-    ASSERT_TRUE(CPU_ISSET(i, &cpu_set));
-  }
-}
-
-TEST(cpu_set, to_str_mask)
-{
-  cpu_set_t cpu_set;
-  CPU_ZERO(&cpu_set);
-  CPU_SET(0, &cpu_set);
-  CPU_SET(1, &cpu_set);
-  CPU_SET(2, &cpu_set);
-  CPU_SET(3, &cpu_set);
-  ASSERT_EQ(std::string("f"), cpu_set_to_str_mask(4, &cpu_set));
-  ASSERT_EQ(std::string("0f"), cpu_set_to_str_mask(8, &cpu_set));
-}
-
-TEST(cpu_set, round_trip_mask)
-{
-  for (unsigned i = 0; i < 100; ++i) {
-    char buf[50];
-    snprintf(buf, sizeof(buf), "%08llx", (long long unsigned)rand());
-    cpu_set_t cpu_set;
-    size_t size;
-    ASSERT_EQ(0, parse_cpu_set_mask(buf, &size, &cpu_set));
-    ASSERT_EQ(32u, size);
-    std::string v = cpu_set_to_str_mask(size, &cpu_set);
-    ASSERT_EQ(v, buf);
-  }
-}
-