From 607274943bfd3d4856b872bc4278b36903fb2182 Mon Sep 17 00:00:00 2001 From: Stanislav Brabec Date: Wed, 9 May 2018 22:13:07 +0200 Subject: [PATCH] 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 --- 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 f32b7a6fc..4b5c7579a 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.16.3