diff --git a/lib/base/configuration.cpp b/lib/base/configuration.cpp index 4b25d8932f4..3d438201351 100644 --- a/lib/base/configuration.cpp +++ b/lib/base/configuration.cpp @@ -78,30 +78,33 @@ int Configuration::Concurrency{([]() -> int { #ifdef __linux__ { - auto rawCpus (ReadSysLine("/sys/fs/cgroup/cpuset/cpuset.cpus")); + for (auto* cpuset : {"/sys/fs/cgroup/cpuset.cpus.effective", "/sys/fs/cgroup/cpuset/cpuset.cpus"}) { + auto rawCpus (ReadSysLine(cpuset)); - if (rawCpus.length()) { - std::vector ranges; - boost::split(ranges, rawCpus, is_any_of(",")); + if (rawCpus.length()) { + std::vector ranges; + boost::split(ranges, rawCpus, is_any_of(",")); - std::set cpus; + std::set cpus; - for (auto& range : ranges) { - std::vector rangeEnds; - boost::split(rangeEnds, range, is_any_of("-")); + for (auto& range : ranges) { + std::vector rangeEnds; + boost::split(rangeEnds, range, is_any_of("-")); - if (rangeEnds.size() > 1u) { - auto to (boost::lexical_cast(rangeEnds.at(1))); + if (rangeEnds.size() > 1u) { + auto to (boost::lexical_cast(rangeEnds.at(1))); - for (auto i (boost::lexical_cast(rangeEnds.at(0))); i <= to; ++i) { - cpus.emplace(i); + for (auto i (boost::lexical_cast(rangeEnds.at(0))); i <= to; ++i) { + cpus.emplace(i); + } + } else { + cpus.emplace(boost::lexical_cast(rangeEnds.at(0))); } - } else { - cpus.emplace(boost::lexical_cast(rangeEnds.at(0))); } - } - concurrency = cpus.size(); + concurrency = cpus.size(); + break; + } } }