* [PATCH v3 0/5] SRAT/CEDT fixes and updates
@ 2024-04-19 14:01 Robert Richter
2024-04-19 14:01 ` [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() Robert Richter
` (4 more replies)
0 siblings, 5 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-19 14:01 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter
Some fixes and updates for SRAT/CEDT parsing code. Patches can be
applied individually and are independent.
First patch fixes a page fault during boot. It should be marked stable.
2nd patch adds diagnostic printouts for CEDT.
Patches 3 to 5 remove architectural code no longer needed.
Changelog:
v3:
* Rebased onto v6.9-rc1
* Fixing x86 build error in sparsemem.h [Dan/Alison]
* Added CEDT node info [Alison]
* Use pr_debug() for table output [Dan]
* Refactoring split in 3 patches [Dan]
* Fixed performance regression introduced [kbot]
* Fixed checkpatch issues [Dan]
Bases on v6.9-rc1.
Robert Richter (5):
x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
ACPI/NUMA: Print CXL Early Discovery Table (CEDT)
ACPI/NUMA: Remove architecture dependent remainings
ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit()
ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into
acpi_parse_memory_affinity()
arch/x86/include/asm/sparsemem.h | 2 +-
arch/x86/mm/numa.c | 4 +-
drivers/acpi/numa/srat.c | 198 +++++++++++++++++++++++--------
include/linux/acpi.h | 5 -
4 files changed, 150 insertions(+), 59 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
2024-04-19 14:01 [PATCH v3 0/5] SRAT/CEDT fixes and updates Robert Richter
@ 2024-04-19 14:01 ` Robert Richter
2024-04-22 20:47 ` Alison Schofield
2024-04-23 2:20 ` Dan Williams
2024-04-19 14:02 ` [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Robert Richter
` (3 subsequent siblings)
4 siblings, 2 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-19 14:01 UTC (permalink / raw)
To: Rafael J. Wysocki, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, Andy Lutomirski, Peter Zijlstra, Dan Williams,
Alison Schofield
Cc: linux-acpi, linux-kernel, linux-cxl, Robert Richter, Derick Marks,
H. Peter Anvin
For configurations that have the kconfig option NUMA_KEEP_MEMINFO
disabled, the SRAT lookup done with numa_fill_memblks() fails
returning NUMA_NO_MEMBLK (-1). An existing SRAT memory range cannot be
found for a CFMWS address range. This causes the addition of a
duplicate numa_memblk with a different node id and a subsequent page
fault and kernel crash during boot.
numa_fill_memblks() is implemented and used in the init section only.
The option NUMA_KEEP_MEMINFO is only for the case when NUMA data will
be used outside of init. So fix the SRAT lookup by moving
numa_fill_memblks() out of the NUMA_KEEP_MEMINFO block to make it
always available in the init section.
Note that the issue was initially introduced with [1]. But since
phys_to_target_node() was originally used that returned the valid node
0, an additional numa_memblk was not added. Though, the node id was
wrong too.
[1] commit fd49f99c1809 ("ACPI: NUMA: Add a node and memblk for each
CFMWS not in SRAT")
Fixes: 8f1004679987 ("ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window")
Cc: Derick Marks <derick.w.marks@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
---
arch/x86/include/asm/sparsemem.h | 2 +-
arch/x86/mm/numa.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/sparsemem.h b/arch/x86/include/asm/sparsemem.h
index 1be13b2dfe8b..1aaa447ef24b 100644
--- a/arch/x86/include/asm/sparsemem.h
+++ b/arch/x86/include/asm/sparsemem.h
@@ -37,9 +37,9 @@ extern int phys_to_target_node(phys_addr_t start);
#define phys_to_target_node phys_to_target_node
extern int memory_add_physaddr_to_nid(u64 start);
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
+#endif
extern int numa_fill_memblks(u64 start, u64 end);
#define numa_fill_memblks numa_fill_memblks
-#endif
#endif /* __ASSEMBLY__ */
#endif /* _ASM_X86_SPARSEMEM_H */
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 65e9a6e391c0..ce84ba86e69e 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -929,6 +929,8 @@ int memory_add_physaddr_to_nid(u64 start)
}
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
+#endif
+
static int __init cmp_memblk(const void *a, const void *b)
{
const struct numa_memblk *ma = *(const struct numa_memblk **)a;
@@ -1001,5 +1003,3 @@ int __init numa_fill_memblks(u64 start, u64 end)
}
return 0;
}
-
-#endif
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT)
2024-04-19 14:01 [PATCH v3 0/5] SRAT/CEDT fixes and updates Robert Richter
2024-04-19 14:01 ` [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() Robert Richter
@ 2024-04-19 14:02 ` Robert Richter
2024-04-22 16:43 ` Jonathan Cameron
` (2 more replies)
2024-04-19 14:02 ` [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings Robert Richter
` (2 subsequent siblings)
4 siblings, 3 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-19 14:02 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
The CEDT contains similar entries as the SRAT. For diagnostic reasons
print the CEDT same style as the SRAT.
Adding also a pr_info() when successfully adding a CFMWS memory range.
Suggested-by: Alison Schofield <alison.schofield@intel.com> # CEDT node info
Signed-off-by: Robert Richter <rrichter@amd.com>
---
drivers/acpi/numa/srat.c | 122 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 121 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index e45e64993c50..43417b4920da 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -300,6 +300,114 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
return -EINVAL;
}
+static int __init
+__acpi_table_print_cedt_entry(union acpi_subtable_headers *__header,
+ void *arg, const unsigned long table_end)
+{
+ struct acpi_cedt_header *header = (struct acpi_cedt_header *)__header;
+
+ switch (header->type) {
+ case ACPI_CEDT_TYPE_CHBS:
+ {
+ struct acpi_cedt_chbs *p =
+ (struct acpi_cedt_chbs *)header;
+
+ if (header->length < sizeof(struct acpi_cedt_chbs)) {
+ pr_warn("CEDT: unsupported CHBS entry: size %d\n",
+ header->length);
+ break;
+ }
+
+ pr_debug("CEDT: CHBS (0x%llx length 0x%llx uid %lu) %s (%d)\n",
+ (unsigned long long)p->base,
+ (unsigned long long)p->length,
+ (unsigned long)p->uid,
+ (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) ?
+ "cxl11" :
+ (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL20) ?
+ "cxl20" :
+ "unsupported version",
+ p->cxl_version);
+ }
+ break;
+ case ACPI_CEDT_TYPE_CFMWS:
+ {
+ struct acpi_cedt_cfmws *p =
+ (struct acpi_cedt_cfmws *)header;
+ int eiw_to_ways[] = {1, 2, 4, 8, 16, 3, 6, 12};
+ int targets = -1;
+
+ if (header->length < sizeof(struct acpi_cedt_cfmws)) {
+ pr_warn("CEDT: unsupported CFMWS entry: size %d\n",
+ header->length);
+ break;
+ }
+
+ if (p->interleave_ways < ARRAY_SIZE(eiw_to_ways))
+ targets = eiw_to_ways[p->interleave_ways];
+ if (header->length < struct_size(
+ p, interleave_targets, targets))
+ targets = -1;
+
+ pr_debug("CEDT: CFMWS (0x%llx length 0x%llx) with %d target%s",
+ (unsigned long long)p->base_hpa,
+ (unsigned long long)p->window_size,
+ targets, targets > 1 ? "s" : "");
+ for (int i = 0; i < targets; i++)
+ pr_cont("%s%lu", i ? ", " : " (",
+ (unsigned long)p->interleave_targets[i]);
+ pr_cont("%s%s%s%s%s%s\n",
+ targets > 0 ? ")" : "",
+ (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE2) ?
+ " type2" : "",
+ (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE3) ?
+ " type3" : "",
+ (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_VOLATILE) ?
+ " volatile" : "",
+ (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_PMEM) ?
+ " pmem" : "",
+ (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_FIXED) ?
+ " fixed" : "");
+ }
+ break;
+ case ACPI_CEDT_TYPE_CXIMS:
+ {
+ struct acpi_cedt_cxims *p =
+ (struct acpi_cedt_cxims *)header;
+
+ if (header->length < sizeof(struct acpi_cedt_cxims)) {
+ pr_warn("CEDT: unsupported CXIMS entry: size %d\n",
+ header->length);
+ break;
+ }
+
+ pr_debug("CEDT: CXIMS (hbig %u nr_xormaps %u)\n",
+ (unsigned int)p->hbig,
+ (unsigned int)p->nr_xormaps);
+ }
+ break;
+ default:
+ pr_warn("CEDT: Found unsupported entry (type = 0x%x)\n",
+ header->type);
+ break;
+ }
+
+ return 0;
+}
+
+static void __init acpi_table_print_cedt_entry(enum acpi_cedt_type id)
+{
+ acpi_table_parse_cedt(id, __acpi_table_print_cedt_entry, NULL);
+}
+
+static void __init acpi_table_print_cedt(void)
+{
+ /* Print only implemented CEDT types */
+ acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CHBS);
+ acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CFMWS);
+ acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CXIMS);
+}
+
static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
void *arg, const unsigned long table_end)
{
@@ -318,8 +426,11 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
* found for any portion of the window to cover the entire
* window.
*/
- if (!numa_fill_memblks(start, end))
+ if (!numa_fill_memblks(start, end)) {
+ pr_info("CEDT: memblk extended [mem %#010Lx-%#010Lx]\n",
+ (unsigned long long) start, (unsigned long long) end - 1);
return 0;
+ }
/* No SRAT description. Create a new node. */
node = acpi_map_pxm_to_node(*fake_pxm);
@@ -334,13 +445,19 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
pr_warn("ACPI NUMA: Failed to add memblk for CFMWS node %d [mem %#llx-%#llx]\n",
node, start, end);
}
+
node_set(node, numa_nodes_parsed);
+ pr_info("CEDT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
+ node, *fake_pxm,
+ (unsigned long long) start, (unsigned long long) end - 1);
+
/* Set the next available fake_pxm value */
(*fake_pxm)++;
return 0;
}
#else
+static inline void acpi_table_print_cedt(void) {}
static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
void *arg, const unsigned long table_end)
{
@@ -526,6 +643,9 @@ int __init acpi_numa_init(void)
/* SLIT: System Locality Information Table */
acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
+ /* CEDT: CXL Early Discovery Table */
+ acpi_table_print_cedt();
+
/*
* CXL Fixed Memory Window Structures (CFMWS) must be parsed
* after the SRAT. Create NUMA Nodes for CXL memory ranges that
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings
2024-04-19 14:01 [PATCH v3 0/5] SRAT/CEDT fixes and updates Robert Richter
2024-04-19 14:01 ` [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() Robert Richter
2024-04-19 14:02 ` [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Robert Richter
@ 2024-04-19 14:02 ` Robert Richter
2024-04-22 16:48 ` Jonathan Cameron
` (2 more replies)
2024-04-19 14:02 ` [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit() Robert Richter
2024-04-19 14:02 ` [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity() Robert Richter
4 siblings, 3 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-19 14:02 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
With the removal of the Itanium architecture [1] the last architecture
dependent functions:
acpi_numa_slit_init(), acpi_numa_memory_affinity_init()
were removed. Remove its remainings in the header files too an make
them static.
[1] commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture")
Signed-off-by: Robert Richter <rrichter@amd.com>
---
drivers/acpi/numa/srat.c | 17 ++---------------
include/linux/acpi.h | 5 -----
2 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 43417b4920da..bd0e2d342ba2 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -208,13 +208,12 @@ int __init srat_disabled(void)
return acpi_numa < 0;
}
-#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
/*
* Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for
* I/O localities since SRAT does not list them. I/O localities are
* not supported at this point.
*/
-void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
+static void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
{
int i, j;
@@ -236,11 +235,7 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
}
}
-/*
- * Default callback for parsing of the Proximity Domain <-> Memory
- * Area mappings
- */
-int __init
+static int __init
acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
{
u64 start, end;
@@ -456,14 +451,6 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
(*fake_pxm)++;
return 0;
}
-#else
-static inline void acpi_table_print_cedt(void) {}
-static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
- void *arg, const unsigned long table_end)
-{
- return 0;
-}
-#endif /* defined(CONFIG_X86) || defined (CONFIG_ARM64) */
static int __init acpi_parse_slit(struct acpi_table_header *table)
{
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 34829f2c517a..2c227b61a452 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -242,9 +242,6 @@ static inline bool acpi_gicc_is_usable(struct acpi_madt_generic_interrupt *gicc)
return gicc->flags & ACPI_MADT_ENABLED;
}
-/* the following numa functions are architecture-dependent */
-void acpi_numa_slit_init (struct acpi_table_slit *slit);
-
#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH)
void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
#else
@@ -267,8 +264,6 @@ static inline void
acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { }
#endif
-int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
-
#ifndef PHYS_CPUID_INVALID
typedef u32 phys_cpuid_t;
#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit()
2024-04-19 14:01 [PATCH v3 0/5] SRAT/CEDT fixes and updates Robert Richter
` (2 preceding siblings ...)
2024-04-19 14:02 ` [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings Robert Richter
@ 2024-04-19 14:02 ` Robert Richter
2024-04-22 16:49 ` Jonathan Cameron
2024-04-23 20:03 ` Dan Williams
2024-04-19 14:02 ` [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity() Robert Richter
4 siblings, 2 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-19 14:02 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
After removing architectural code the helper function
acpi_numa_slit_init() is no longer needed. Squash it into
acpi_parse_slit(). No functional changes intended.
Signed-off-by: Robert Richter <rrichter@amd.com>
---
drivers/acpi/numa/srat.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index bd0e2d342ba2..37a0f4b3d24a 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -213,10 +213,16 @@ int __init srat_disabled(void)
* I/O localities since SRAT does not list them. I/O localities are
* not supported at this point.
*/
-static void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
+static int __init acpi_parse_slit(struct acpi_table_header *table)
{
+ struct acpi_table_slit *slit = (struct acpi_table_slit *)table;
int i, j;
+ if (!slit_valid(slit)) {
+ pr_info("SLIT table looks invalid. Not used.\n");
+ return -EINVAL;
+ }
+
for (i = 0; i < slit->locality_count; i++) {
const int from_node = pxm_to_node(i);
@@ -233,6 +239,8 @@ static void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
slit->entry[slit->locality_count * i + j]);
}
}
+
+ return 0;
}
static int __init
@@ -452,19 +460,6 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
return 0;
}
-static int __init acpi_parse_slit(struct acpi_table_header *table)
-{
- struct acpi_table_slit *slit = (struct acpi_table_slit *)table;
-
- if (!slit_valid(slit)) {
- pr_info("SLIT table looks invalid. Not used.\n");
- return -EINVAL;
- }
- acpi_numa_slit_init(slit);
-
- return 0;
-}
-
void __init __weak
acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
{
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity()
2024-04-19 14:01 [PATCH v3 0/5] SRAT/CEDT fixes and updates Robert Richter
` (3 preceding siblings ...)
2024-04-19 14:02 ` [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit() Robert Richter
@ 2024-04-19 14:02 ` Robert Richter
2024-04-22 16:54 ` Jonathan Cameron
2024-04-23 2:29 ` Dan Williams
4 siblings, 2 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-19 14:02 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, kernel test robot,
Len Brown
After removing architectural code the helper function
acpi_numa_memory_affinity_init() is no longer needed. Squash it into
acpi_parse_memory_affinity(). No functional changes intended.
While at it, fixing checkpatch complaints in code moved.
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202403220943.96dde419-oliver.sang@intel.com
Signed-off-by: Robert Richter <rrichter@amd.com>
---
drivers/acpi/numa/srat.c | 40 +++++++++++++++++-----------------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 37a0f4b3d24a..cfa1cbe4a1f5 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -243,22 +243,30 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
return 0;
}
+static int parsed_numa_memblks __initdata;
+
static int __init
-acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
+acpi_parse_memory_affinity(union acpi_subtable_headers *header,
+ const unsigned long table_end)
{
+ struct acpi_srat_mem_affinity *ma;
u64 start, end;
u32 hotpluggable;
int node, pxm;
+ ma = (struct acpi_srat_mem_affinity *)header;
+
+ acpi_table_print_srat_entry(&header->common);
+
if (srat_disabled())
- goto out_err;
+ return 0;
if (ma->header.length < sizeof(struct acpi_srat_mem_affinity)) {
pr_err("SRAT: Unexpected header length: %d\n",
ma->header.length);
goto out_err_bad_srat;
}
if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
- goto out_err;
+ return 0;
hotpluggable = IS_ENABLED(CONFIG_MEMORY_HOTPLUG) &&
(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE);
@@ -296,11 +304,15 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
max_possible_pfn = max(max_possible_pfn, PFN_UP(end - 1));
+ parsed_numa_memblks++;
+
return 0;
+
out_err_bad_srat:
+ /* Just disable SRAT, but do not fail and ignore errors. */
bad_srat();
-out_err:
- return -EINVAL;
+
+ return 0;
}
static int __init
@@ -549,24 +561,6 @@ acpi_parse_gi_affinity(union acpi_subtable_headers *header,
}
#endif /* defined(CONFIG_X86) || defined (CONFIG_ARM64) */
-static int __initdata parsed_numa_memblks;
-
-static int __init
-acpi_parse_memory_affinity(union acpi_subtable_headers * header,
- const unsigned long end)
-{
- struct acpi_srat_mem_affinity *memory_affinity;
-
- memory_affinity = (struct acpi_srat_mem_affinity *)header;
-
- acpi_table_print_srat_entry(&header->common);
-
- /* let architecture-dependent part to do it */
- if (!acpi_numa_memory_affinity_init(memory_affinity))
- parsed_numa_memblks++;
- return 0;
-}
-
static int __init acpi_parse_srat(struct acpi_table_header *table)
{
struct acpi_table_srat *srat = (struct acpi_table_srat *)table;
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT)
2024-04-19 14:02 ` [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Robert Richter
@ 2024-04-22 16:43 ` Jonathan Cameron
2024-04-22 20:56 ` Alison Schofield
2024-04-23 2:23 ` Dan Williams
2 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2024-04-22 16:43 UTC (permalink / raw)
To: Robert Richter
Cc: Rafael J. Wysocki, Dave Hansen, Dan Williams, Alison Schofield,
linux-acpi, linux-kernel, linux-cxl, Len Brown
On Fri, 19 Apr 2024 16:02:00 +0200
Robert Richter <rrichter@amd.com> wrote:
> The CEDT contains similar entries as the SRAT. For diagnostic reasons
> print the CEDT same style as the SRAT.
>
> Adding also a pr_info() when successfully adding a CFMWS memory range.
>
> Suggested-by: Alison Schofield <alison.schofield@intel.com> # CEDT node info
> Signed-off-by: Robert Richter <rrichter@amd.com>
Hi Robert,
Comments inline,
Jonathan
> ---
> drivers/acpi/numa/srat.c | 122 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 121 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
> index e45e64993c50..43417b4920da 100644
> --- a/drivers/acpi/numa/srat.c
> +++ b/drivers/acpi/numa/srat.c
> @@ -300,6 +300,114 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
> return -EINVAL;
> }
>
> +static int __init
> +__acpi_table_print_cedt_entry(union acpi_subtable_headers *__header,
> + void *arg, const unsigned long table_end)
> +{
> + struct acpi_cedt_header *header = (struct acpi_cedt_header *)__header;
As below. There is very little shred by the different types in here, so
I'd break it up into separate functions and just call the relevant
one.
> +
> + switch (header->type) {
> + case ACPI_CEDT_TYPE_CHBS:
> + {
> + struct acpi_cedt_chbs *p =
> + (struct acpi_cedt_chbs *)header;
> +
> + if (header->length < sizeof(struct acpi_cedt_chbs)) {
sizeof(*p) perhaps?
> + pr_warn("CEDT: unsupported CHBS entry: size %d\n",
> + header->length);
> + break;
> + }
> +
> + pr_debug("CEDT: CHBS (0x%llx length 0x%llx uid %lu) %s (%d)\n",
> + (unsigned long long)p->base,
> + (unsigned long long)p->length,
> + (unsigned long)p->uid,
> + (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) ?
> + "cxl11" :
> + (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL20) ?
> + "cxl20" :
> + "unsupported version",
> + p->cxl_version);
> + }
> + break;
> + case ACPI_CEDT_TYPE_CFMWS:
> + {
> + struct acpi_cedt_cfmws *p =
> + (struct acpi_cedt_cfmws *)header;
> + int eiw_to_ways[] = {1, 2, 4, 8, 16, 3, 6, 12};
> + int targets = -1;
> +
> + if (header->length < sizeof(struct acpi_cedt_cfmws)) {
sizeof(*p) perhaps?
> + pr_warn("CEDT: unsupported CFMWS entry: size %d\n",
> + header->length);
> + break;
> + }
> +
> + if (p->interleave_ways < ARRAY_SIZE(eiw_to_ways))
> + targets = eiw_to_ways[p->interleave_ways];
> + if (header->length < struct_size(
> + p, interleave_targets, targets))
> + targets = -1;
Not a warning?
> +
> + pr_debug("CEDT: CFMWS (0x%llx length 0x%llx) with %d target%s",
> + (unsigned long long)p->base_hpa,
> + (unsigned long long)p->window_size,
> + targets, targets > 1 ? "s" : "");
> + for (int i = 0; i < targets; i++)
> + pr_cont("%s%lu", i ? ", " : " (",
> + (unsigned long)p->interleave_targets[i]);
This seems odd. I don't think there is a good way to do combined pr_debug() and pr_cont()
There was a discussion about this a few years ago...
> + pr_cont("%s%s%s%s%s%s\n",
> + targets > 0 ? ")" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE2) ?
> + " type2" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE3) ?
> + " type3" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_VOLATILE) ?
> + " volatile" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_PMEM) ?
> + " pmem" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_FIXED) ?
> + " fixed" : "");
> + }
> + break;
> + case ACPI_CEDT_TYPE_CXIMS:
> + {
> + struct acpi_cedt_cxims *p =
> + (struct acpi_cedt_cxims *)header;
> +
> + if (header->length < sizeof(struct acpi_cedt_cxims)) {
sizeof(*p) perhaps?
> + pr_warn("CEDT: unsupported CXIMS entry: size %d\n",
> + header->length);
> + break;
I'd go with direct returns in these to make the code flow easier to read.
> + }
> +
> + pr_debug("CEDT: CXIMS (hbig %u nr_xormaps %u)\n",
> + (unsigned int)p->hbig,
> + (unsigned int)p->nr_xormaps);
> + }
> + break;
> + default:
> + pr_warn("CEDT: Found unsupported entry (type = 0x%x)\n",
> + header->type);
> + break;
> + }
> +
> + return 0;
> +}
> +
> +static void __init acpi_table_print_cedt_entry(enum acpi_cedt_type id)
> +{
> + acpi_table_parse_cedt(id, __acpi_table_print_cedt_entry, NULL);
> +}
> +
> +static void __init acpi_table_print_cedt(void)
> +{
> + /* Print only implemented CEDT types */
> + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CHBS);
> + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CFMWS);
> + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CXIMS);
Would this be cleaner just breaking these up?
acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, print_chbs_entry, NULL);
acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, print_cfmws_entry, NULL);
acpi_table_parse_cedt(ACPI_CEDT_TYPE_CXIMS, print_cxims_entry, NULL);
> +}
> +
> static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> void *arg, const unsigned long table_end)
> {
> @@ -318,8 +426,11 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> * found for any portion of the window to cover the entire
> * window.
> */
> - if (!numa_fill_memblks(start, end))
> + if (!numa_fill_memblks(start, end)) {
> + pr_info("CEDT: memblk extended [mem %#010Lx-%#010Lx]\n",
> + (unsigned long long) start, (unsigned long long) end - 1);
> return 0;
> + }
>
> /* No SRAT description. Create a new node. */
> node = acpi_map_pxm_to_node(*fake_pxm);
> @@ -334,13 +445,19 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> pr_warn("ACPI NUMA: Failed to add memblk for CFMWS node %d [mem %#llx-%#llx]\n",
> node, start, end);
> }
> +
Unrelated changed. Best to clean this out to avoid the (really minor) noise.
> node_set(node, numa_nodes_parsed);
>
> + pr_info("CEDT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
> + node, *fake_pxm,
> + (unsigned long long) start, (unsigned long long) end - 1);
> +
> /* Set the next available fake_pxm value */
> (*fake_pxm)++;
> return 0;
> }
> #else
> +static inline void acpi_table_print_cedt(void) {}
> static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> void *arg, const unsigned long table_end)
> {
> @@ -526,6 +643,9 @@ int __init acpi_numa_init(void)
> /* SLIT: System Locality Information Table */
> acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
>
> + /* CEDT: CXL Early Discovery Table */
> + acpi_table_print_cedt();
> +
> /*
> * CXL Fixed Memory Window Structures (CFMWS) must be parsed
> * after the SRAT. Create NUMA Nodes for CXL memory ranges that
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings
2024-04-19 14:02 ` [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings Robert Richter
@ 2024-04-22 16:48 ` Jonathan Cameron
2024-04-23 2:27 ` Dan Williams
2024-04-23 2:28 ` Dan Williams
2 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2024-04-22 16:48 UTC (permalink / raw)
To: Robert Richter
Cc: Rafael J. Wysocki, Dave Hansen, Dan Williams, Alison Schofield,
linux-acpi, linux-kernel, linux-cxl, Len Brown
On Fri, 19 Apr 2024 16:02:01 +0200
Robert Richter <rrichter@amd.com> wrote:
> With the removal of the Itanium architecture [1] the last architecture
> dependent functions:
>
> acpi_numa_slit_init(), acpi_numa_memory_affinity_init()
>
> were removed. Remove its remainings in the header files too an make
> them static.
>
> [1] commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture")
>
> Signed-off-by: Robert Richter <rrichter@amd.com>
The slit change is fine, but what about the cfmws function in here
where a stub was removed as well. Looks sensible as it relied on the
implementation details of acpi_numa_memory_affinity_init() but
should probably call it out in the description and say why it no
longer needs to be protected like this.
Jonathan
> ---
> drivers/acpi/numa/srat.c | 17 ++---------------
> include/linux/acpi.h | 5 -----
> 2 files changed, 2 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
> index 43417b4920da..bd0e2d342ba2 100644
> --- a/drivers/acpi/numa/srat.c
> +++ b/drivers/acpi/numa/srat.c
> @@ -208,13 +208,12 @@ int __init srat_disabled(void)
> return acpi_numa < 0;
> }
>
> -#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
> /*
> * Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for
> * I/O localities since SRAT does not list them. I/O localities are
> * not supported at this point.
> */
> -void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
> +static void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
> {
> int i, j;
>
> @@ -236,11 +235,7 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
> }
> }
>
> -/*
> - * Default callback for parsing of the Proximity Domain <-> Memory
> - * Area mappings
> - */
> -int __init
> +static int __init
> acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
> {
> u64 start, end;
> @@ -456,14 +451,6 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> (*fake_pxm)++;
> return 0;
> }
> -#else
> -static inline void acpi_table_print_cedt(void) {}
> -static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> - void *arg, const unsigned long table_end)
> -{
> - return 0;
> -}
> -#endif /* defined(CONFIG_X86) || defined (CONFIG_ARM64) */
>
> static int __init acpi_parse_slit(struct acpi_table_header *table)
> {
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 34829f2c517a..2c227b61a452 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -242,9 +242,6 @@ static inline bool acpi_gicc_is_usable(struct acpi_madt_generic_interrupt *gicc)
> return gicc->flags & ACPI_MADT_ENABLED;
> }
>
> -/* the following numa functions are architecture-dependent */
> -void acpi_numa_slit_init (struct acpi_table_slit *slit);
> -
> #if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH)
> void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
> #else
> @@ -267,8 +264,6 @@ static inline void
> acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { }
> #endif
>
> -int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
> -
> #ifndef PHYS_CPUID_INVALID
> typedef u32 phys_cpuid_t;
> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit()
2024-04-19 14:02 ` [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit() Robert Richter
@ 2024-04-22 16:49 ` Jonathan Cameron
2024-04-23 20:03 ` Dan Williams
1 sibling, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2024-04-22 16:49 UTC (permalink / raw)
To: Robert Richter
Cc: Rafael J. Wysocki, Dave Hansen, Dan Williams, Alison Schofield,
linux-acpi, linux-kernel, linux-cxl, Len Brown
On Fri, 19 Apr 2024 16:02:02 +0200
Robert Richter <rrichter@amd.com> wrote:
> After removing architectural code the helper function
> acpi_numa_slit_init() is no longer needed. Squash it into
> acpi_parse_slit(). No functional changes intended.
>
> Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity()
2024-04-19 14:02 ` [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity() Robert Richter
@ 2024-04-22 16:54 ` Jonathan Cameron
2024-04-23 2:29 ` Dan Williams
1 sibling, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2024-04-22 16:54 UTC (permalink / raw)
To: Robert Richter
Cc: Rafael J. Wysocki, Dave Hansen, Dan Williams, Alison Schofield,
linux-acpi, linux-kernel, linux-cxl, kernel test robot, Len Brown
On Fri, 19 Apr 2024 16:02:03 +0200
Robert Richter <rrichter@amd.com> wrote:
> After removing architectural code the helper function
> acpi_numa_memory_affinity_init() is no longer needed. Squash it into
> acpi_parse_memory_affinity(). No functional changes intended.
>
> While at it, fixing checkpatch complaints in code moved.
>
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202403220943.96dde419-oliver.sang@intel.com
> Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
2024-04-19 14:01 ` [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() Robert Richter
@ 2024-04-22 20:47 ` Alison Schofield
2024-04-23 2:20 ` Dan Williams
1 sibling, 0 replies; 21+ messages in thread
From: Alison Schofield @ 2024-04-22 20:47 UTC (permalink / raw)
To: Robert Richter
Cc: Rafael J. Wysocki, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, Andy Lutomirski, Peter Zijlstra, Dan Williams,
linux-acpi, linux-kernel, linux-cxl, Derick Marks, H. Peter Anvin
On Fri, Apr 19, 2024 at 04:01:59PM +0200, Robert Richter wrote:
> For configurations that have the kconfig option NUMA_KEEP_MEMINFO
> disabled, the SRAT lookup done with numa_fill_memblks() fails
> returning NUMA_NO_MEMBLK (-1). An existing SRAT memory range cannot be
> found for a CFMWS address range. This causes the addition of a
> duplicate numa_memblk with a different node id and a subsequent page
> fault and kernel crash during boot.
>
> numa_fill_memblks() is implemented and used in the init section only.
> The option NUMA_KEEP_MEMINFO is only for the case when NUMA data will
> be used outside of init. So fix the SRAT lookup by moving
> numa_fill_memblks() out of the NUMA_KEEP_MEMINFO block to make it
> always available in the init section.
>
> Note that the issue was initially introduced with [1]. But since
> phys_to_target_node() was originally used that returned the valid node
> 0, an additional numa_memblk was not added. Though, the node id was
> wrong too.
>
> [1] commit fd49f99c1809 ("ACPI: NUMA: Add a node and memblk for each
> CFMWS not in SRAT")
>
> Fixes: 8f1004679987 ("ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window")
> Cc: Derick Marks <derick.w.marks@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
with the assumption that this is passing 0-day builds...
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> arch/x86/include/asm/sparsemem.h | 2 +-
> arch/x86/mm/numa.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/include/asm/sparsemem.h b/arch/x86/include/asm/sparsemem.h
> index 1be13b2dfe8b..1aaa447ef24b 100644
> --- a/arch/x86/include/asm/sparsemem.h
> +++ b/arch/x86/include/asm/sparsemem.h
> @@ -37,9 +37,9 @@ extern int phys_to_target_node(phys_addr_t start);
> #define phys_to_target_node phys_to_target_node
> extern int memory_add_physaddr_to_nid(u64 start);
> #define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
> +#endif
> extern int numa_fill_memblks(u64 start, u64 end);
> #define numa_fill_memblks numa_fill_memblks
> -#endif
> #endif /* __ASSEMBLY__ */
>
> #endif /* _ASM_X86_SPARSEMEM_H */
> diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> index 65e9a6e391c0..ce84ba86e69e 100644
> --- a/arch/x86/mm/numa.c
> +++ b/arch/x86/mm/numa.c
> @@ -929,6 +929,8 @@ int memory_add_physaddr_to_nid(u64 start)
> }
> EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
>
> +#endif
> +
> static int __init cmp_memblk(const void *a, const void *b)
> {
> const struct numa_memblk *ma = *(const struct numa_memblk **)a;
> @@ -1001,5 +1003,3 @@ int __init numa_fill_memblks(u64 start, u64 end)
> }
> return 0;
> }
> -
> -#endif
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT)
2024-04-19 14:02 ` [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Robert Richter
2024-04-22 16:43 ` Jonathan Cameron
@ 2024-04-22 20:56 ` Alison Schofield
2024-04-22 21:17 ` Robert Richter
2024-04-23 2:23 ` Dan Williams
2 siblings, 1 reply; 21+ messages in thread
From: Alison Schofield @ 2024-04-22 20:56 UTC (permalink / raw)
To: Robert Richter
Cc: Rafael J. Wysocki, Dave Hansen, Dan Williams, linux-acpi,
linux-kernel, linux-cxl, Len Brown
On Fri, Apr 19, 2024 at 04:02:00PM +0200, Robert Richter wrote:
> The CEDT contains similar entries as the SRAT. For diagnostic reasons
> print the CEDT same style as the SRAT.
>
> Adding also a pr_info() when successfully adding a CFMWS memory range.
>
> Suggested-by: Alison Schofield <alison.schofield@intel.com> # CEDT node info
Ah, I see you annotated the Suggested-by. I did suggest the pr_info
when we extend or add a node during CFMWS parsing.
There is an update in acpitools for CEDT decode and dump[1] offering
pretty dumps of this info. Is this printing for convenience or for
something else?
[1] https://github.com/acpica/acpica/pull/939
-- Alison
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> drivers/acpi/numa/srat.c | 122 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 121 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
> index e45e64993c50..43417b4920da 100644
> --- a/drivers/acpi/numa/srat.c
> +++ b/drivers/acpi/numa/srat.c
> @@ -300,6 +300,114 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
> return -EINVAL;
> }
>
> +static int __init
> +__acpi_table_print_cedt_entry(union acpi_subtable_headers *__header,
> + void *arg, const unsigned long table_end)
> +{
> + struct acpi_cedt_header *header = (struct acpi_cedt_header *)__header;
> +
> + switch (header->type) {
> + case ACPI_CEDT_TYPE_CHBS:
> + {
> + struct acpi_cedt_chbs *p =
> + (struct acpi_cedt_chbs *)header;
> +
> + if (header->length < sizeof(struct acpi_cedt_chbs)) {
> + pr_warn("CEDT: unsupported CHBS entry: size %d\n",
> + header->length);
> + break;
> + }
> +
> + pr_debug("CEDT: CHBS (0x%llx length 0x%llx uid %lu) %s (%d)\n",
> + (unsigned long long)p->base,
> + (unsigned long long)p->length,
> + (unsigned long)p->uid,
> + (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) ?
> + "cxl11" :
> + (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL20) ?
> + "cxl20" :
> + "unsupported version",
> + p->cxl_version);
> + }
> + break;
> + case ACPI_CEDT_TYPE_CFMWS:
> + {
> + struct acpi_cedt_cfmws *p =
> + (struct acpi_cedt_cfmws *)header;
> + int eiw_to_ways[] = {1, 2, 4, 8, 16, 3, 6, 12};
> + int targets = -1;
> +
> + if (header->length < sizeof(struct acpi_cedt_cfmws)) {
> + pr_warn("CEDT: unsupported CFMWS entry: size %d\n",
> + header->length);
> + break;
> + }
> +
> + if (p->interleave_ways < ARRAY_SIZE(eiw_to_ways))
> + targets = eiw_to_ways[p->interleave_ways];
> + if (header->length < struct_size(
> + p, interleave_targets, targets))
> + targets = -1;
> +
> + pr_debug("CEDT: CFMWS (0x%llx length 0x%llx) with %d target%s",
> + (unsigned long long)p->base_hpa,
> + (unsigned long long)p->window_size,
> + targets, targets > 1 ? "s" : "");
> + for (int i = 0; i < targets; i++)
> + pr_cont("%s%lu", i ? ", " : " (",
> + (unsigned long)p->interleave_targets[i]);
> + pr_cont("%s%s%s%s%s%s\n",
> + targets > 0 ? ")" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE2) ?
> + " type2" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE3) ?
> + " type3" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_VOLATILE) ?
> + " volatile" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_PMEM) ?
> + " pmem" : "",
> + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_FIXED) ?
> + " fixed" : "");
> + }
> + break;
> + case ACPI_CEDT_TYPE_CXIMS:
> + {
> + struct acpi_cedt_cxims *p =
> + (struct acpi_cedt_cxims *)header;
> +
> + if (header->length < sizeof(struct acpi_cedt_cxims)) {
> + pr_warn("CEDT: unsupported CXIMS entry: size %d\n",
> + header->length);
> + break;
> + }
> +
> + pr_debug("CEDT: CXIMS (hbig %u nr_xormaps %u)\n",
> + (unsigned int)p->hbig,
> + (unsigned int)p->nr_xormaps);
> + }
> + break;
> + default:
> + pr_warn("CEDT: Found unsupported entry (type = 0x%x)\n",
> + header->type);
> + break;
> + }
> +
> + return 0;
> +}
> +
> +static void __init acpi_table_print_cedt_entry(enum acpi_cedt_type id)
> +{
> + acpi_table_parse_cedt(id, __acpi_table_print_cedt_entry, NULL);
> +}
> +
> +static void __init acpi_table_print_cedt(void)
> +{
> + /* Print only implemented CEDT types */
> + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CHBS);
> + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CFMWS);
> + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CXIMS);
> +}
> +
> static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> void *arg, const unsigned long table_end)
> {
> @@ -318,8 +426,11 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> * found for any portion of the window to cover the entire
> * window.
> */
> - if (!numa_fill_memblks(start, end))
> + if (!numa_fill_memblks(start, end)) {
> + pr_info("CEDT: memblk extended [mem %#010Lx-%#010Lx]\n",
> + (unsigned long long) start, (unsigned long long) end - 1);
> return 0;
> + }
>
> /* No SRAT description. Create a new node. */
> node = acpi_map_pxm_to_node(*fake_pxm);
> @@ -334,13 +445,19 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> pr_warn("ACPI NUMA: Failed to add memblk for CFMWS node %d [mem %#llx-%#llx]\n",
> node, start, end);
> }
> +
> node_set(node, numa_nodes_parsed);
>
> + pr_info("CEDT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
> + node, *fake_pxm,
> + (unsigned long long) start, (unsigned long long) end - 1);
> +
> /* Set the next available fake_pxm value */
> (*fake_pxm)++;
> return 0;
> }
> #else
> +static inline void acpi_table_print_cedt(void) {}
> static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
> void *arg, const unsigned long table_end)
> {
> @@ -526,6 +643,9 @@ int __init acpi_numa_init(void)
> /* SLIT: System Locality Information Table */
> acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
>
> + /* CEDT: CXL Early Discovery Table */
> + acpi_table_print_cedt();
> +
> /*
> * CXL Fixed Memory Window Structures (CFMWS) must be parsed
> * after the SRAT. Create NUMA Nodes for CXL memory ranges that
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT)
2024-04-22 20:56 ` Alison Schofield
@ 2024-04-22 21:17 ` Robert Richter
0 siblings, 0 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-22 21:17 UTC (permalink / raw)
To: Alison Schofield
Cc: Rafael J. Wysocki, Dave Hansen, Dan Williams, linux-acpi,
linux-kernel, linux-cxl, Len Brown
On 22.04.24 13:56:00, Alison Schofield wrote:
> On Fri, Apr 19, 2024 at 04:02:00PM +0200, Robert Richter wrote:
> > The CEDT contains similar entries as the SRAT. For diagnostic reasons
> > print the CEDT same style as the SRAT.
> >
> > Adding also a pr_info() when successfully adding a CFMWS memory range.
> >
> > Suggested-by: Alison Schofield <alison.schofield@intel.com> # CEDT node info
>
> Ah, I see you annotated the Suggested-by. I did suggest the pr_info
> when we extend or add a node during CFMWS parsing.
That's what I meant here and what I have added to this patch with this
update.
>
> There is an update in acpitools for CEDT decode and dump[1] offering
> pretty dumps of this info. Is this printing for convenience or for
> something else?
No, this helped early boot debugging of kernel and ACPI issues since
CEDT entries are important for this. For acpitools you need the
machine to be up already. If it is not part of the kernel log there
would be a 2nd step needed to get this information from. The patch
also lifts CEDT logging to the same level as for SRAT.
I hope that makes sense?
Thanks,
-Robert
>
> [1] https://github.com/acpica/acpica/pull/939
>
> -- Alison
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
2024-04-19 14:01 ` [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() Robert Richter
2024-04-22 20:47 ` Alison Schofield
@ 2024-04-23 2:20 ` Dan Williams
2024-04-24 15:41 ` Robert Richter
1 sibling, 1 reply; 21+ messages in thread
From: Dan Williams @ 2024-04-23 2:20 UTC (permalink / raw)
To: Robert Richter, Rafael J. Wysocki, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, Andy Lutomirski,
Peter Zijlstra, Dan Williams, Alison Schofield
Cc: linux-acpi, linux-kernel, linux-cxl, Robert Richter, Derick Marks,
H. Peter Anvin
Robert Richter wrote:
> For configurations that have the kconfig option NUMA_KEEP_MEMINFO
> disabled, the SRAT lookup done with numa_fill_memblks() fails
> returning NUMA_NO_MEMBLK (-1). An existing SRAT memory range cannot be
> found for a CFMWS address range. This causes the addition of a
> duplicate numa_memblk with a different node id and a subsequent page
> fault and kernel crash during boot.
>
> numa_fill_memblks() is implemented and used in the init section only.
> The option NUMA_KEEP_MEMINFO is only for the case when NUMA data will
> be used outside of init. So fix the SRAT lookup by moving
> numa_fill_memblks() out of the NUMA_KEEP_MEMINFO block to make it
> always available in the init section.
>
> Note that the issue was initially introduced with [1]. But since
> phys_to_target_node() was originally used that returned the valid node
> 0, an additional numa_memblk was not added. Though, the node id was
> wrong too.
Wrong node seems worth notifying and we can figure out on the backend
where the backport makes sense.
>
> [1] commit fd49f99c1809 ("ACPI: NUMA: Add a node and memblk for each
> CFMWS not in SRAT")
>
> Fixes: 8f1004679987 ("ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window")
> Cc: Derick Marks <derick.w.marks@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> arch/x86/include/asm/sparsemem.h | 2 +-
> arch/x86/mm/numa.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/include/asm/sparsemem.h b/arch/x86/include/asm/sparsemem.h
> index 1be13b2dfe8b..1aaa447ef24b 100644
> --- a/arch/x86/include/asm/sparsemem.h
> +++ b/arch/x86/include/asm/sparsemem.h
> @@ -37,9 +37,9 @@ extern int phys_to_target_node(phys_addr_t start);
> #define phys_to_target_node phys_to_target_node
> extern int memory_add_physaddr_to_nid(u64 start);
> #define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
> +#endif
> extern int numa_fill_memblks(u64 start, u64 end);
> #define numa_fill_memblks numa_fill_memblks
It just feels like numa_fill_memblks() has absolutely no business being
defined in arch/x86/include/asm/sparsemem.h.
The only use for numa_fill_memblks() is to arrange for NUMA nodes to be
applied to memory ranges hot-onlined by the CXL driver.
It belongs right next to numa_add_memblk(), and I suspect
arch/x86/include/asm/sparsemem.h was only chosen to avoid figuring out
what to do about the fact that linux/numa.h does not include asm/numa.h
and that all implementations either provide numa_add_memblk() or select
the generic implementation.
So I would prefer that this do the proper fix and get
numa_fill_memblks() completely out of the sparsemem.h path.
Something like the following which boots for me:
diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h
index ef2844d69173..12a93a3466c4 100644
--- a/arch/x86/include/asm/numa.h
+++ b/arch/x86/include/asm/numa.h
@@ -26,6 +26,7 @@ extern s16 __apicid_to_node[MAX_LOCAL_APIC];
extern nodemask_t numa_nodes_parsed __initdata;
extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
+extern int __init numa_fill_memblks(u64 start, u64 end);
extern void __init numa_set_distance(int from, int to, int distance);
static inline void set_apicid_to_node(int apicid, s16 node)
diff --git a/arch/x86/include/asm/sparsemem.h b/arch/x86/include/asm/sparsemem.h
index 1be13b2dfe8b..64df897c0ee3 100644
--- a/arch/x86/include/asm/sparsemem.h
+++ b/arch/x86/include/asm/sparsemem.h
@@ -37,8 +37,6 @@ extern int phys_to_target_node(phys_addr_t start);
#define phys_to_target_node phys_to_target_node
extern int memory_add_physaddr_to_nid(u64 start);
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
-extern int numa_fill_memblks(u64 start, u64 end);
-#define numa_fill_memblks numa_fill_memblks
#endif
#endif /* __ASSEMBLY__ */
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index e45e64993c50..3b09fd39eeb4 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -208,6 +208,11 @@ int __init srat_disabled(void)
return acpi_numa < 0;
}
+__weak int __init numa_fill_memblks(u64 start, u64 end)
+{
+ return NUMA_NO_MEMBLK;
+}
+
#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
/*
* Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for
diff --git a/include/linux/numa.h b/include/linux/numa.h
index 915033a75731..8485d98e554d 100644
--- a/include/linux/numa.h
+++ b/include/linux/numa.h
@@ -36,13 +36,6 @@ int memory_add_physaddr_to_nid(u64 start);
int phys_to_target_node(u64 start);
#endif
-#ifndef numa_fill_memblks
-static inline int __init numa_fill_memblks(u64 start, u64 end)
-{
- return NUMA_NO_MEMBLK;
-}
-#endif
-
#else /* !CONFIG_NUMA */
static inline int numa_nearest_node(int node, unsigned int state)
{
^ permalink raw reply related [flat|nested] 21+ messages in thread
* RE: [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT)
2024-04-19 14:02 ` [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Robert Richter
2024-04-22 16:43 ` Jonathan Cameron
2024-04-22 20:56 ` Alison Schofield
@ 2024-04-23 2:23 ` Dan Williams
2 siblings, 0 replies; 21+ messages in thread
From: Dan Williams @ 2024-04-23 2:23 UTC (permalink / raw)
To: Robert Richter, Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
Robert Richter wrote:
> The CEDT contains similar entries as the SRAT. For diagnostic reasons
> print the CEDT same style as the SRAT.
>
> Adding also a pr_info() when successfully adding a CFMWS memory range.
>
> Suggested-by: Alison Schofield <alison.schofield@intel.com> # CEDT node info
> Signed-off-by: Robert Richter <rrichter@amd.com>
This patch feels out of place with the rest. At a minimum it should come
at the end. For me, I would just drop it altogether unless there is
some motivation to enable more bootup debug messages.
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings
2024-04-19 14:02 ` [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings Robert Richter
2024-04-22 16:48 ` Jonathan Cameron
@ 2024-04-23 2:27 ` Dan Williams
2024-04-23 2:28 ` Dan Williams
2 siblings, 0 replies; 21+ messages in thread
From: Dan Williams @ 2024-04-23 2:27 UTC (permalink / raw)
To: Robert Richter, Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
Robert Richter wrote:
> With the removal of the Itanium architecture [1] the last architecture
> dependent functions:
>
> acpi_numa_slit_init(), acpi_numa_memory_affinity_init()
>
> were removed. Remove its remainings in the header files too an make
> them static.
>
> [1] commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture")
>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> drivers/acpi/numa/srat.c | 17 ++---------------
> include/linux/acpi.h | 5 -----
> 2 files changed, 2 insertions(+), 20 deletions(-)
Looks good,
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings
2024-04-19 14:02 ` [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings Robert Richter
2024-04-22 16:48 ` Jonathan Cameron
2024-04-23 2:27 ` Dan Williams
@ 2024-04-23 2:28 ` Dan Williams
2024-04-23 6:48 ` Robert Richter
2 siblings, 1 reply; 21+ messages in thread
From: Dan Williams @ 2024-04-23 2:28 UTC (permalink / raw)
To: Robert Richter, Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
Robert Richter wrote:
> With the removal of the Itanium architecture [1] the last architecture
> dependent functions:
>
> acpi_numa_slit_init(), acpi_numa_memory_affinity_init()
>
> were removed. Remove its remainings in the header files too an make
> them static.
>
> [1] commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture")
>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> drivers/acpi/numa/srat.c | 17 ++---------------
> include/linux/acpi.h | 5 -----
> 2 files changed, 2 insertions(+), 20 deletions(-)
Looks good,
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity()
2024-04-19 14:02 ` [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity() Robert Richter
2024-04-22 16:54 ` Jonathan Cameron
@ 2024-04-23 2:29 ` Dan Williams
1 sibling, 0 replies; 21+ messages in thread
From: Dan Williams @ 2024-04-23 2:29 UTC (permalink / raw)
To: Robert Richter, Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, kernel test robot,
Len Brown
Robert Richter wrote:
> After removing architectural code the helper function
> acpi_numa_memory_affinity_init() is no longer needed. Squash it into
> acpi_parse_memory_affinity(). No functional changes intended.
>
> While at it, fixing checkpatch complaints in code moved.
>
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202403220943.96dde419-oliver.sang@intel.com
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> drivers/acpi/numa/srat.c | 40 +++++++++++++++++-----------------------
> 1 file changed, 17 insertions(+), 23 deletions(-)
Looks good,
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings
2024-04-23 2:28 ` Dan Williams
@ 2024-04-23 6:48 ` Robert Richter
0 siblings, 0 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-23 6:48 UTC (permalink / raw)
To: Dan Williams
Cc: Rafael J. Wysocki, Dave Hansen, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Len Brown
On 22.04.24 19:28:29, Dan Williams wrote:
> Robert Richter wrote:
> > With the removal of the Itanium architecture [1] the last architecture
> > dependent functions:
> >
> > acpi_numa_slit_init(), acpi_numa_memory_affinity_init()
> >
> > were removed. Remove its remainings in the header files too an make
> > them static.
> >
> > [1] commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture")
> >
> > Signed-off-by: Robert Richter <rrichter@amd.com>
> > ---
> > drivers/acpi/numa/srat.c | 17 ++---------------
> > include/linux/acpi.h | 5 -----
> > 2 files changed, 2 insertions(+), 20 deletions(-)
>
> Looks good,
>
> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
I assume this is for 4/5?
Thanks for review.
-Robert
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit()
2024-04-19 14:02 ` [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit() Robert Richter
2024-04-22 16:49 ` Jonathan Cameron
@ 2024-04-23 20:03 ` Dan Williams
1 sibling, 0 replies; 21+ messages in thread
From: Dan Williams @ 2024-04-23 20:03 UTC (permalink / raw)
To: Robert Richter, Rafael J. Wysocki
Cc: Dave Hansen, Dan Williams, Alison Schofield, linux-acpi,
linux-kernel, linux-cxl, Robert Richter, Len Brown
Robert Richter wrote:
> After removing architectural code the helper function
> acpi_numa_slit_init() is no longer needed. Squash it into
> acpi_parse_slit(). No functional changes intended.
>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> drivers/acpi/numa/srat.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
Looks like I fumble fingered and replied to patch 3/5 twice. For this
one as well:
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
2024-04-23 2:20 ` Dan Williams
@ 2024-04-24 15:41 ` Robert Richter
0 siblings, 0 replies; 21+ messages in thread
From: Robert Richter @ 2024-04-24 15:41 UTC (permalink / raw)
To: Dan Williams
Cc: Rafael J. Wysocki, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, Andy Lutomirski, Peter Zijlstra,
Alison Schofield, linux-acpi, linux-kernel, linux-cxl,
Derick Marks, H. Peter Anvin
On 22.04.24 19:20:48, Dan Williams wrote:
> Robert Richter wrote:
> > For configurations that have the kconfig option NUMA_KEEP_MEMINFO
> > disabled, the SRAT lookup done with numa_fill_memblks() fails
> > returning NUMA_NO_MEMBLK (-1). An existing SRAT memory range cannot be
> > found for a CFMWS address range. This causes the addition of a
> > duplicate numa_memblk with a different node id and a subsequent page
> > fault and kernel crash during boot.
> >
> > numa_fill_memblks() is implemented and used in the init section only.
> > The option NUMA_KEEP_MEMINFO is only for the case when NUMA data will
> > be used outside of init. So fix the SRAT lookup by moving
> > numa_fill_memblks() out of the NUMA_KEEP_MEMINFO block to make it
> > always available in the init section.
> >
> > Note that the issue was initially introduced with [1]. But since
> > phys_to_target_node() was originally used that returned the valid node
> > 0, an additional numa_memblk was not added. Though, the node id was
> > wrong too.
>
> Wrong node seems worth notifying and we can figure out on the backend
> where the backport makes sense.
Updating the description here.
>
> >
> > [1] commit fd49f99c1809 ("ACPI: NUMA: Add a node and memblk for each
> > CFMWS not in SRAT")
> >
> > Fixes: 8f1004679987 ("ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window")
> > Cc: Derick Marks <derick.w.marks@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Alison Schofield <alison.schofield@intel.com>
> > Signed-off-by: Robert Richter <rrichter@amd.com>
> > ---
> > arch/x86/include/asm/sparsemem.h | 2 +-
> > arch/x86/mm/numa.c | 4 ++--
> > 2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/sparsemem.h b/arch/x86/include/asm/sparsemem.h
> > index 1be13b2dfe8b..1aaa447ef24b 100644
> > --- a/arch/x86/include/asm/sparsemem.h
> > +++ b/arch/x86/include/asm/sparsemem.h
> > @@ -37,9 +37,9 @@ extern int phys_to_target_node(phys_addr_t start);
> > #define phys_to_target_node phys_to_target_node
> > extern int memory_add_physaddr_to_nid(u64 start);
> > #define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
> > +#endif
> > extern int numa_fill_memblks(u64 start, u64 end);
> > #define numa_fill_memblks numa_fill_memblks
>
> It just feels like numa_fill_memblks() has absolutely no business being
> defined in arch/x86/include/asm/sparsemem.h.
>
> The only use for numa_fill_memblks() is to arrange for NUMA nodes to be
> applied to memory ranges hot-onlined by the CXL driver.
>
> It belongs right next to numa_add_memblk(), and I suspect
> arch/x86/include/asm/sparsemem.h was only chosen to avoid figuring out
> what to do about the fact that linux/numa.h does not include asm/numa.h
> and that all implementations either provide numa_add_memblk() or select
> the generic implementation.
>
> So I would prefer that this do the proper fix and get
> numa_fill_memblks() completely out of the sparsemem.h path.
>
> Something like the following which boots for me:
I have kept this patch as a stable change but took your patch on top.
Thanks,
-Robert
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2024-04-24 15:41 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19 14:01 [PATCH v3 0/5] SRAT/CEDT fixes and updates Robert Richter
2024-04-19 14:01 ` [PATCH v3 1/5] x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() Robert Richter
2024-04-22 20:47 ` Alison Schofield
2024-04-23 2:20 ` Dan Williams
2024-04-24 15:41 ` Robert Richter
2024-04-19 14:02 ` [PATCH v3 2/5] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Robert Richter
2024-04-22 16:43 ` Jonathan Cameron
2024-04-22 20:56 ` Alison Schofield
2024-04-22 21:17 ` Robert Richter
2024-04-23 2:23 ` Dan Williams
2024-04-19 14:02 ` [PATCH v3 3/5] ACPI/NUMA: Remove architecture dependent remainings Robert Richter
2024-04-22 16:48 ` Jonathan Cameron
2024-04-23 2:27 ` Dan Williams
2024-04-23 2:28 ` Dan Williams
2024-04-23 6:48 ` Robert Richter
2024-04-19 14:02 ` [PATCH v3 4/5] ACPI/NUMA: Squash acpi_numa_slit_init() into acpi_parse_slit() Robert Richter
2024-04-22 16:49 ` Jonathan Cameron
2024-04-23 20:03 ` Dan Williams
2024-04-19 14:02 ` [PATCH v3 5/5] ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity() Robert Richter
2024-04-22 16:54 ` Jonathan Cameron
2024-04-23 2:29 ` Dan Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox