[PATCH] ACPI: NUMA: Only parse CFMWS at boot when CXL_ACPI is on

From: Kai Huang

Date: Wed Mar 04 2026 - 16:34:28 EST


On CXL platforms, the Static Resource Affinity Table (SRAT) may not
cover memory affinity information for all the CXL memory regions. Since
each CXL memory region is enumerated via a CXL Fixed Memory Window
Structure (CFMWS), during early boot the kernel parses the CFMWS tables
to find all CXL memory regions and sets a NUMA node for each of them.
This memory affinity information of CXL memory regions is later used by
the CXL ACPI driver.

The CFMWS table doesn't provide the memory affinity information either.
Currently the kernel assigns a 'faked' NUMA node for each CXL memory
region, starting from the next node of the highest node that is
enumerated via the SRAT. This can potentially increase the maximum NUMA
node ID of the platform ('nr_node_ids') a lot. E.g., on a GNR platform
with 4 NUMA nodes and 18 CFMWS tables, this bumps the 'nr_node_ids' to
22.

Increasing the 'nr_node_ids' has side effects. For instance, it is
widely used by the kernel for "highest possible NUMA node" based memory
allocations. It also impacts userspace ABIs, e.g., some NUMA memory
related system calls such as 'get_mempolicy' which requires 'maxnode'
not being smaller than the 'nr_node_ids'.

Currently parsing CFMWS tables and assigning faked NUMA node at boot is
done unconditionally. However, if the CXL ACPI driver is not enabled,
there will be no user of such memory affinity information of CXL memory
regions.

Change to only parsing the CFMWS tables at boot when CXL_ACPI is enabled
in Kconfig to avoid the unnecessary cost of bumping up 'nr_node_ids'.

E.g., on the aforementioned GNR platform, the "Slab" in /proc/meminfo is
reduced with this change (when CXL_ACPI is off):

w/ this change w/o

Slab 900488 kB 923660 kB

Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx>
---
drivers/acpi/numa/srat.c | 45 +++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index aa87ee1583a4..c008fe1f15f7 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -425,6 +425,7 @@ acpi_parse_memory_affinity(union acpi_subtable_headers *header,
return 0;
}

+#if IS_ENABLED(CONFIG_CXL_ACPI)
static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
void *arg, const unsigned long table_end)
{
@@ -476,6 +477,31 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
return 0;
}

+static void __init acpi_numa_init_cxl(void)
+{
+ int i, fake_pxm;
+
+ /*
+ * CXL Fixed Memory Window Structures (CFMWS) must be parsed
+ * after the SRAT. Create NUMA Nodes for CXL memory ranges that
+ * are defined in the CFMWS and not already defined in the SRAT.
+ * Initialize a fake_pxm as the first available PXM to emulate.
+ */
+
+ /* fake_pxm is the next unused PXM value after SRAT parsing */
+ for (i = 0, fake_pxm = -1; i < MAX_NUMNODES; i++) {
+ if (node_to_pxm_map[i] > fake_pxm)
+ fake_pxm = node_to_pxm_map[i];
+ }
+ last_real_pxm = fake_pxm;
+ fake_pxm++;
+ acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, acpi_parse_cfmws,
+ &fake_pxm);
+}
+#else
+static void __init acpi_numa_init_cxl(void) {}
+#endif
+
void __init __weak
acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
{
@@ -602,7 +628,7 @@ acpi_table_parse_srat(enum acpi_srat_type id,

int __init acpi_numa_init(void)
{
- int i, fake_pxm, cnt = 0;
+ int cnt = 0;

if (acpi_disabled)
return -EINVAL;
@@ -640,22 +666,7 @@ int __init acpi_numa_init(void)
/* SLIT: System Locality Information Table */
acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);

- /*
- * CXL Fixed Memory Window Structures (CFMWS) must be parsed
- * after the SRAT. Create NUMA Nodes for CXL memory ranges that
- * are defined in the CFMWS and not already defined in the SRAT.
- * Initialize a fake_pxm as the first available PXM to emulate.
- */
-
- /* fake_pxm is the next unused PXM value after SRAT parsing */
- for (i = 0, fake_pxm = -1; i < MAX_NUMNODES; i++) {
- if (node_to_pxm_map[i] > fake_pxm)
- fake_pxm = node_to_pxm_map[i];
- }
- last_real_pxm = fake_pxm;
- fake_pxm++;
- acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, acpi_parse_cfmws,
- &fake_pxm);
+ acpi_numa_init_cxl();

if (cnt < 0)
return cnt;

base-commit: af4e9ef3d78420feb8fe58cd9a1ab80c501b3c08
--
2.53.0