Skip to content

Commit

Permalink
linux/cxl: merge CXLDevice attributes when interleaved
Browse files Browse the repository at this point in the history
And add CXLDeviceInterleaveWays

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Jul 3, 2023
1 parent 850a706 commit 254f910
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
8 changes: 6 additions & 2 deletions doc/hwloc.doxy
Expand Up @@ -2244,8 +2244,12 @@ These info attributes are attached to objects specified in parentheses.
<dl>
<dt>CXLDevice (NUMA Nodes or DAX Memory OS devices)</dt>
<dd>The PCI/CXL bus ID of a device whose CXL Type-3 memory is exposed here.
There may be multiple instances of this attributes if multiple device memories
are interleaved.
If multiple devices are interleaved, their bus IDs are separated by commas,
and the number of devices in reported in CXLDeviceInterleaveWays.
</dd>
<dt>CXLDeviceInterleaveWays (NUMA Nodes or DAX Memory OS devices)</dt>
<dd>If multiple CXL devices are interleaved, this attribute shows the
number of devices (and the number of bus IDs in the CXLDevice attributes).
</dd>
<dt>DAXDevice (NUMA Nodes)</dt>
<dd>The name of the Linux DAX device that was used to expose a non-volatile
Expand Down
25 changes: 24 additions & 1 deletion hwloc/topology-linux.c
Expand Up @@ -3708,7 +3708,11 @@ static int
annotate_cxl_dax(hwloc_obj_t obj, unsigned region, int root_fd)
{
char path[300];
char bdfs[(12+1)*16]; /* 16 interleaved devices max, 12 chars par BDF, comma-separated + ending \0 */
char *curbdfptr = bdfs;
unsigned interleave_ways = 0;
unsigned i;
*curbdfptr = '\0';

for(i=0; ; i++) {
char decoder[20]; /* "decoderX.Y" */
Expand Down Expand Up @@ -3760,8 +3764,27 @@ annotate_cxl_dax(hwloc_obj_t obj, unsigned region, int root_fd)
}
*slash = '\0';
if (pcibdf) {
hwloc_obj_add_info(obj, "CXLDevice", pcibdf);
if (interleave_ways) {
if (interleave_ways >= 16) {
if (HWLOC_SHOW_CRITICAL_ERRORS())
fprintf(stderr, "Found more than 16 interleaved devices for region%u, ignoring the last ones.\n", region);
break;
}
*(curbdfptr++) = ',';
}
strcpy(curbdfptr, pcibdf);
curbdfptr += 12;
interleave_ways++;
}
}

if (interleave_ways) {
if (interleave_ways > 1) {
char tmp[12]; /* interleave ways is 16 max */
snprintf(tmp, sizeof(tmp), "%u", interleave_ways);
hwloc_obj_add_info(obj, "CXLDeviceInterleaveWays", tmp);
}
hwloc_obj_add_info(obj, "CXLDevice", bdfs);
}

return 0;
Expand Down

0 comments on commit 254f910

Please sign in to comment.