Skip to content

Commit 75b5e0b

Browse files
HuangShijie2024willdeacon
authored andcommitted
arm64: irq: set the correct node for VMAP stack
In current code, init_irq_stacks() will call cpu_to_node(). The cpu_to_node() depends on percpu "numa_node" which is initialized in: arch_call_rest_init() --> rest_init() -- kernel_init() --> kernel_init_freeable() --> smp_prepare_cpus() But init_irq_stacks() is called in init_IRQ() which is before arch_call_rest_init(). So in init_irq_stacks(), the cpu_to_node() does not work, it always return 0. In NUMA, it makes the node 1 cpu accesses the IRQ stack which is in the node 0. This patch fixes it by: 1.) export the early_cpu_to_node(), and use it in the init_irq_stacks(). 2.) change init_irq_stacks() to __init function. Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Huang Shijie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 2cc14f5 commit 75b5e0b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

arch/arm64/kernel/irq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/vmalloc.h>
2323
#include <asm/daifflags.h>
2424
#include <asm/exception.h>
25+
#include <asm/numa.h>
2526
#include <asm/softirq_stack.h>
2627
#include <asm/stacktrace.h>
2728
#include <asm/vmap_stack.h>
@@ -51,13 +52,13 @@ static void init_irq_scs(void)
5152
}
5253

5354
#ifdef CONFIG_VMAP_STACK
54-
static void init_irq_stacks(void)
55+
static void __init init_irq_stacks(void)
5556
{
5657
int cpu;
5758
unsigned long *p;
5859

5960
for_each_possible_cpu(cpu) {
60-
p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, cpu_to_node(cpu));
61+
p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, early_cpu_to_node(cpu));
6162
per_cpu(irq_stack_ptr, cpu) = p;
6263
}
6364
}

drivers/base/arch_numa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void __init early_map_cpu_to_node(unsigned int cpu, int nid)
144144
unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
145145
EXPORT_SYMBOL(__per_cpu_offset);
146146

147-
static int __init early_cpu_to_node(int cpu)
147+
int __init early_cpu_to_node(int cpu)
148148
{
149149
return cpu_to_node_map[cpu];
150150
}

include/asm-generic/numa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int __init numa_add_memblk(int nodeid, u64 start, u64 end);
3535
void __init numa_set_distance(int from, int to, int distance);
3636
void __init numa_free_distance(void);
3737
void __init early_map_cpu_to_node(unsigned int cpu, int nid);
38+
int __init early_cpu_to_node(int cpu);
3839
void numa_store_cpu_info(unsigned int cpu);
3940
void numa_add_cpu(unsigned int cpu);
4041
void numa_remove_cpu(unsigned int cpu);
@@ -46,6 +47,7 @@ static inline void numa_add_cpu(unsigned int cpu) { }
4647
static inline void numa_remove_cpu(unsigned int cpu) { }
4748
static inline void arch_numa_init(void) { }
4849
static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { }
50+
static inline int early_cpu_to_node(int cpu) { return 0; }
4951

5052
#endif /* CONFIG_NUMA */
5153

0 commit comments

Comments
 (0)