Skip to content

Commit ea6be04

Browse files
committed
linux: gather SoC information
Exposed in root info as SoC0ID, SoC1Family, SoC0Revision, etc. Signed-off-by: Brice Goglin <[email protected]>
1 parent 6157a3a commit ea6be04

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

doc/hwloc.doxy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,10 @@ hwloc failed to discover any package.
20392039
models and vendors, the BIOS revision, etc.,
20402040
as reported by Linux under <tt>/sys/class/dmi/id/</tt>.
20412041
</dd>
2042+
<dt>SoC0ID, SoC0Family, SoC1Revision, etc.</dt>
2043+
<dd>The ID, family and revision of the first system-on-chip
2044+
(<tt>SoC0</tt>), second (<tt>SoC1</tt>), etc.
2045+
</dd>
20422046
<dt>MemoryMode, ClusterMode</dt>
20432047
<dd>
20442048
Intel Xeon Phi processor configuration modes.

hwloc/topology-linux.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,54 @@ hwloc__get_dmi_id_info(struct hwloc_linux_backend_data_s *data, hwloc_obj_t obj)
27482748
hwloc__get_dmi_id_one_info(data, obj, path, pathlen, "sys_vendor", "DMISysVendor");
27492749
}
27502750

2751+
static void
2752+
hwloc__get_soc_one_info(struct hwloc_linux_backend_data_s *data,
2753+
hwloc_obj_t obj,
2754+
char *path, int n, const char *info_suffix)
2755+
{
2756+
char soc_line[64];
2757+
char infoname[64];
2758+
2759+
if (hwloc_read_path_by_length(path, soc_line, sizeof(soc_line), data->root_fd) <= 0)
2760+
return;
2761+
2762+
if (soc_line[0] != '\0') {
2763+
char *tmp = strchr(soc_line, '\n');
2764+
if (tmp)
2765+
*tmp = '\0';
2766+
snprintf(infoname, sizeof(infoname), "SoC%d%s", n, info_suffix);
2767+
hwloc_obj_add_info(obj, infoname, soc_line);
2768+
}
2769+
}
2770+
2771+
static void
2772+
hwloc__get_soc_info(struct hwloc_linux_backend_data_s *data, hwloc_obj_t obj)
2773+
{
2774+
char path[128];
2775+
struct dirent *dirent;
2776+
DIR *dir;
2777+
2778+
/* single SoC, add topology info */
2779+
strcpy(path, "/sys/bus/soc/devices");
2780+
dir = hwloc_opendir(path, data->root_fd);
2781+
if (!dir)
2782+
return;
2783+
2784+
while ((dirent = readdir(dir)) != NULL) {
2785+
int i;
2786+
if (sscanf(dirent->d_name, "soc%d", &i) != 1)
2787+
continue;
2788+
2789+
snprintf(path, sizeof(path), "/sys/bus/soc/devices/soc%d/soc_id", i);
2790+
hwloc__get_soc_one_info(data, obj, path, i, "ID");
2791+
snprintf(path, sizeof(path), "/sys/bus/soc/devices/soc%d/family", i);
2792+
hwloc__get_soc_one_info(data, obj, path, i, "Family");
2793+
snprintf(path, sizeof(path), "/sys/bus/soc/devices/soc%d/revision", i);
2794+
hwloc__get_soc_one_info(data, obj, path, i, "Revision");
2795+
}
2796+
closedir(dir);
2797+
}
2798+
27512799

27522800
/***************************************
27532801
* KNL NUMA quirks
@@ -7479,6 +7527,8 @@ hwloc_look_linuxfs(struct hwloc_backend *backend, struct hwloc_disc_status *dsta
74797527
if (data->need_global_infos) {
74807528
hwloc_gather_system_info(topology, data);
74817529
hwloc_linuxfs_check_kernel_cmdline(data);
7530+
/* soc info needed for cpukinds quirks in hwloc_linuxfs_look_cpu() */
7531+
hwloc__get_soc_info(data, topology->levels[0][0]);
74827532
}
74837533

74847534
if (dstatus->phase == HWLOC_DISC_PHASE_CPU) {

0 commit comments

Comments
 (0)