Skip to content

Commit

Permalink
Merge pull request #5373 from CallMeFoxie/ashley/cpuset
Browse files Browse the repository at this point in the history
Correctly detect CPU cores when cpuset cgroup is used
  • Loading branch information
AenBleidd authored Sep 28, 2023
2 parents aa4173d + 90838f6 commit 8b5334d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/hostinfo_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,12 @@ int HOST_INFO::get_cpu_count() {
if(cpus_sys_path > p_ncpus){
p_ncpus = cpus_sys_path;
}
#elif __GNU_LIBRARY__ /* glibc */
cpu_set_t set;

if (sched_getaffinity (0, sizeof (set), &set) == 0) {
p_ncpus = CPU_COUNT (&set);
}
#elif defined(_SC_NPROCESSORS_ONLN) && !defined(__EMX__) && !defined(__APPLE__)
// sysconf not working on OS2
p_ncpus = sysconf(_SC_NPROCESSORS_ONLN);
Expand Down

0 comments on commit 8b5334d

Please sign in to comment.