summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorHeiko Carstens2016-07-29 14:13:34 +0200
committerKarel Zak2016-08-03 13:35:05 +0200
commit0002704ebe998d70af87d4385cc243baae7b2059 (patch)
treed869517b09f3deb640ffb198053ea42bffa0bbcb /sys-utils/lscpu.c
parentlscpu: add parsable testcase with the --physical option (diff)
downloadkernel-qcow2-util-linux-0002704ebe998d70af87d4385cc243baae7b2059.tar.gz
kernel-qcow2-util-linux-0002704ebe998d70af87d4385cc243baae7b2059.tar.xz
kernel-qcow2-util-linux-0002704ebe998d70af87d4385cc243baae7b2059.zip
lscpu: only try to read sysfs attributes of present CPUs
lscpu can skip all CPUs which are possible but not present. For configurations where a lot of CPUs are possible but only few CPUs are present this saves a lot of pointless glibc/system calls. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index dbb639c2f..1da595b3d 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -2059,6 +2059,10 @@ int main(int argc, char *argv[])
read_basicinfo(desc, mod);
for (i = 0; i < desc->ncpuspos; i++) {
+ /* only consider present CPUs */
+ if (desc->present &&
+ !CPU_ISSET(real_cpu_num(desc, i), desc->present))
+ continue;
read_topology(desc, i);
read_cache(desc, i);
read_polarization(desc, i);