[COMMIT seastar master] core/resource: do not check c.cpus for null

0 views
Skip to first unread message

Commit Bot

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

core/resource: do not check c.cpus for null

* change `configuration::cpus` to plain value instead of an optional
* do not provide fallback value for it anymore.

along with `rc.cpu_set`, `rc.cpus` is already set at the caller site
before `resource::allocate(rc)` gets called. so `rc.cpus` always has
a value.

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

---
diff --git a/include/seastar/core/resource.hh b/include/seastar/core/resource.hh
--- a/include/seastar/core/resource.hh
+++ b/include/seastar/core/resource.hh
@@ -88,7 +88,7 @@ struct configuration {
optional<size_t> total_memory;
optional<size_t> reserve_memory; // if total_memory not specified
size_t reserve_additional_memory;
- optional<size_t> cpus;
+ size_t cpus;
optional<cpuset> cpu_set;
bool assign_orphan_cpus = false;
std::vector<dev_t> devices;
diff --git a/src/core/resource.cc b/src/core/resource.cc
--- a/src/core/resource.cc
+++ b/src/core/resource.cc
@@ -512,7 +512,7 @@ resources allocate(configuration& c) {
size_t mem = calculate_memory(c, std::min(available_memory,
cgroup::memory_limit()));
unsigned available_procs = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_PU);
- unsigned procs = c.cpus.value_or(available_procs);
+ unsigned procs = c.cpus;
if (procs > available_procs) {
throw std::runtime_error(format("insufficient processing units: needed {} available {}", procs, available_procs));
}
@@ -672,8 +672,7 @@ resources allocate(configuration& c) {

auto available_memory = ::sysconf(_SC_PAGESIZE) * size_t(::sysconf(_SC_PHYS_PAGES));
auto mem = calculate_memory(c, available_memory);
- auto cpuset_procs = c.cpu_set ? c.cpu_set->size() : nr_processing_units(c);
- auto procs = c.cpus.value_or(cpuset_procs);
+ auto procs = c.cpus;
ret.cpus.reserve(procs);
// limit memory address to fit in 36-bit, see core/memory.cc:Memory map
constexpr size_t max_mem_per_proc = 1UL << 36;
Reply all
Reply to author
Forward
0 new messages