From fc4840ebc9ad62231a98e1070b39aee86a16b9ca Mon Sep 17 00:00:00 2001 From: jolai <58589285+laijonathan@users.noreply.github.com> Date: Fri, 6 Oct 2023 13:53:38 -0400 Subject: [PATCH] zos: correctly get cpu model in uv_cpu_info() (#4136) The previous implementation using si11v1cpcmodel did not return a valid cpu model on z/OS. So use PCCA instead to correctly get the cpu model. Co-authored-by: Wayne Zhang Co-authored-by: Gaby Baghdadi Co-authored-by: Jonathan Lai Fixes: https://github.com/libuv/libuv/issues/4102 --- src/unix/os390.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/unix/os390.c b/src/unix/os390.c index bbd37692..1b277292 100644 --- a/src/unix/os390.c +++ b/src/unix/os390.c @@ -19,6 +19,7 @@ * IN THE SOFTWARE. */ +#include "uv.h" #include "internal.h" #include #include @@ -30,6 +31,7 @@ #include #include #include "zos-base.h" +#include "zos-sys-info.h" #if defined(__clang__) #include "csrsic.h" #else @@ -66,9 +68,6 @@ /* Total number of frames currently on all available frame queues. */ #define RCEAFC_OFFSET 0x088 -/* CPC model length from the CSRSI Service. */ -#define CPCMODEL_LENGTH 16 - /* Pointer to the home (current) ASCB. */ #define PSAAOLD 0x224 @@ -258,9 +257,12 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { idx = 0; while (idx < *count) { cpu_info->speed = *(int*)(info.siv1v2si22v1.si22v1cpucapability); - cpu_info->model = uv__malloc(CPCMODEL_LENGTH + 1); - memset(cpu_info->model, '\0', CPCMODEL_LENGTH + 1); - memcpy(cpu_info->model, info.siv1v2si11v1.si11v1cpcmodel, CPCMODEL_LENGTH); + cpu_info->model = uv__malloc(ZOSCPU_MODEL_LENGTH + 1); + if (cpu_info->model == NULL) { + uv_free_cpu_info(*cpu_infos, idx); + return UV_ENOMEM; + } + __get_cpu_model(cpu_info->model, ZOSCPU_MODEL_LENGTH + 1); cpu_info->cpu_times.user = cpu_usage_avg; /* TODO: implement the following */ cpu_info->cpu_times.sys = 0;