]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/alienstore: add default behaviour for alien threads affinities 39777/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 18 Mar 2021 03:15:51 +0000 (11:15 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Sun, 21 Mar 2021 08:49:11 +0000 (16:49 +0800)
currently, we allow alienstore to be scheduled on to any cpu cores other than
the starting three, as in most current tests we use the those cores for crimson-osd
seastar threads

Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/os/alienstore/alien_store.cc
src/crimson/os/alienstore/alien_store.h

index ceac8cdafb80b494e850f73e31fbb0d8f4a707eb..e37d8a1f4f204ea6342660de3161152f05f9bb79 100644 (file)
@@ -66,6 +66,21 @@ AlienStore::AlienStore(const std::string& path, const ConfigValues& values)
   const auto num_threads =
     cct->_conf.get_val<uint64_t>("crimson_alien_op_num_threads");
   std::vector<uint64_t> cpu_cores = _parse_cpu_cores();
+
+  // cores except the first "N_CORES_FOR_SEASTAR" ones will
+  // be used for alien threads scheduling:
+  //   [0, N_CORES_FOR_SEASTAR) are reserved for seastar reactors
+  //   [N_CORES_FOR_SEASTAR, ..] are assigned to alien threads.
+  if (cpu_cores.empty()) {
+    if (long nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+       nr_cpus > N_CORES_FOR_SEASTAR ) {
+      for (int i = N_CORES_FOR_SEASTAR; i < nr_cpus; i++) {
+        cpu_cores.push_back(i);
+      }
+    } else {
+      logger().error("{}: unable to get nproc: {}", __func__, errno);
+    }
+  }
   tp = std::make_unique<crimson::os::ThreadPool>(num_threads, 128, cpu_cores);
 }
 
index 08790c5fdfa6eb94023553bc4fbf27f62cf1e6d8..bc5376e0f6cdcd0a75ac5a12b9fd8883eff9bd8f 100644 (file)
@@ -113,6 +113,9 @@ public:
     const ghobject_t& oid) final;
 
 private:
+  // number of cores that are PREVENTED from being scheduled
+  // to run alien store threads.
+  static constexpr int N_CORES_FOR_SEASTAR = 3;
   constexpr static unsigned MAX_KEYS_PER_OMAP_GET_CALL = 32;
   mutable std::unique_ptr<crimson::os::ThreadPool> tp;
   const std::string path;