From 778254d9a22a7303820baaa3b10cd144fd907a6f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 4 Sep 2020 11:27:33 +0200 Subject: [PATCH] lscpu: keep static/dynamic MHz in cputype struct The Dynamic and Static MHz are /proc/cpuinfo s390 per-CPU fields, but we display it as a single value according the first parsed CPU. For this purpose we store the values from the first CPU in lscpu_cputype. For -p and -e outputs we will print per CPU values. Signed-off-by: Karel Zak --- sys-utils/lscpu-cputype.c | 7 +++++++ sys-utils/lscpu.h | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c index c1333d042f..4fe4f3f8a0 100644 --- a/sys-utils/lscpu-cputype.c +++ b/sys-utils/lscpu-cputype.c @@ -82,6 +82,8 @@ void lscpu_unref_cputype(struct lscpu_cputype *ct) free(ct->flags); free(ct->mtid); /* maximum thread id (s390) */ free(ct->addrsz); /* address sizes */ + free(ct->static_mhz); + free(ct->dynamic_mhz); free(ct); } } @@ -479,6 +481,11 @@ int lscpu_read_cpuinfo(struct lscpu_cxt *cxt) DBG(GATHER, ul_debug("*** cpu data before cpu ID")); else strdup_to_offset(pr->curr_cpu, pattern->offset, value); + + if (pattern->id == PAT_MHZ_DYNAMIC && pr->curr_type && !pr->curr_type->dynamic_mhz) + pr->curr_type->dynamic_mhz = xstrdup(value); + if (pattern->id == PAT_MHZ_STATIC && pr->curr_type && !pr->curr_type->static_mhz) + pr->curr_type->static_mhz = xstrdup(value); break; case CPUINFO_LINE_CPUTYPE: if (pr->curr_type && is_different_cputype(pr->curr_type, pattern->offset, value)) { diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h index 011444e2f7..78948c4b6a 100644 --- a/sys-utils/lscpu.h +++ b/sys-utils/lscpu.h @@ -81,6 +81,9 @@ struct lscpu_cputype { size_t nbooks_per_drawer; size_t ndrawers_per_system; + char *dynamic_mhz; /* s390; copy from the first CPU */ + char *static_mhz; /* s390; copy from the first CPU */ + /* siblings maps */ size_t ncores; cpu_set_t **coremaps; @@ -91,7 +94,7 @@ struct lscpu_cputype { size_t ndrawers; cpu_set_t **drawermaps; - unsigned int has_freq; + unsigned int has_freq : 1; /* has max/nim frequence info */ }; /* dispatching modes */ -- 2.47.3