Skip to content

Commit 2fc7c23

Browse files
committed
linux: make sure uname, Backend and other global info attrs are added once
Once and only once when some discovery phases may be disabled. Signed-off-by: Brice Goglin <[email protected]>
1 parent a4e63f2 commit 2fc7c23

22 files changed

+38
-43
lines changed

hwloc/topology-linux.c

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct hwloc_linux_backend_data_s {
6363
struct utsname utsname; /* fields contain \0 when unknown */
6464
int fallback_nbprocessors; /* only used in hwloc_linux_fallback_pu_level(), maybe be <= 0 (error) earlier */
6565
unsigned pagesize;
66+
int need_global_infos;
6667
};
6768

6869

@@ -5768,16 +5769,6 @@ hwloc_linuxfs_look_cpu(struct hwloc_backend *backend, struct hwloc_disc_status *
57685769

57695770
hwloc_alloc_root_sets(topology->levels[0][0]);
57705771

5771-
/*********************************
5772-
* Platform information for later
5773-
*/
5774-
hwloc_gather_system_info(topology, data);
5775-
5776-
/**********************************
5777-
* Detect things in /proc/cmdline
5778-
*/
5779-
hwloc_linuxfs_check_kernel_cmdline(data);
5780-
57815772
/**********************
57825773
* /proc/cpuinfo
57835774
*/
@@ -5862,22 +5853,11 @@ hwloc_linuxfs_look_cpu(struct hwloc_backend *backend, struct hwloc_disc_status *
58625853
} else
58635854
nbnodes = 0;
58645855

5865-
/**********************
5866-
* Misc
5867-
*/
5868-
5869-
/* Gather DMI info */
5870-
hwloc__get_dmi_id_info(data, topology->levels[0][0]);
5871-
5872-
hwloc_obj_add_info(topology->levels[0][0], "Backend", "Linux");
58735856
if (cpuset_name) {
58745857
hwloc_obj_add_info(topology->levels[0][0], "LinuxCgroup", cpuset_name);
58755858
free(cpuset_name);
58765859
}
58775860

5878-
/* data->utsname was filled with real uname or \0, we can safely pass it */
5879-
hwloc_add_uname_info(topology, &data->utsname);
5880-
58815861
hwloc_linux_free_cpuinfo(Lprocs, numprocs, global_infos, global_infos_count);
58825862
return 0;
58835863
}
@@ -7292,14 +7272,20 @@ hwloc_look_linuxfs(struct hwloc_backend *backend, struct hwloc_disc_status *dsta
72927272
* or not (modified fsroot path).
72937273
*/
72947274

7275+
struct hwloc_linux_backend_data_s *data = HWLOC_BACKEND_PRIVATE_DATA(backend);
72957276
struct hwloc_topology *topology = backend->topology;
72967277
#ifdef HWLOC_HAVE_LINUXIO
72977278
enum hwloc_type_filter_e pfilter, bfilter, ofilter, mfilter;
72987279
#endif /* HWLOC_HAVE_LINUXIO */
72997280

7281+
if (data->need_global_infos) {
7282+
hwloc_gather_system_info(topology, data);
7283+
hwloc_linuxfs_check_kernel_cmdline(data);
7284+
}
7285+
73007286
if (dstatus->phase == HWLOC_DISC_PHASE_CPU) {
73017287
hwloc_linuxfs_look_cpu(backend, dstatus);
7302-
return 0;
7288+
goto out;
73037289
}
73047290

73057291
#ifdef HWLOC_HAVE_LINUXIO
@@ -7353,6 +7339,14 @@ hwloc_look_linuxfs(struct hwloc_backend *backend, struct hwloc_disc_status *dsta
73537339
}
73547340
#endif /* HWLOC_HAVE_LINUXIO */
73557341

7342+
out:
7343+
if (data->need_global_infos) {
7344+
hwloc__get_dmi_id_info(data, topology->levels[0][0]);
7345+
hwloc_obj_add_info(topology->levels[0][0], "Backend", "Linux");
7346+
/* data->utsname was filled with real uname or \0, we can safely pass it */
7347+
hwloc_add_uname_info(topology, &data->utsname);
7348+
data->need_global_infos = 0;
7349+
}
73567350
return 0;
73577351
}
73587352

@@ -7405,6 +7399,7 @@ hwloc_linux_component_instantiate(struct hwloc_topology *topology,
74057399
data->is_knl = 0;
74067400
data->is_amd_with_CU = 0;
74077401
data->is_fake_numa_uniform = 0;
7402+
data->need_global_infos = 1;
74087403
data->is_real_fsroot = 1;
74097404
data->root_path = NULL;
74107405
fsroot_path = getenv("HWLOC_FSROOT");

tests/hwloc/linux/128arm-2pa2n8cluster4co.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=503GiB DMIProductName="XA320 V2 " DMIProductVersion="To be filled by O.E.M." DMIProductSerial=2102312MEA10K9000003 DMIProductUUID=76cfcdd4-c8a7-9486-e911-c1d00a756a75 DMIBoardVendor=Huawei DMIBoardName=BC82HPNBB DMIBoardVersion=V200R002C00 DMIBoardSerial=026MGF10K8000012 DMIBoardAssetTag="To be filled by O.E.M." DMIChassisVendor=Huawei DMIChassisType=17 DMIChassisVersion="To be filled by O.E.M." DMIChassisSerial="To be filled by O.E.M." DMIChassisAssetTag="To be filled by O.E.M." DMIBIOSVendor="Huawei Corp." DMIBIOSVersion=0.86 DMIBIOSDate=07/19/2019 DMISysVendor=Huawei Backend=Linux LinuxCgroup=/ OSName=Linux OSRelease=5.15.0-rc1-00005-g4c1b4a4d90b6-dirty OSVersion="#313 SMP PREEMPT Sun Nov 7 14:18:05 EST 2021" HostName=ubuntu Architecture=aarch64)
1+
Machine (P#0 total=503GiB LinuxCgroup=/ DMIProductName="XA320 V2 " DMIProductVersion="To be filled by O.E.M." DMIProductSerial=2102312MEA10K9000003 DMIProductUUID=76cfcdd4-c8a7-9486-e911-c1d00a756a75 DMIBoardVendor=Huawei DMIBoardName=BC82HPNBB DMIBoardVersion=V200R002C00 DMIBoardSerial=026MGF10K8000012 DMIBoardAssetTag="To be filled by O.E.M." DMIChassisVendor=Huawei DMIChassisType=17 DMIChassisVersion="To be filled by O.E.M." DMIChassisSerial="To be filled by O.E.M." DMIChassisAssetTag="To be filled by O.E.M." DMIBIOSVendor="Huawei Corp." DMIBIOSVersion=0.86 DMIBIOSDate=07/19/2019 DMISysVendor=Huawei Backend=Linux OSName=Linux OSRelease=5.15.0-rc1-00005-g4c1b4a4d90b6-dirty OSVersion="#313 SMP PREEMPT Sun Nov 7 14:18:05 EST 2021" HostName=ubuntu Architecture=aarch64)
22
Package L#0 (P#36 total=252GiB)
33
L3Cache L#0 (total=126GiB size=32MiB linesize=128 ways=128)
44
NUMANode L#0 (P#0 local=126GiB total=126GiB)

tests/hwloc/linux/16amd64-4n4c-cgroup-distance-merge.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=16GiB DMIProductName=H8QM8 DMIProductVersion=1234567890 DMIBoardVendor=Supermicro DMIBoardName=H8QM8 DMIBoardVersion=1234567890 DMIBoardAssetTag="To Be Filled By O.E.M." DMIChassisVendor="To Be Filled By O.E.M." DMIChassisType=3 DMIChassisVersion="To Be Filled By O.E.M." DMIChassisAssetTag="To Be Filled By O.E.M." DMIBIOSVendor="American Megatrends Inc." DMIBIOSVersion="080014 " DMIBIOSDate=12/20/2008 DMISysVendor=Supermicro Backend=Linux LinuxCgroup=/prout)
1+
Machine (P#0 total=16GiB LinuxCgroup=/prout DMIProductName=H8QM8 DMIProductVersion=1234567890 DMIBoardVendor=Supermicro DMIBoardName=H8QM8 DMIBoardVersion=1234567890 DMIBoardAssetTag="To Be Filled By O.E.M." DMIChassisVendor="To Be Filled By O.E.M." DMIChassisType=3 DMIChassisVersion="To Be Filled By O.E.M." DMIChassisAssetTag="To Be Filled By O.E.M." DMIBIOSVendor="American Megatrends Inc." DMIBIOSVersion="080014 " DMIBIOSDate=12/20/2008 DMISysVendor=Supermicro Backend=Linux)
22
Package L#0 (P#0 CPUModel="Quad-Core AMD Opteron(tm) Processor 8347 HE")
33
L3Cache L#0 (size=2048KiB linesize=64 ways=32)
44
PU L#0 (P#0)

tests/hwloc/linux/16amd64-8n2c-cpusets-disallowed.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=64GiB DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881 " DMIBoardVersion=S4881 DMIBoardAssetTag= Backend=Linux LinuxCgroup=/dummy)
1+
Machine (P#0 total=64GiB LinuxCgroup=/dummy DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881 " DMIBoardVersion=S4881 DMIBoardAssetTag= Backend=Linux)
22
Package L#0 (P#0 total=8190MiB CPUModel="Dual Core AMD Opteron(tm) Processor 865")
33
NUMANode L#0 (P#0 local=8190MiB total=8190MiB) (disallowed)
44
L2Cache L#0 (size=1024KiB linesize=64 ways=16)

tests/hwloc/linux/16amd64-8n2c-cpusets-xml.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<!DOCTYPE topology SYSTEM "hwloc2.dtd">
33
<topology version="3.0">
44
<object type="Machine" os_index="0" cpuset="0x0000f06f" complete_cpuset="0x0000ffff" allowed_cpuset="0x0000f06f" nodeset="0x0000001e" complete_nodeset="0x000000ff" allowed_nodeset="0x0000001e">
5+
<info name="LinuxCgroup" value="/dummy"/>
56
<info name="DMIBoardVendor" value="TYAN Computer Corp"/>
67
<info name="DMIBoardName" value="S4881 "/>
78
<info name="DMIBoardVersion" value="S4881"/>
89
<info name="DMIBoardAssetTag" value=""/>
910
<info name="Backend" value="Linux"/>
10-
<info name="LinuxCgroup" value="/dummy"/>
1111
<object type="Package" os_index="0" cpuset="0x00000003" complete_cpuset="0x00000003" nodeset="0x0" complete_nodeset="0x00000001">
1212
<info name="CPUModel" value="Dual Core AMD Opteron(tm) Processor 865"/>
1313
<object type="L2Cache" cpuset="0x00000001" complete_cpuset="0x00000001" nodeset="0x0" complete_nodeset="0x00000001" cache_size="1048576" depth="2" cache_linesize="64" cache_associativity="16" cache_type="0">

tests/hwloc/linux/16amd64-8n2c-cpusets.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=32GiB DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881 " DMIBoardVersion=S4881 DMIBoardAssetTag= Backend=Linux LinuxCgroup=/dummy)
1+
Machine (P#0 total=32GiB LinuxCgroup=/dummy DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881 " DMIBoardVersion=S4881 DMIBoardAssetTag= Backend=Linux)
22
Package L#0 (P#0 CPUModel="Dual Core AMD Opteron(tm) Processor 865")
33
L2Cache L#0 (size=1024KiB linesize=64 ways=16)
44
L1dCache L#0 (size=64KiB linesize=64 ways=2)

tests/hwloc/linux/16em64t-4s2ca2c-cpusetreorder-merge.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=16GiB Backend=Linux LinuxCgroup=/prout)
1+
Machine (P#0 total=16GiB LinuxCgroup=/prout Backend=Linux)
22
NUMANode L#0 (P#0 local=16GiB total=16GiB)
33
Package L#0 (P#0 CPUModel="Intel(R) Xeon(TM) CPU 2.60GHz")
44
L2Cache L#0 (size=1024KiB linesize=64 ways=8)

tests/hwloc/linux/16em64t-4s2ca2c-cpusetreorder.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=16GiB Backend=Linux LinuxCgroup=/prout)
1+
Machine (P#0 total=16GiB LinuxCgroup=/prout Backend=Linux)
22
NUMANode L#0 (P#0 local=16GiB total=16GiB)
33
Package L#0 (P#0 CPUModel="Intel(R) Xeon(TM) CPU 2.60GHz")
44
L3Cache L#0 (size=4096KiB linesize=64 ways=16)

tests/hwloc/linux/2pa-pcidomain32bits.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Machine (P#0 total=2004MiB DMIProductName="CloudStack KVM Hypervisor" DMIProductVersion="RHEL 7.0.0 PC (i440FX + PIIX, 1996)" DMIChassisVendor=Bochs DMIChassisType=1 DMIChassisVersion= DMIChassisAssetTag= DMIBIOSVendor=Seabios DMIBIOSVersion=0.5.1 DMIBIOSDate=01/01/2011 DMISysVendor="Apache Software Foundation" Backend=Linux LinuxCgroup=/ OSName=Linux OSRelease=4.9.0-3-amd64 OSVersion="#1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26)" HostName=hwloc-debian9amd64 Architecture=x86_64)
1+
Machine (P#0 total=2004MiB LinuxCgroup=/ DMIProductName="CloudStack KVM Hypervisor" DMIProductVersion="RHEL 7.0.0 PC (i440FX + PIIX, 1996)" DMIChassisVendor=Bochs DMIChassisType=1 DMIChassisVersion= DMIChassisAssetTag= DMIBIOSVendor=Seabios DMIBIOSVersion=0.5.1 DMIBIOSDate=01/01/2011 DMISysVendor="Apache Software Foundation" Backend=Linux OSName=Linux OSRelease=4.9.0-3-amd64 OSVersion="#1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26)" HostName=hwloc-debian9amd64 Architecture=x86_64)
22
NUMANode L#0 (P#0 local=2004MiB total=2004MiB)
33
Package L#0 (P#0 CPUVendor=GenuineIntel CPUFamilyNumber=6 CPUModelNumber=94 CPUModel="Intel Core Processor (Skylake, IBRS)" CPUStepping=3)
44
L2Cache L#0 (size=4096KiB linesize=64 ways=16)

tests/hwloc/linux/32amd64-4s2n4c-cgroup2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<!DOCTYPE topology SYSTEM "hwloc2.dtd">
33
<topology version="3.0">
44
<object type="Machine" os_index="0" cpuset="0x0000003f" complete_cpuset="0xffffffff" allowed_cpuset="0x0000003f" nodeset="0x0000003f" complete_nodeset="0x000000ff" allowed_nodeset="0x0000003f">
5+
<info name="LinuxCgroup" value="/uid_2008/job_15389/step_0"/>
56
<info name="DMIProductName" value="H8QG6"/>
67
<info name="DMIProductVersion" value="1234567890"/>
78
<info name="DMIBoardVendor" value="Supermicro"/>
@@ -17,7 +18,6 @@
1718
<info name="DMIBIOSDate" value="07/26/2011"/>
1819
<info name="DMISysVendor" value="Supermicro"/>
1920
<info name="Backend" value="Linux"/>
20-
<info name="LinuxCgroup" value="/uid_2008/job_15389/step_0"/>
2121
<object type="Package" os_index="0" cpuset="0x0000003f" complete_cpuset="0x000000ff" nodeset="0x00000003" complete_nodeset="0x00000003">
2222
<info name="CPUModel" value="AMD Opteron(tm) Processor 6134"/>
2323
<object type="L3Cache" cpuset="0x0000000f" complete_cpuset="0x0000000f" nodeset="0x00000001" complete_nodeset="0x00000001" cache_size="5240832" depth="3" cache_linesize="64" cache_associativity="48" cache_type="0">

0 commit comments

Comments
 (0)