Skip to contentSkip to conversation

cxl/region: Create node access attributes for CFMWS-only NUMA nodes

PATCH Superseded Guixin Liu 6 participants 11 messages Sep 16 – Sep 17 CXL

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/1 cxl/region: Create node access attributes for CFMWS-only NUMA nodes

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
---
 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
 		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
 	}
 }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
 resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
 					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
 #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +4 -1
index 27e63e6dab7c..636435733754 100644
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
 	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
 		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
 			cset++;
 		}
 	}
Signature · 1 line
2.43.7
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] cxl: backwards naming of cxl_need_node_perf_attrs_update() --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] cxl: backwards naming of cxl_need_node_perf_attrs_update()
--

commit b11d76869ff914a767abdc38146d89e156a8de78
Author: Guixin Liu <[email protected]>

cxl/region: Create node access attributes for CFMWS-only NUMA nodes

This patch handles a case where a NUMA node only backs a CXL fixed memory window without being enumerated by SRAT. When such a node is not backed by a real SRAT PXM, it creates the node access attributes using node_set_perf_attrs() rather than just trying to update them.

Quoted 4 lines
drivers/cxl/core/cdat.c +0 -0
index df9261ba84e5a..1ac7ce3a6127e 100644

[ ... ]

drivers/cxl/core/cdat.c void cxl_region_perf_data_calculate(struct cxl_region *cxlr, · line 1079

Quoted 9 lines
drivers/cxl/core/cdat.c +5 -0
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
 		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
 	}
 }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}

[Severity: Low]
Does this function name accurately describe what it checks for? It seems to return true when the node is NOT backed by a real SRAT PXM, which means it needs creation rather than an update.

[ ... ]

Quoted 4 lines
drivers/cxl/core/region.c +0 -0
index 4f6069451fed6..11902e7f6a1c6 100644

[ ... ]

drivers/cxl/core/region.c static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid) · line 2637

Quoted 9 lines
drivers/cxl/core/region.c +4 -1
@@ -2631,7 +2631,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
 	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
 		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);

[Severity: Low]
Is the logic backwards here because of the helper name?

If cxl_need_node_perf_attrs_update() returns true, this calls node_set_perf_attrs() to create the attributes. If it returns false, it calls node_update_perf_attrs() to update them.

This effectively reads as "if we need to update, we set; otherwise we update". Would renaming the helper to something like cxl_need_node_perf_attrs_creation() make this logic clearer?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Guixin Liu
Quoted 76 lines · Guixin Liu

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
---
 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
 		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
 	}
 }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
 resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
 					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
 #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +0 -0
index 27e63e6dab7c..636435733754 100644

drivers/cxl/core/region.c static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid) · line 2633

Quoted 5 lines
drivers/cxl/core/region.c +1 -1
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
 	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
 		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))

Given that it's only used once and it's straight forward enough, just open code it instead of creating a helper.

DJ

Quoted 6 lines
drivers/cxl/core/region.c +3 -0
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
 			cset++;
 		}
 	}
author
#3 lore raw
Quoted 79 lines · Dave Jiang
Quoted 77 lines · Guixin Liu

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

  drivers/cxl/core/cdat.c   | 5 +++++
  drivers/cxl/core/core.h   | 1 +
  drivers/cxl/core/region.c | 5 ++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
---
  drivers/cxl/core/cdat.c   | 5 +++++
  drivers/cxl/core/core.h   | 1 +
  drivers/cxl/core/region.c | 5 ++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
  		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
  	}
  }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
  resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
  					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
  #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +0 -0
index 27e63e6dab7c..636435733754 100644
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
Quoted 7 lines

drivers/cxl/core/region.c static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid) · line 2633

Quoted 4 lines
drivers/cxl/core/region.c +1 -1
  	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
  		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))

Given that it's only used once and it's straight forward enough, just open code it instead of creating a helper.

DJ

OK,  removed in v2, thanks.

Best Regards,
Guixin Liu

Quoted 7 lines
Quoted 7 lines
drivers/cxl/core/region.c +3 -0
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
  			cset++;
  		}
  	}
#4 lore raw
In reply to Guixin Liu
Quoted 2 lines · Guixin Liu

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT

Sigh. This keeps coming up. (Not your issue Guixin Liu)

It would be nice to actually fix this in QEMU rather than make QEMU specific fixes in linux.

On any other platform we would call this a firmware bug.

~Gregory

maintainer
#5 lore raw
Quoted 5 lines · On Wed, 16 Sep 2026 13:59:48 -0400 Gregory Price <[email protected]> wrote:
Quoted 2 lines · Guixin Liu

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT

Sigh. This keeps coming up. (Not your issue Guixin Liu)

I won't reply in depth again. If a platform supports non trivial hotplug (i.e. more than one device spec) then the bios has to be clairvoyant to create those tables in a fashion that is useful. Generic Ports were added to put the missing piece in to solve the problem so there is no longer a need to pre bake.

Quoted 5 lines

It would be nice to actually fix this in QEMU rather than make QEMU specific fixes in linux.

On any other platform we would call this a firmware bug.

You are going to see more 'buggy' platforms as the ones that don't have to comply with the ancient history aren't going to add these fake SRAT entrees.

Personally I'd take the more radical view that if a platform gives us Generic Ports, right answer is throw away any fictional / approximate SRAT entrees, do the discovery ourselves and build representative NUMA nodes for what is actually there.

This is going to be more fun when we have more complex devices showing up and need to create a NUMA node per device (i.e. those nice compression devices of yours). At that point you aren't using SRAT memory proximity nodes anyway - unless they are all there at boot and you are spinning a PXM for each one. How do you do if a mix of different sized (or at least sizes you didn't know at boot) devices get hotplugged later?

Jonathan

Quoted 2 lines

~Gregory

#6 lore raw
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Wed, 16 Sep 2026 13:59:48 -0400 Gregory Price <[email protected]> wrote:
Quoted 2 lines · Guixin Liu

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT

Quoted 8 lines
Quoted 1 line

Sigh. This keeps coming up. (Not your issue Guixin Liu)

I won't reply in depth again. If a platform supports non trivial hotplug (i.e. more than one device spec) then the bios has to be clairvoyant to create those tables in a fashion that is useful. Generic Ports were added to put the missing piece in to solve the problem so there is no longer a need to pre bake.

Well sure, but [SRAT, Generic Ports] - pick one.

But giving nothing is just a wart :|

Quoted 6 lines

This is going to be more fun when we have more complex devices showing up and need to create a NUMA node per device (i.e. those nice compression devices of yours). At that point you aren't using SRAT memory proximity nodes anyway - unless they are all there at boot and you are spinning a PXM for each one. How do you do if a mix of different sized (or at least sizes you didn't know at boot) devices get hotplugged later?

cough

https://lore.kernel.org/linux-mm/[email protected]/

maintainer Reviewed-by on v1 1/1
#7 lore raw
In reply to Guixin Liu
Quoted 24 lines · On Wed, 16 Sep 2026 20:03:38 +0800 Guixin Liu <[email protected]> wrote:

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Quoted 8 lines

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

Ah. I should have caught this one. Indeed looks correct.

My only concern is it is relying heavily on the fact we only do this once which is not apparent at this layer in the code. You need to go looking in cxl_region_perf_attrs_callback() for that.

It is also a one way gate so even you tear down all regions in the NUMA node (so the CFWMS) we don't do this update again.

Anyhow, I think all we need here is a note that this function will only be called once per CFWMS and thus it is fine to register the sysfs attrs here.

With that added, this looks good to me

Quoted 55 lines

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
---
 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
 		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
 	}
 }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
 resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
 					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
 #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +4 -1
index 27e63e6dab7c..636435733754 100644
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
 	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
 		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
 			cset++;
 		}
 	}
author
#8 lore raw
Quoted 41 lines · Jonathan Cameron
Quoted 24 lines · On Wed, 16 Sep 2026 20:03:38 +0800 Guixin Liu <[email protected]> wrote:

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Quoted 8 lines

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

Ah. I should have caught this one. Indeed looks correct.

My only concern is it is relying heavily on the fact we only do this once which is not apparent at this layer in the code. You need to go looking in cxl_region_perf_attrs_callback() for that.

Quoted 6 lines

It is also a one way gate so even you tear down all regions in the NUMA node (so the CFWMS) we don't do this update again.

Anyhow, I think all we need here is a note that this function will only be called once per CFWMS and thus it is fine to register the sysfs attrs here.

OK, added in v2, thanks.

Best Regards,
Guixin Liu

Quoted 60 lines

With that added, this looks good to me

Quoted 55 lines

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

  drivers/cxl/core/cdat.c   | 5 +++++
  drivers/cxl/core/core.h   | 1 +
  drivers/cxl/core/region.c | 5 ++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
---
  drivers/cxl/core/cdat.c   | 5 +++++
  drivers/cxl/core/core.h   | 1 +
  drivers/cxl/core/region.c | 5 ++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
  		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
  	}
  }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
  resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
  					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
  #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +4 -1
index 27e63e6dab7c..636435733754 100644
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
  	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
  		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
  			cset++;
  		}
  	}
maintainer
#9 lore raw
In reply to Guixin Liu
Quoted 24 lines · Guixin Liu

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Quoted 5 lines

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

The detailed analysis establishes that this is a regression in the existing CFMWS-only NUMA node support, but I think that gets a little lost in the forensics.

Could you make that more explicit up front? In particular, the user-visible impact is that a NUMA node which the kernel already supports creating from CFMWS no longer gets its accessN attributes.

Gregory's point about whether QEMU should also provide SRAT is a separate issue, like he notes. The kernel already supports the CFMWS-only path, so I think we should continue to handle it correctly.

-- Alison

Quoted 61 lines
Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
---
 drivers/cxl/core/cdat.c   | 5 +++++
 drivers/cxl/core/core.h   | 1 +
 drivers/cxl/core/region.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
 		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
 	}
 }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
 resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
 					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
 #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +4 -1
index 27e63e6dab7c..636435733754 100644
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
 	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
 		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
 			cset++;
 		}
 	}
Signature · 1 line
2.43.7
author
#10 lore raw
Quoted 31 lines · Alison Schofield
Quoted 24 lines · Guixin Liu

A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code. When the first memory of such a node comes online, hmat_callback() exits early at find_mem_target() without creating anything, and node_update_perf_attrs() only updates attributes that already exist, so the node never gets its accessN sysfs attributes at all:
/sys/devices/system/node/nodeX/accessN/initiators/* stays missing even though the region's own sysfs reports the coordinates.

Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") handled this by having the CXL region notifier call node_set_perf_attrs() directly for such nodes, but

commit 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

replaced that call with node_update_perf_attrs() on the assumption that the HMAT callback has already created the attributes. That assumption does not hold for CFMWS-only nodes.

Restore the distinction: when the node is not backed by a real SRAT pxm, create the attributes with node_set_perf_attrs() instead of only trying to update them.

Quoted 5 lines

Tested on a QEMU CXL topology with a CFMWS window whose memory is not described by SRAT or HMAT: after the region's first memory block comes online, node1 has no accessN directory before this patch; with it, node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates.

Quoted 7 lines

The detailed analysis establishes that this is a regression in the existing CFMWS-only NUMA node support, but I think that gets a little lost in the forensics.

Could you make that more explicit up front? In particular, the user-visible impact is that a NUMA node which the kernel already supports creating from CFMWS no longer gets its accessN attributes.

Yes, it's better, will be changed in v2, thanks.

Best Regards,
Guixin Liu

Quoted 67 lines

Gregory's point about whether QEMU should also provide SRAT is a separate issue, like he notes. The kernel already supports the CFMWS-only path, so I think we should continue to handle it correctly.

-- Alison

Quoted 60 lines
Fixes 2e454fb8056d ("cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT")

---
checkpatch reports one "Prefer a maximum 75 chars per line" warning:
the 2e454fb8056d reference line above is 84 columns because checkpatch requires the quoted title to match the git subject exactly, and that subject is 62 characters long. Wrapping it instead produces a GIT_COMMIT_ID error, so the long line is the lesser evil.

  drivers/cxl/core/cdat.c   | 5 +++++
  drivers/cxl/core/core.h   | 1 +
  drivers/cxl/core/region.c | 5 ++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
---
  drivers/cxl/core/cdat.c   | 5 +++++
  drivers/cxl/core/core.h   | 1 +
  drivers/cxl/core/region.c | 5 ++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
drivers/cxl/core/cdat.c +5 -0
index 5c9f07262513..e28c40159d94 100644
@@ -1072,3 +1072,8 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
  		cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
  	}
  }
+
+bool cxl_need_node_perf_attrs_update(int nid)
+{
+	return !acpi_node_backed_by_real_pxm(nid);
+}
drivers/cxl/core/core.h +1 -0
index 35eaf636adc9..19a5b8edbfda 100644
@@ -229,4 +229,5 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 
  resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
  					   struct cxl_dport *dport);
+bool cxl_need_node_perf_attrs_update(int nid);
  #endif /* __CXL_CORE_H__ */
drivers/cxl/core/region.c +4 -1
index 27e63e6dab7c..636435733754 100644
@@ -2630,7 +2630,10 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
 
  	for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
  		if (cxlr->coord[i].read_bandwidth) {
-			node_update_perf_attrs(nid, &cxlr->coord[i], i);
+			if (cxl_need_node_perf_attrs_update(nid))
+				node_set_perf_attrs(nid, &cxlr->coord[i], i);
+			else
+				node_update_perf_attrs(nid, &cxlr->coord[i], i);
  			cset++;
  		}
  	}
Signature · 1 line
2.43.7