Skip to content

Commit 6db8780

Browse files
authored
Merge pull request ceph#57593 from Matan-B/wip-matanb-crimson-default-cpu-cores
Crimson: Support basic deployments Reviewed-by: Yingxin Cheng <[email protected]>
2 parents b06ef68 + 64a9915 commit 6db8780

File tree

4 files changed

+51
-17
lines changed

4 files changed

+51
-17
lines changed

src/common/options/crimson.yaml.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ options:
3131
desc: CPU cores on which alienstore threads will run in cpuset(7) format
3232
flags:
3333
- startup
34+
- name: crimson_seastar_num_threads
35+
type: uint
36+
level: advanced
37+
default: 0
38+
desc: The number of threads for serving seastar reactors without CPU pinning, overridden if crimson_seastar_cpu_cores is set
39+
flags:
40+
- startup
41+
min: 0
42+
max: 32
3443
- name: crimson_osd_stat_interval
3544
type: int
3645
level: advanced

src/crimson/os/alienstore/alien_store.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,23 @@ seastar::future<> AlienStore::start()
101101
if (!store) {
102102
ceph_abort_msgf("unsupported objectstore type: %s", type.c_str());
103103
}
104-
auto cpu_cores = seastar::resource::parse_cpuset(
105-
get_conf<std::string>("crimson_alien_thread_cpu_cores"));
106-
// crimson_alien_thread_cpu_cores are assigned to alien threads.
107-
if (!cpu_cores.has_value()) {
108-
// no core isolation by default, seastar_cpu_cores will be
109-
// shared between both alien and seastar reactor threads.
110-
cpu_cores = seastar::resource::parse_cpuset(
111-
get_conf<std::string>("crimson_seastar_cpu_cores"));
112-
ceph_assert(cpu_cores.has_value());
104+
/*
105+
* crimson_alien_thread_cpu_cores must be set for optimal performance.
106+
* Otherwise, no CPU pinning will take place.
107+
*/
108+
std::optional<seastar::resource::cpuset> alien_thread_cpu_cores;
109+
110+
if (std::string conf_cpu_cores =
111+
get_conf<std::string>("crimson_alien_thread_cpu_cores");
112+
!conf_cpu_cores.empty()) {
113+
logger().debug("{} using crimson_alien_thread_cpu_cores", __func__);
114+
alien_thread_cpu_cores =
115+
seastar::resource::parse_cpuset(conf_cpu_cores);
113116
}
117+
114118
const auto num_threads =
115119
get_conf<uint64_t>("crimson_alien_op_num_threads");
116-
tp = std::make_unique<crimson::os::ThreadPool>(num_threads, 128, cpu_cores);
120+
tp = std::make_unique<crimson::os::ThreadPool>(num_threads, 128, alien_thread_cpu_cores);
117121
return tp->start();
118122
}
119123

src/crimson/osd/main_config_bootstrap_helpers.cc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,32 @@ _get_early_config(int argc, const char *argv[])
150150
std::end(early_args),
151151
[](auto* arg) { return "--cpuset"sv == arg; });
152152
found == std::end(early_args)) {
153-
auto smp_config = crimson::common::get_conf<std::string>("crimson_seastar_cpu_cores");
154-
if (!smp_config.empty()) {
153+
auto cpu_cores = crimson::common::get_conf<std::string>("crimson_seastar_cpu_cores");
154+
if (!cpu_cores.empty()) {
155155
// Set --cpuset based on crimson_seastar_cpu_cores config option
156156
// --smp default is one per CPU
157157
ret.early_args.emplace_back("--cpuset");
158-
ret.early_args.emplace_back(smp_config);
159-
logger().info("get_early_config: set --cpuset {}", smp_config);
158+
ret.early_args.emplace_back(cpu_cores);
159+
ret.early_args.emplace_back("--thread-affinity");
160+
ret.early_args.emplace_back("1");
161+
logger().info("get_early_config: set --thread-affinity 1 --cpuset {}",
162+
cpu_cores);
160163
} else {
161-
logger().warn("get_early_config: no cpuset specified, falling back"
162-
" to seastar's default of: all");
164+
auto reactor_num = crimson::common::get_conf<uint64_t>("crimson_seastar_num_threads");
165+
if (!reactor_num) {
166+
logger().error("get_early_config: crimson_seastar_cpu_cores"
167+
" or crimson_seastar_num_threads"
168+
" must be set");
169+
ceph_abort();
170+
}
171+
std::string smp = fmt::format("{}", reactor_num);
172+
ret.early_args.emplace_back("--smp");
173+
ret.early_args.emplace_back(smp);
174+
ret.early_args.emplace_back("--thread-affinity");
175+
ret.early_args.emplace_back("0");
176+
logger().info("get_early_config: set --thread-affinity 0 --smp {}",
177+
smp);
178+
163179
}
164180
} else {
165181
logger().error("get_early_config: --cpuset can be "

src/crimson/osd/osd.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ seastar::future<> OSD::start()
361361
{
362362
LOG_PREFIX(OSD::start);
363363
INFO("seastar::smp::count {}", seastar::smp::count);
364-
364+
if (auto cpu_cores =
365+
local_conf().get_val<std::string>("crimson_seastar_cpu_cores");
366+
cpu_cores.empty()) {
367+
clog->warn() << "for optimal performance please set "
368+
"crimson_seastar_cpu_cores";
369+
}
365370
startup_time = ceph::mono_clock::now();
366371
ceph_assert(seastar::this_shard_id() == PRIMARY_CORE);
367372
return store.start().then([this] {

0 commit comments

Comments
 (0)