From: Huang Shijie <shijie@os.amperecomputing.com>
To: util-linux@vger.kernel.org
Cc: patches@amperecomputing.com, zwang@amperecomputing.com,
mas@amperecomputing.com, ilkka@os.amperecomputing.com,
jeremy.linton@arm.com, jbastian@redhat.com,
m.mizuma@jp.fujitsu.com,
Huang Shijie <shijie@os.amperecomputing.com>
Subject: [RFC PATCH 2/2] lscpu: add bios_family
Date: Tue, 15 Jun 2021 10:06:39 +0000 [thread overview]
Message-ID: <20210615100639.51546-2-shijie@os.amperecomputing.com> (raw)
In-Reply-To: <20210615100639.51546-1-shijie@os.amperecomputing.com>
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
----------------------------------------------------------------
Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
This patch is just RFC, if it is not proper, we can drop it.
---
sys-utils/lscpu-cputype.c | 1 +
sys-utils/lscpu-dmi.c | 10 ++++++++++
sys-utils/lscpu.c | 2 ++
sys-utils/lscpu.h | 2 ++
4 files changed, 15 insertions(+)
diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c
index d5ca8e1f1..d5f0eb7d6 100644
--- a/sys-utils/lscpu-cputype.c
+++ b/sys-utils/lscpu-cputype.c
@@ -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);
diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c
index d05380891..ef82cf828 100644
--- a/sys-utils/lscpu-dmi.c
+++ b/sys-utils/lscpu-dmi.c
@@ -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;
@@ -116,6 +121,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));
+ sprintf(buf, "%d", di.processor_family);
+ ct->bios_family = xstrdup(buf);
+
free(data);
return 0;
}
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 5a99a9a5b..827e84a6d 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -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)
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 4dc8e0a23..79477b469 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -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;
--
2.30.2
next prev parent reply other threads:[~2021-06-15 2:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 10:06 [PATCH 1/2] lscpu: get the processor information by DMI Huang Shijie
2021-06-15 10:06 ` Huang Shijie [this message]
2021-06-16 9:17 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210615100639.51546-2-shijie@os.amperecomputing.com \
--to=shijie@os.amperecomputing.com \
--cc=ilkka@os.amperecomputing.com \
--cc=jbastian@redhat.com \
--cc=jeremy.linton@arm.com \
--cc=m.mizuma@jp.fujitsu.com \
--cc=mas@amperecomputing.com \
--cc=patches@amperecomputing.com \
--cc=util-linux@vger.kernel.org \
--cc=zwang@amperecomputing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).