]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: only try to read sysfs attributes of present CPUs
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Fri, 29 Jul 2016 12:13:34 +0000 (14:13 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Aug 2016 11:35:05 +0000 (13:35 +0200)
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>
sys-utils/lscpu.c

index dbb639c2fe2a6cf32be3fddcf9230b9270509868..1da595b3dac7fddcd8b0b7966382c423d853e857 100644 (file)
@@ -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);