Skip to content

Commit 254f910

Browse files
committed
linux/cxl: merge CXLDevice attributes when interleaved
And add CXLDeviceInterleaveWays Signed-off-by: Brice Goglin <[email protected]>
1 parent 850a706 commit 254f910

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

doc/hwloc.doxy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,8 +2244,12 @@ These info attributes are attached to objects specified in parentheses.
22442244
<dl>
22452245
<dt>CXLDevice (NUMA Nodes or DAX Memory OS devices)</dt>
22462246
<dd>The PCI/CXL bus ID of a device whose CXL Type-3 memory is exposed here.
2247-
There may be multiple instances of this attributes if multiple device memories
2248-
are interleaved.
2247+
If multiple devices are interleaved, their bus IDs are separated by commas,
2248+
and the number of devices in reported in CXLDeviceInterleaveWays.
2249+
</dd>
2250+
<dt>CXLDeviceInterleaveWays (NUMA Nodes or DAX Memory OS devices)</dt>
2251+
<dd>If multiple CXL devices are interleaved, this attribute shows the
2252+
number of devices (and the number of bus IDs in the CXLDevice attributes).
22492253
</dd>
22502254
<dt>DAXDevice (NUMA Nodes)</dt>
22512255
<dd>The name of the Linux DAX device that was used to expose a non-volatile

hwloc/topology-linux.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3708,7 +3708,11 @@ static int
37083708
annotate_cxl_dax(hwloc_obj_t obj, unsigned region, int root_fd)
37093709
{
37103710
char path[300];
3711+
char bdfs[(12+1)*16]; /* 16 interleaved devices max, 12 chars par BDF, comma-separated + ending \0 */
3712+
char *curbdfptr = bdfs;
3713+
unsigned interleave_ways = 0;
37113714
unsigned i;
3715+
*curbdfptr = '\0';
37123716

37133717
for(i=0; ; i++) {
37143718
char decoder[20]; /* "decoderX.Y" */
@@ -3760,8 +3764,27 @@ annotate_cxl_dax(hwloc_obj_t obj, unsigned region, int root_fd)
37603764
}
37613765
*slash = '\0';
37623766
if (pcibdf) {
3763-
hwloc_obj_add_info(obj, "CXLDevice", pcibdf);
3767+
if (interleave_ways) {
3768+
if (interleave_ways >= 16) {
3769+
if (HWLOC_SHOW_CRITICAL_ERRORS())
3770+
fprintf(stderr, "Found more than 16 interleaved devices for region%u, ignoring the last ones.\n", region);
3771+
break;
3772+
}
3773+
*(curbdfptr++) = ',';
3774+
}
3775+
strcpy(curbdfptr, pcibdf);
3776+
curbdfptr += 12;
3777+
interleave_ways++;
3778+
}
3779+
}
3780+
3781+
if (interleave_ways) {
3782+
if (interleave_ways > 1) {
3783+
char tmp[12]; /* interleave ways is 16 max */
3784+
snprintf(tmp, sizeof(tmp), "%u", interleave_ways);
3785+
hwloc_obj_add_info(obj, "CXLDeviceInterleaveWays", tmp);
37643786
}
3787+
hwloc_obj_add_info(obj, "CXLDevice", bdfs);
37653788
}
37663789

37673790
return 0;

0 commit comments

Comments
 (0)