]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/numa: Add shim routines for NUMA on FreeBSD.
authorWillem Jan Withagen <wjw@digiware.nl>
Fri, 11 Jan 2019 17:40:22 +0000 (18:40 +0100)
committerWillem Jan Withagen <wjw@digiware.nl>
Thu, 17 Jan 2019 10:41:44 +0000 (11:41 +0100)
FreeBSD has some of the numa features,
but for now faking them will do.

Also don't test NUMA on FreeBSD.

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/common/blkdev.cc
src/common/compat.cc
src/common/numa.cc
src/common/numa.h
src/include/compat.h
src/test/common/CMakeLists.txt

index 1c03ffb1f405423df8740754c6c313ce277a135b..43e4be0a0a669420c55b030c549bc2daf20e9ef0 100644 (file)
@@ -765,6 +765,11 @@ int BlkDev::get_size(int64_t *psize) const
   return ret;
 }
 
+int64_t BlkDev::get_int_property(blkdev_prop_t prop) const
+{
+  return 0;
+}
+
 bool BlkDev::support_discard() const
 {
   return false;
@@ -785,6 +790,11 @@ bool BlkDev::is_rotational() const
   return false;
 }
 
+int BlkDev::get_numa_node(int *node) const
+{
+  return -1;
+}
+
 int BlkDev::model(char *model, size_t max) const
 {
   return -EOPNOTSUPP;
@@ -866,6 +876,11 @@ int BlkDev::get_size(int64_t *psize) const
   return ret;
 }
 
+int64_t BlkDev::get_int_property(blkdev_prop_t prop) const
+{
+  return 0;
+}
+
 bool BlkDev::support_discard() const
 {
 #ifdef FREEBSD_WITH_TRIM
@@ -934,6 +949,15 @@ bool BlkDev::is_rotational() const
 #endif
 }
 
+int BlkDev::get_numa_node(int *node) const
+{
+  int numa = get_int_property(BLKDEV_PROP_NUMA_NODE);
+  if (numa < 0)
+    return -1;
+  *node = numa;
+  return 0;
+}
+
 int BlkDev::model(char *model, size_t max) const
 {
   struct diocgattr_arg arg;
index 1cfc4db973ab924586cf0e80491274c6953f300e..3380d1cd031c6bbb1d1547559ed65e30fd6f9873 100644 (file)
@@ -184,3 +184,12 @@ fail:
   return (errno = save_errno, -1);
 #endif
 }
+
+#if defined(__FreeBSD__)
+int sched_setaffinity(pid_t pid, size_t cpusetsize,
+                      cpu_set_t *mask)
+{
+  return 0;
+}
+#endif
+
index 9ec29fa95f228aa1c118d66b94478c08191043b1..c75f50088eb10904f9172130030a73c97e6fd2cd 100644 (file)
@@ -12,7 +12,7 @@
 
 
 // list
-
+#if defined(__linux__)
 int parse_cpu_set_list(const char *s,
                       size_t *cpu_set_size,
                       cpu_set_t *cpu_set)
@@ -133,3 +133,33 @@ int get_numa_node_cpu_set(
   ::close(fd);
   return r;
 }
+
+#elif defined(__FreeBSD__)
+
+int parse_cpu_set_list(const char *s,
+                      size_t *cpu_set_size,
+                      cpu_set_t *cpu_set)
+{
+  return -ENOTSUP;
+}
+
+std::string cpu_set_to_str_list(size_t cpu_set_size,
+                               const cpu_set_t *cpu_set)
+{
+  return {};
+}
+
+std::set<int> cpu_set_to_set(size_t cpu_set_size,
+                            const cpu_set_t *cpu_set)
+{
+  return {};
+}
+
+int get_numa_node_cpu_set(int node,
+                          size_t *cpu_set_size,
+                          cpu_set_t *cpu_set)
+{
+  return -ENOTSUP;
+}
+
+#endif
index 85f91b30eeb102d1c67873ee7f9391ebfc37de4a..4acb8280c8f4cb15528bdf06ac44bed45196260c 100644 (file)
@@ -3,6 +3,7 @@
 
 #pragma once
 
+#include <include/compat.h>
 #include <sched.h>
 #include <ostream>
 #include <set>
index 949bb406e8bfff94894b702d11ed1944fd4ef8c8..3463c98d2b877144eceaaba242de498e72ec1719 100644 (file)
 /* And include the extra required include file */
 #include <pthread_np.h>
 
+#include <sys/param.h>
+#include <sys/cpuset.h>
+#define cpu_set_t cpuset_t
+int sched_setaffinity(pid_t pid, size_t cpusetsize,
+                      cpu_set_t *mask);
+
 #endif /* __FreeBSD__ */
 
 #if defined(__APPLE__) || defined(__FreeBSD__)
index 9578822c62600c1b0e885fe3a673b361c7fa8e13..71fb77cda912145b438b4fb27d624f7c2332994f 100644 (file)
@@ -28,12 +28,15 @@ add_executable(unittest_lockdep
 add_ceph_unittest(unittest_lockdep)
 target_link_libraries(unittest_lockdep ceph-common global)
 
+# FreeBSD only has shims to support NUMA, no functional code.
+if(LINUX)
 # unittest_numa
 add_executable(unittest_numa
   test_numa.cc
   )
 add_ceph_unittest(unittest_numa)
 target_link_libraries(unittest_numa ceph-common)
+endif()
 
 # unittest_bloom_filter
 add_executable(unittest_bloom_filter