From d62e0754502a2ff2b499557ce4d4b6be88742e00 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Fri, 21 Jan 2022 13:00:39 +0100 Subject: [PATCH] cpumf/lshwc.c: Fix CPU list parameter setup for device driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lshwc allows to specify a list of CPUs, for example # ./lshwc -a 2-3,66-68:b Date,Time,CPU,CPU_CYCLES(0),INSTRUCTIONS(1),L1I_DIR_WRITES(2),.... 2022-01-21,12:51:54,CPU2,68762,20999,283,14157,601,87255 2022-01-21,12:51:54,CPU3,70514,21179,288,10654,586,90188 2022-01-21,12:51:54,CPU4,48504,21018,141,7831,438,78494 2022-01-21,12:51:54,Total,187780,63196,712,32642,1625,255937 # However, as seen on the output, the CPU list is incorrect. It shows CPUs 2, 3 and 4 even when only CPU 2 and 3 was requested. CPUs 66, 67 and 68 have not been online and can not be displayed. What happens is a wrong parameter conversion for the device driver. CPUs 66, 67 and 68 are passed to the device driver as CPUs 2 3 and 4 and that data is returned. Fix this and submit a CPU list with correct bit ordering: # ./lshwc -a 2-3,66-68:b Date,Time,CPU,CPU_CYCLES(0),INSTRUCTIONS(1),L1I_DIR_WRITES(2),... 2022-01-21,12:59:18,CPU2,50753,18042,246,10972,494,60345 2022-01-21,12:59:18,CPU3,54002,20390,232,9219,511,66033 2022-01-21,12:59:18,Total,104755,38432,478,20191,1005,126378 # Reported-by: Sumanth Korikkar Signed-off-by: Thomas Richter Acked-by: Sumanth Korikkar Signed-off-by: Jan Höppner --- cpumf/lshwc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cpumf/lshwc.c b/cpumf/lshwc.c index f9778170..099a7e76 100644 --- a/cpumf/lshwc.c +++ b/cpumf/lshwc.c @@ -298,14 +298,8 @@ static void parse_cpulist(char *parm, struct s390_hwctr_start *start) words[no_b] |= 1ULL << no_a; } } - /* no_b is highest used index, swap array */ - start->cpumask_len = (no_b + 1) * 8; - for (no_a = 0; no_a < no_b; ++no_a, --no_b) { - uint64_t tmp = words[no_a]; - - words[no_a] = words[no_b]; - words[no_b] = tmp; - } + /* no_b is highest used index */ + start->cpumask_len = (no_b + 1) * CHAR_BIT; start->version = S390_HWCTR_START_VERSION; }