lscpu: add bios_family

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>
This commit is contained in:
Huang Shijie 2021-06-15 10:06:39 +00:00 committed by Karel Zak
parent a772d7c493
commit 4cae2104ec
4 changed files with 15 additions and 0 deletions

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

View 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;
}

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

View 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;