From 6520070a4648c0993204bfd2a05570c15f528310 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 13 Dec 2024 16:11:45 +0100 Subject: [PATCH] chpstat: Fix invalid utilization data on older kernels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On kernels without support for the new "measurement_chars_full" CHPID sysfs attribute, chpstat displays invalid utilization numbers (nan/inf). This is due to an invalid buffer address calculation when reading the old "measurement_chars" attribute. Fix this by using the correct buffer address calculation. Fixes: 026ecbafea5b ("chpstat: Add support for full CMCB") Signed-off-by: Peter Oberparleiter Reviewed-by: Vineeth Vijayan Signed-off-by: Jan Höppner --- zconf/chp/chpstat/chpstat.c | 2 +- zconf/chp/chpstat/cmg.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zconf/chp/chpstat/chpstat.c b/zconf/chp/chpstat/chpstat.c index 1b0cf8c4..09d1e94c 100644 --- a/zconf/chp/chpstat/chpstat.c +++ b/zconf/chp/chpstat/chpstat.c @@ -719,7 +719,7 @@ static bool read_cmcb(int chpid, cmcb_t *cmcb) free(path); path = get_chpid_path(chpid, "measurement_chars"); /* Partial CMCB contains data starting at word 3. */ - read_bin(path, &cmcb[PARTIAL_CMCB_OFFSET], + read_bin(path, (char *)cmcb + PARTIAL_CMCB_OFFSET, PARTIAL_CMCB_SIZE, false); } free(path); diff --git a/zconf/chp/chpstat/cmg.h b/zconf/chp/chpstat/cmg.h index a0cff894..e2f610f6 100644 --- a/zconf/chp/chpstat/cmg.h +++ b/zconf/chp/chpstat/cmg.h @@ -17,8 +17,8 @@ #include "column.h" #define CMCB_SIZE (8 * sizeof(u32)) -#define PARTIAL_CMCB_OFFSET 3 -#define PARTIAL_CMCB_SIZE (CMCB_SIZE - PARTIAL_CMCB_OFFSET * sizeof(u32)) +#define PARTIAL_CMCB_OFFSET (3 * sizeof(u32)) +#define PARTIAL_CMCB_SIZE (CMCB_SIZE - PARTIAL_CMCB_OFFSET) #define CUE_SIZE (8 * sizeof(u32)) #define EXT_CUE_SIZE (16 * sizeof(u32)) #define METRICS_SIZE (18 * sizeof(double))