diff options
author | Stanislav Brabec | 2018-05-09 18:08:32 +0200 |
---|---|---|
committer | Karel Zak | 2018-05-10 11:41:23 +0200 |
commit | 538b50cb0a4aac56b6b3b6e4d1e8ce886854c6d8 (patch) | |
tree | 28bfe412d74fe6d822aac245279c9f82d9bd04ca /sys-utils/lscpu.c | |
parent | last: fix false positive compiler warning (diff) | |
download | kernel-qcow2-util-linux-538b50cb0a4aac56b6b3b6e4d1e8ce886854c6d8.tar.gz kernel-qcow2-util-linux-538b50cb0a4aac56b6b3b6e4d1e8ce886854c6d8.tar.xz kernel-qcow2-util-linux-538b50cb0a4aac56b6b3b6e4d1e8ce886854c6d8.zip |
lscpu, chcpu: Avoid use of the old CPU macros
The old CPU macros are limited to 1024 cores. As a result, lscpu cannot
count sockets on large systems. Use new scalable macros.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Michael Matz <matz@suse.de>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 2132511a5..fd6d63bbf 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -478,7 +478,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) desc->idx2cpunum = xcalloc(desc->ncpuspos, sizeof(int)); for (num = 0, idx = 0; num < maxcpus; num++) { - if (CPU_ISSET(num, tmp)) + if (CPU_ISSET_S(num, setsize, tmp)) desc->idx2cpunum[idx++] = num; } cpuset_free(tmp); @@ -1109,10 +1109,11 @@ cpu_max_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz) { int i; float cpu_freq = 0.0; + size_t setsize = CPU_ALLOC_SIZE(maxcpus); if (desc->present) { for (i = 0; i < desc->ncpuspos; i++) { - if (CPU_ISSET(real_cpu_num(desc, i), desc->present) + if (CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present) && desc->maxmhz[i]) { float freq = atof(desc->maxmhz[i]); @@ -1131,10 +1132,11 @@ cpu_min_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz) { int i; float cpu_freq = -1.0; + size_t setsize = CPU_ALLOC_SIZE(maxcpus); if (desc->present) { for (i = 0; i < desc->ncpuspos; i++) { - if (CPU_ISSET(real_cpu_num(desc, i), desc->present) + if (CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present) && desc->minmhz[i]) { float freq = atof(desc->minmhz[i]); @@ -1931,6 +1933,7 @@ int main(int argc, char *argv[]) int c, i; int columns[ARRAY_SIZE(coldescs)], ncolumns = 0; int cpu_modifier_specified = 0; + size_t setsize; static const struct option longopts[] = { { "all", no_argument, NULL, 'a' }, @@ -2034,10 +2037,12 @@ int main(int argc, char *argv[]) read_basicinfo(desc, mod); + setsize = CPU_ALLOC_SIZE(maxcpus); + for (i = 0; i < desc->ncpuspos; i++) { /* only consider present CPUs */ if (desc->present && - !CPU_ISSET(real_cpu_num(desc, i), desc->present)) + !CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present)) continue; read_topology(desc, i); read_cache(desc, i); |