diff --git a/programs/util.c b/programs/util.c index 652530b1223..dc18a9ac042 100644 --- a/programs/util.c +++ b/programs/util.c @@ -1593,6 +1593,7 @@ int UTIL_countCores(int logical) int siblings = 0; int cpu_cores = 0; + int procs = 0; int ratio = 1; if (cpuinfo == NULL) { @@ -1622,6 +1623,15 @@ int UTIL_countCores(int logical) cpu_cores = atoi(sep + 1); } + if (strncmp(buff, "processor", 9) == 0) { + const char* const sep = strchr(buff, ':'); + if (sep == NULL || *sep == '\0') { + /* formatting was broken? */ + goto failed; + } + + procs++; + } } else if (ferror(cpuinfo)) { /* fall back on the sysconf value */ goto failed; @@ -1633,6 +1643,9 @@ int UTIL_countCores(int logical) if (ratio && numCores > ratio && !logical) { numCores = numCores / ratio; } + if (procs) { + numCores = procs; + } failed: fclose(cpuinfo);