[COMMIT seastar master] reactor: initialize smp::count without a temporary value

0 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Feb 1, 2023, 1:26:21 PM2/1/23
to seastar-dev@googlegroups.com, Kefu Chai
From: Kefu Chai <kefu...@scylladb.com>
Committer: Kefu Chai <tcha...@gmail.com>
Branch: master

reactor: initialize smp::count without a temporary value

before this change, `smp::count` and `nr_cpus` are always initialized
with a certain value respectively, but neither of them are read after
being reassigned with another value. this is confusing and adds the
load of a programmer parsing the source code.

after this change, `nr_cpus` is dropped. and `smp::count` is initialized
at the place where `nr_cpus` is set.

Signed-off-by: Kefu Chai <kefu...@scylladb.com>

---
diff --git a/src/core/reactor.cc b/src/core/reactor.cc
--- a/src/core/reactor.cc
+++ b/src/core/reactor.cc
@@ -4088,9 +4088,7 @@ void smp::configure(const smp_options& smp_opts, const reactor_options& reactor_

resource::configuration rc;

- smp::count = 1;
smp::_tmain = std::this_thread::get_id();
- auto nr_cpus = resource::nr_processing_units(rc);
resource::cpuset cpu_set = get_current_cpuset();

if (smp_opts.cpuset) {
@@ -4114,13 +4112,12 @@ void smp::configure(const smp_options& smp_opts, const reactor_options& reactor_
}

if (smp_opts.smp) {
- nr_cpus = smp_opts.smp.get_value();
+ smp::count = smp_opts.smp.get_value();
} else {
- nr_cpus = cpu_set.size();
+ smp::count = cpu_set.size();
}
- smp::count = nr_cpus;
logger::set_shard_field_width(std::ceil(std::log10(smp::count)));
- std::vector<reactor*> reactors(nr_cpus);
+ std::vector<reactor*> reactors(smp::count);
if (smp_opts.memory) {
rc.total_memory = parse_memory_size(smp_opts.memory.get_value());
#ifdef SEASTAR_HAVE_DPDK
Reply all
Reply to author
Forward
0 new messages