From 7d08c76da00ce1253bd0c6ffd4b6d91ca50e1e16 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Thu, 18 Mar 2021 11:15:51 +0800 Subject: [PATCH] crimson/os/alienstore: add default behaviour for alien threads affinities 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 --- src/crimson/os/alienstore/alien_store.cc | 15 +++++++++++++++ src/crimson/os/alienstore/alien_store.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index ceac8cdafb8..e37d8a1f4f2 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -66,6 +66,21 @@ AlienStore::AlienStore(const std::string& path, const ConfigValues& values) const auto num_threads = cct->_conf.get_val("crimson_alien_op_num_threads"); std::vector 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(num_threads, 128, cpu_cores); } diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index 08790c5fdfa..bc5376e0f6c 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -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 tp; const std::string path; -- 2.39.5