dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
05ad79
From 72e09b02e7b4cf3e9e77ef02d5073d9a11f3b314 Mon Sep 17 00:00:00 2001
05ad79
From: Stanislav Brabec <sbrabec@suse.cz>
05ad79
Date: Wed, 9 May 2018 22:13:07 +0200
05ad79
Subject: [PATCH 173/173] chcpu: Fix maximal number of CPUs
05ad79
05ad79
chcpu.c mixed maxcpus (number of cpus) and setsize (size of CPU bit
05ad79
mask). It effectively limits number of CPUs to 1/8 of the supported
05ad79
amount.
05ad79
05ad79
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
05ad79
Cc: Michael Matz <matz@suse.de>
05ad79
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
05ad79
Upstream: http://github.com/karelzak/util-linux/commit/607274943bfd3d4856b872bc4278b36903fb2182
05ad79
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1579439
05ad79
---
05ad79
 sys-utils/chcpu.c | 16 ++++++++--------
05ad79
 1 file changed, 8 insertions(+), 8 deletions(-)
05ad79
05ad79
diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c
05ad79
index 7843dfb22..1a0157360 100644
05ad79
--- a/sys-utils/chcpu.c
05ad79
+++ b/sys-utils/chcpu.c
05ad79
@@ -75,12 +75,12 @@ enum {
05ad79
  */
05ad79
 static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable)
05ad79
 {
05ad79
-	unsigned int cpu;
05ad79
+	int cpu;
05ad79
 	int online, rc;
05ad79
 	int configured = -1;
05ad79
-	size_t fails = 0;
05ad79
+	int fails = 0;
05ad79
 
05ad79
-	for (cpu = 0; cpu < setsize; cpu++) {
05ad79
+	for (cpu = 0; cpu < maxcpus; cpu++) {
05ad79
 		if (!CPU_ISSET_S(cpu, setsize, cpu_set))
05ad79
 			continue;
05ad79
 		if (!path_exist(_PATH_SYS_CPU "/cpu%d", cpu)) {
05ad79
@@ -132,7 +132,7 @@ static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable)
05ad79
 		}
05ad79
 	}
05ad79
 
05ad79
-	return fails == 0 ? 0 : fails == setsize ? -1 : 1;
05ad79
+	return fails == 0 ? 0 : fails == maxcpus ? -1 : 1;
05ad79
 }
05ad79
 
05ad79
 static int cpu_rescan(void)
05ad79
@@ -168,11 +168,11 @@ static int cpu_set_dispatch(int mode)
05ad79
  */
05ad79
 static int cpu_configure(cpu_set_t *cpu_set, size_t setsize, int configure)
05ad79
 {
05ad79
-	unsigned int cpu;
05ad79
+	int cpu;
05ad79
 	int rc, current;
05ad79
-	size_t fails = 0;
05ad79
+	int fails = 0;
05ad79
 
05ad79
-	for (cpu = 0; cpu < setsize; cpu++) {
05ad79
+	for (cpu = 0; cpu < maxcpus; cpu++) {
05ad79
 		if (!CPU_ISSET_S(cpu, setsize, cpu_set))
05ad79
 			continue;
05ad79
 		if (!path_exist(_PATH_SYS_CPU "/cpu%d", cpu)) {
05ad79
@@ -217,7 +217,7 @@ static int cpu_configure(cpu_set_t *cpu_set, size_t setsize, int configure)
05ad79
 		}
05ad79
 	}
05ad79
 
05ad79
-	return fails == 0 ? 0 : fails == setsize ? -1 : 1;
05ad79
+	return fails == 0 ? 0 : fails == maxcpus ? -1 : 1;
05ad79
 }
05ad79
 
05ad79
 static void cpu_parse(char *cpu_string, cpu_set_t *cpu_set, size_t setsize)
05ad79
-- 
05ad79
2.14.4
05ad79