chpstat: Fix invalid utilization data on older kernels

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: 026ecbafea ("chpstat: Add support for full CMCB")
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Peter Oberparleiter
2024-12-13 16:11:45 +01:00
committed by Jan Höppner
parent 3b8fdcc892
commit 6520070a46
2 changed files with 3 additions and 3 deletions

View File

@@ -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);

View File

@@ -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))