From: Heiko Carstens Date: Fri, 29 Jul 2016 12:13:34 +0000 (+0200) Subject: lscpu: only try to read sysfs attributes of present CPUs X-Git-Tag: v2.29-rc1~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0002704ebe998d70af87d4385cc243baae7b2059;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index dbb639c2fe..1da595b3da 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);