mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/platform/uv: Use alternate source for socket to node data
@ 2023-08-07 14:17 Steve Wahl
  2023-08-28 21:22 ` Steve Wahl
  2023-09-01 17:18 ` Dave Hansen
  0 siblings, 2 replies; 9+ messages in thread
From: Steve Wahl @ 2023-08-07 14:17 UTC (permalink / raw)
  To: Steve Wahl, Dimitri Sivanich, Russ Anderson, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	linux-kernel

When nr_cpus is set to a smaller number than actually present, the
cpu_to_node() mapping information for unused CPUs is not available to
build_socket_tables().  This results in an incomplete table and will
later cause use of a -1 value for some array indexing, and eventual
kernel page faults.

Switch to using the __apicid_to_node array, which still contains all
the information mapping apicids to nodes, even for CPUs disabled with
a reduced nr_cpus setting.

Fixes: 8a50c5851927 ("x86/platform/uv: UV support for sub-NUMA clustering")
Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
---
 arch/x86/kernel/apic/x2apic_uv_x.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

This is essentially version 2 of "[PATCH] x86/platform/uv: Abort UV
initialization when reduced nr_cpus requires it".  However, the title
was no longer accurate, aborting UV initialization is no longer needed.

Previous discussion can be found here:
https://lore.kernel.org/lkml/20230711202618.85562-1-steve.wahl@hpe.com/

diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index d9384d5b4b8e..35acc95c6dd5 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -1571,7 +1571,7 @@ static void __init build_socket_tables(void)
 {
 	struct uv_gam_range_entry *gre = uv_gre_table;
 	int nums, numn, nump;
-	int cpu, i, lnid;
+	int i, lnid, apicid;
 	int minsock = _min_socket;
 	int maxsock = _max_socket;
 	int minpnode = _min_pnode;
@@ -1622,15 +1622,14 @@ static void __init build_socket_tables(void)
 
 	/* Set socket -> node values: */
 	lnid = NUMA_NO_NODE;
-	for_each_possible_cpu(cpu) {
-		int nid = cpu_to_node(cpu);
-		int apicid, sockid;
+	for (apicid = 0; apicid < ARRAY_SIZE(__apicid_to_node); apicid++) {
+		int nid = __apicid_to_node[apicid];
+		int sockid;
 
-		if (lnid == nid)
+		if ((nid == NUMA_NO_NODE) || (lnid == nid))
 			continue;
 		lnid = nid;
 
-		apicid = per_cpu(x86_cpu_to_apicid, cpu);
 		sockid = apicid >> uv_cpuid.socketid_shift;
 
 		if (_socket_to_node[sockid - minsock] == SOCK_EMPTY)
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-07 21:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 14:17 [PATCH] x86/platform/uv: Use alternate source for socket to node data Steve Wahl
2023-08-28 21:22 ` Steve Wahl
2023-09-01 17:18 ` Dave Hansen
2023-09-01 19:01   ` Steve Wahl
2023-09-05 15:01     ` Steve Wahl
2023-09-07 20:57       ` Dave Hansen
2023-09-07 21:25         ` Steve Wahl
2023-09-07 21:32           ` Dave Hansen
2023-09-07 21:43             ` Steve Wahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®