Skip to content

Commit 5290e88

Browse files
swahlhpehansendc
authored andcommitted
x86/platform/uv: Use alternate source for socket to node data
The UV code attempts to build a set of tables to allow it to do bidirectional socket<=>node lookups. But 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 skipping some nodes or sockets when creating the tables and leaving some -1's for later code to trip. over, causing oopses. The problem is that the socket<=>node lookups are created by doing a loop over all CPUs, then looking up the CPU's APICID and socket. But if a CPU is not present, there is no way to start this lookup. Instead of looping over all CPUs, take CPUs out of the equation entirely. Loop over all APICIDs which are mapped to a valid NUMA node. Then just extract the socket-id from the APICID. This avoid tripping over disabled CPUs. Fixes: 8a50c58 ("x86/platform/uv: UV support for sub-NUMA clustering") Signed-off-by: Steve Wahl <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/20230807141730.1117278-1-steve.wahl%40hpe.com
1 parent 0bb80ec commit 5290e88

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ static void __init build_socket_tables(void)
15331533
{
15341534
struct uv_gam_range_entry *gre = uv_gre_table;
15351535
int nums, numn, nump;
1536-
int cpu, i, lnid;
1536+
int i, lnid, apicid;
15371537
int minsock = _min_socket;
15381538
int maxsock = _max_socket;
15391539
int minpnode = _min_pnode;
@@ -1584,15 +1584,14 @@ static void __init build_socket_tables(void)
15841584

15851585
/* Set socket -> node values: */
15861586
lnid = NUMA_NO_NODE;
1587-
for_each_possible_cpu(cpu) {
1588-
int nid = cpu_to_node(cpu);
1589-
int apicid, sockid;
1587+
for (apicid = 0; apicid < ARRAY_SIZE(__apicid_to_node); apicid++) {
1588+
int nid = __apicid_to_node[apicid];
1589+
int sockid;
15901590

1591-
if (lnid == nid)
1591+
if ((nid == NUMA_NO_NODE) || (lnid == nid))
15921592
continue;
15931593
lnid = nid;
15941594

1595-
apicid = per_cpu(x86_cpu_to_apicid, cpu);
15961595
sockid = apicid >> uv_cpuid.socketid_shift;
15971596

15981597
if (_socket_to_node[sockid - minsock] == SOCK_EMPTY)

0 commit comments

Comments
 (0)