]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: keep static/dynamic MHz in cputype struct
authorKarel Zak <kzak@redhat.com>
Fri, 4 Sep 2020 09:27:33 +0000 (11:27 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 13 Nov 2020 08:19:02 +0000 (09:19 +0100)
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 <kzak@redhat.com>
sys-utils/lscpu-cputype.c
sys-utils/lscpu.h

index c1333d042f01d88fe5e33e9610fcaa46a44ced0f..4fe4f3f8a0dcd3626d4623ac622c2ca299461aef 100644 (file)
@@ -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)) {
index 011444e2f718a9bbcfde31754e091017fa74adbc..78948c4b6ad7d8df301fd1242e67a770688c7260 100644 (file)
@@ -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 */