]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add bios_family
authorHuang Shijie <shijie@os.amperecomputing.com>
Tue, 15 Jun 2021 10:06:39 +0000 (10:06 +0000)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Jun 2021 09:12:14 +0000 (11:12 +0200)
In the arm platform, we do not have the "CPU family" as X86.
In the linux kernel, it is hardcode to set the "CPU architecuture:8"
which should be changed for arm v9 in future.

This patch adds "bios_family" field, which we can get from the DMI table.
In the ampere Altra platform, we can get the new lscpu output:
    ----------------------------------------------------------------
Architecture:                    aarch64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
CPU(s):                          160
On-line CPU(s) list:             0-159
Vendor ID:                       ARM
BIOS Vendor ID:                  Ampere(R)
Model name:                      Neoverse-N1
BIOS Model name:                 Ampere(R) Altra(R) Processor Q00-00 CPU @ 3.0GHz
BIOS CPU family:                 257
Model:                           1
Thread(s) per core:              1
    ----------------------------------------------------------------

[kzak@redhat.com: - s/sprintf/snprintf/]

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu-cputype.c
sys-utils/lscpu-dmi.c
sys-utils/lscpu.c
sys-utils/lscpu.h

index d5ca8e1f1d12e15d7f4f97f09b21cd5817c0830d..d5f0eb7d69adcaa1742ed9a9e05645f217230935 100644 (file)
@@ -81,6 +81,7 @@ void lscpu_unref_cputype(struct lscpu_cputype *ct)
                free(ct->model);
                free(ct->modelname);
                free(ct->bios_modelname);
+               free(ct->bios_family);
                free(ct->revision);     /* alternative for model (ppc) */
                free(ct->stepping);
                free(ct->bogomips);
index 177b787ebbd541e43370e14e92e56e644256d2e0..782881b75c6e2784767d263904266fd23851bd46 100644 (file)
@@ -73,6 +73,11 @@ int parse_dmi_table(uint16_t len, uint16_t num,
                                di->processor_version = dmi_string(&h, data[0x10]);
                                di->current_speed = *((uint16_t *)(&data[0x16]));
                                di->part_num = dmi_string(&h, data[0x22]);
+
+                               if (data[0x6] == 0xfe)
+                                       di->processor_family = *((uint16_t *)(&data[0x28]));
+                               else
+                                       di->processor_family = data[0x6];
                        }
                        di->sockets++;
                        break;
@@ -117,6 +122,11 @@ int dmi_decode_cputype(struct lscpu_cputype *ct)
                        di.current_speed/1000, (di.current_speed % 1000) / 100);
        ct->bios_modelname = xstrdup(buf);
 
+       /* Get CPU family */
+       memset(buf, 0, sizeof(buf));
+       snprintf(buf, sizeof(buf), "%d", di.processor_family);
+       ct->bios_family = xstrdup(buf);
+
        free(data);
        return 0;
 }
index 5a99a9a5b0fd8d0a2f99939c14a7f43c7142e912..827e84a6d1fa2a60d9b1212eab26212f778a0782 100644 (file)
@@ -863,6 +863,8 @@ print_summary_cputype(struct lscpu_cxt *cxt,
                sec = add_summary_s(tb, sec, _("Model name:"), ct->modelname);
        if (ct->bios_modelname)
                add_summary_s(tb, sec, _("BIOS Model name:"), ct->bios_modelname);
+       if (ct->bios_family)
+               add_summary_s(tb, sec, _("BIOS CPU family:"), ct->bios_family);
        if (ct->machinetype)
                add_summary_s(tb, sec, _("Machine type:"), ct->machinetype);
        if (ct->family)
index 4dc8e0a239658a716ae9961b4f276239d654e6a5..79477b469df72ad01fe2199dedad31041ef6d9b3 100644 (file)
@@ -65,6 +65,7 @@ struct lscpu_cputype {
        char    *model;
        char    *modelname;
        char    *bios_modelname; /* aarch64 */
+       char    *bios_family; /* aarch64 */
        char    *revision;      /* alternative for model (ppc) */
        char    *stepping;
        char    *bogomips;
@@ -318,6 +319,7 @@ struct dmi_info {
        int sockets;
 
        /* Processor Information */
+       uint16_t processor_family;
        char *processor_manufacturer;
        char *processor_version;
        uint16_t current_speed;