[PATCH 3/5] lscpu: only try to read sysfs attributes of present CPUs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 sys-utils/lscpu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index dbb639c2fe2a..1da595b3dac7 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);
-- 
2.6.6

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux