Skip to content

Commit

Permalink
Correctly detect CPU cores when cpuset cgroup is used
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeFoxie committed Sep 27, 2023
1 parent 16a8fa2 commit 90838f6
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 90838f6

Please sign in to comment.