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