Blame SOURCES/0172-lscpu-chcpu-Avoid-use-of-the-old-CPU-macros.patch

5113bc
From 255a3b8bb8cbcb3f689cc3332983983bfbf9eca0 Mon Sep 17 00:00:00 2001
5113bc
From: Stanislav Brabec <sbrabec@suse.cz>
5113bc
Date: Wed, 9 May 2018 18:08:32 +0200
5113bc
Subject: [PATCH 172/173] lscpu, chcpu: Avoid use of the old CPU macros
5113bc
5113bc
The old CPU macros are limited to 1024 cores. As a result, lscpu cannot
5113bc
count sockets on large systems. Use new scalable macros.
5113bc
5113bc
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
5113bc
Cc: Michael Matz <matz@suse.de>
5113bc
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1579439
5113bc
Upstream: http://github.com/karelzak/util-linux/commit/538b50cb0a4aac56b6b3b6e4d1e8ce886854c6d8
5113bc
---
5113bc
 sys-utils/chcpu.c | 6 +++---
5113bc
 sys-utils/lscpu.c | 7 +++++--
5113bc
 2 files changed, 8 insertions(+), 5 deletions(-)
5113bc
5113bc
diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c
5113bc
index ada0eaacc..7843dfb22 100644
5113bc
--- a/sys-utils/chcpu.c
5113bc
+++ b/sys-utils/chcpu.c
5113bc
@@ -81,7 +81,7 @@ static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable)
5113bc
 	size_t fails = 0;
5113bc
 
5113bc
 	for (cpu = 0; cpu < setsize; cpu++) {
5113bc
-		if (!CPU_ISSET(cpu, cpu_set))
5113bc
+		if (!CPU_ISSET_S(cpu, setsize, cpu_set))
5113bc
 			continue;
5113bc
 		if (!path_exist(_PATH_SYS_CPU "/cpu%d", cpu)) {
5113bc
 			warnx(_("CPU %d does not exist"), cpu);
5113bc
@@ -127,7 +127,7 @@ static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable)
5113bc
 			} else {
5113bc
 				printf(_("CPU %d disabled\n"), cpu);
5113bc
 				if (onlinecpus)
5113bc
-					CPU_CLR(cpu, onlinecpus);
5113bc
+					CPU_CLR_S(cpu, setsize, onlinecpus);
5113bc
 			}
5113bc
 		}
5113bc
 	}
5113bc
@@ -173,7 +173,7 @@ static int cpu_configure(cpu_set_t *cpu_set, size_t setsize, int configure)
5113bc
 	size_t fails = 0;
5113bc
 
5113bc
 	for (cpu = 0; cpu < setsize; cpu++) {
5113bc
-		if (!CPU_ISSET(cpu, cpu_set))
5113bc
+		if (!CPU_ISSET_S(cpu, setsize, cpu_set))
5113bc
 			continue;
5113bc
 		if (!path_exist(_PATH_SYS_CPU "/cpu%d", cpu)) {
5113bc
 			warnx(_("CPU %d does not exist"), cpu);
5113bc
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
5113bc
index 4c15de1d4..002ad0d1c 100644
5113bc
--- a/sys-utils/lscpu.c
5113bc
+++ b/sys-utils/lscpu.c
5113bc
@@ -626,7 +626,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
5113bc
 		desc->idx2cpunum = xcalloc(desc->ncpuspos, sizeof(int));
5113bc
 
5113bc
 		for (num = 0, idx = 0; num < maxcpus; num++) {
5113bc
-			if (CPU_ISSET(num, tmp))
5113bc
+			if (CPU_ISSET_S(num, setsize, tmp))
5113bc
 				desc->idx2cpunum[idx++] = num;
5113bc
 		}
5113bc
 		cpuset_free(tmp);
5113bc
@@ -2038,6 +2038,7 @@ int main(int argc, char *argv[])
5113bc
 	int c, i;
5113bc
 	int columns[ARRAY_SIZE(coldescs)], ncolumns = 0;
5113bc
 	int cpu_modifier_specified = 0;
5113bc
+	size_t setsize;
5113bc
 
5113bc
 	static const struct option longopts[] = {
5113bc
 		{ "all",        no_argument,       NULL, 'a' },
5113bc
@@ -2134,10 +2135,12 @@ int main(int argc, char *argv[])
5113bc
 
5113bc
 	read_basicinfo(desc, mod);
5113bc
 
5113bc
+	setsize = CPU_ALLOC_SIZE(maxcpus);
5113bc
+
5113bc
 	for (i = 0; i < desc->ncpuspos; i++) {
5113bc
 		/* only consider present CPUs */
5113bc
 		if (desc->present &&
5113bc
-		    !CPU_ISSET(real_cpu_num(desc, i), desc->present))
5113bc
+		    !CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present))
5113bc
 			continue;
5113bc
 		read_topology(desc, i);
5113bc
 		read_cache(desc, i);
5113bc
-- 
5113bc
2.14.4
5113bc