|
|
df3f53 |
From 32c4fe66ae9107a7fae556be02c1401e5046071b Mon Sep 17 00:00:00 2001
|
|
|
df3f53 |
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
|
|
|
df3f53 |
Date: Fri, 11 Sep 2020 09:53:27 -0400
|
|
|
df3f53 |
Subject: [PATCH 53/55] lscpu: add helper to get physical sockets
|
|
|
df3f53 |
|
|
|
df3f53 |
Add a helper function, get_number_of_physical_sockets_from_dmi(),
|
|
|
df3f53 |
to get physical sockets from DMI table in case of the sysfs for
|
|
|
df3f53 |
cpu topology doesn't have the physical socket information.
|
|
|
df3f53 |
|
|
|
df3f53 |
get_number_of_physical_sockets_from_dmi() parse the DMI table
|
|
|
df3f53 |
and counts the number of SMBIOS Processor Information (Type04)
|
|
|
df3f53 |
structure.
|
|
|
df3f53 |
|
|
|
df3f53 |
Note, ARM SBBR v1.0 and newer requires SMBIOS Processor Information
|
|
|
df3f53 |
(Type04). And ARM SBBR v1.2 requires ACPI PPTT which has physical socket
|
|
|
df3f53 |
information. So the helper function is useful for the machine base on
|
|
|
df3f53 |
SBBR v1.0 and v1.1.
|
|
|
df3f53 |
|
|
|
df3f53 |
Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
|
|
|
df3f53 |
---
|
|
|
df3f53 |
sys-utils/lscpu-dmi.c | 30 ++++++++++++++++++++++++++++++
|
|
|
df3f53 |
sys-utils/lscpu.h | 1 +
|
|
|
df3f53 |
2 files changed, 31 insertions(+)
|
|
|
df3f53 |
|
|
|
df3f53 |
diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c
|
|
|
df3f53 |
index 9b57fe9e6..31127f48a 100644
|
|
|
df3f53 |
--- a/sys-utils/lscpu-dmi.c
|
|
|
df3f53 |
+++ b/sys-utils/lscpu-dmi.c
|
|
|
df3f53 |
@@ -46,6 +46,7 @@ struct dmi_info {
|
|
|
df3f53 |
char *vendor;
|
|
|
df3f53 |
char *product;
|
|
|
df3f53 |
char *manufacturer;
|
|
|
df3f53 |
+ int sockets;
|
|
|
df3f53 |
};
|
|
|
df3f53 |
|
|
|
df3f53 |
static int checksum(const uint8_t *buf, size_t len)
|
|
|
df3f53 |
@@ -147,6 +148,9 @@ static int parse_dmi_table(uint16_t len, uint16_t num,
|
|
|
df3f53 |
di->manufacturer = dmi_string(&h, data[0x04]);
|
|
|
df3f53 |
di->product = dmi_string(&h, data[0x05]);
|
|
|
df3f53 |
break;
|
|
|
df3f53 |
+ case 4:
|
|
|
df3f53 |
+ di->sockets++;
|
|
|
df3f53 |
+ break;
|
|
|
df3f53 |
default:
|
|
|
df3f53 |
break;
|
|
|
df3f53 |
}
|
|
|
df3f53 |
@@ -323,3 +327,29 @@ done:
|
|
|
df3f53 |
free(buf);
|
|
|
df3f53 |
return rc < 0 ? HYPER_NONE : rc;
|
|
|
df3f53 |
}
|
|
|
df3f53 |
+
|
|
|
df3f53 |
+int get_number_of_physical_sockets_from_dmi(void)
|
|
|
df3f53 |
+{
|
|
|
df3f53 |
+ static char const sys_fw_dmi_tables[] = _PATH_SYS_DMI;
|
|
|
df3f53 |
+ struct dmi_info di;
|
|
|
df3f53 |
+ struct stat st;
|
|
|
df3f53 |
+ uint8_t *data;
|
|
|
df3f53 |
+ int rc = -1;
|
|
|
df3f53 |
+
|
|
|
df3f53 |
+ if (stat(sys_fw_dmi_tables, &st))
|
|
|
df3f53 |
+ return rc;
|
|
|
df3f53 |
+
|
|
|
df3f53 |
+ data = get_mem_chunk(0, st.st_size, sys_fw_dmi_tables);
|
|
|
df3f53 |
+ if (!data)
|
|
|
df3f53 |
+ return rc;
|
|
|
df3f53 |
+
|
|
|
df3f53 |
+ memset(&di, 0, sizeof(struct dmi_info));
|
|
|
df3f53 |
+ rc = parse_dmi_table(st.st_size, st.st_size/4, data, &di);
|
|
|
df3f53 |
+
|
|
|
df3f53 |
+ free(data);
|
|
|
df3f53 |
+
|
|
|
df3f53 |
+ if ((rc < 0) || !di.sockets)
|
|
|
df3f53 |
+ return rc;
|
|
|
df3f53 |
+ else
|
|
|
df3f53 |
+ return di.sockets;
|
|
|
df3f53 |
+}
|
|
|
df3f53 |
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
|
|
|
df3f53 |
index bffa9df60..b190afd21 100644
|
|
|
df3f53 |
--- a/sys-utils/lscpu.h
|
|
|
df3f53 |
+++ b/sys-utils/lscpu.h
|
|
|
df3f53 |
@@ -186,6 +186,7 @@ struct lscpu_modifier {
|
|
|
df3f53 |
};
|
|
|
df3f53 |
|
|
|
df3f53 |
extern int read_hypervisor_dmi(void);
|
|
|
df3f53 |
+extern int get_number_of_physical_sockets_from_dmi(void);
|
|
|
df3f53 |
extern void arm_cpu_decode(struct lscpu_desc *desc);
|
|
|
df3f53 |
|
|
|
df3f53 |
#endif /* LSCPU_H */
|
|
|
df3f53 |
--
|
|
|
df3f53 |
2.29.2
|
|
|
df3f53 |
|