When CONFIG_HAVE_MEMORYLESS_NODES is enabled, cpu_to_node()/numa_node_id() may return a node without memory, and later cause system failure/panic when calling kmalloc_node() and friends with returned node id. So use cpu_to_mem()/numa_mem_id() instead to get the nearest node with memory for the/current cpu. If CONFIG_HAVE_MEMORYLESS_NODES is disabled, cpu_to_mem()/numa_mem_id() is the same as cpu_to_node()/numa_node_id(). Signed-off-by: Jiang Liu <jiang.liu@xxxxxxxxxxxxxxx> --- arch/x86/kernel/apic/io_apic.c | 10 +++++----- arch/x86/kernel/devicetree.c | 2 +- arch/x86/kernel/irq_32.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 81e08eff05ee..7cb3d58b11e8 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -204,7 +204,7 @@ int __init arch_early_irq_init(void) cfg = irq_cfgx; count = ARRAY_SIZE(irq_cfgx); - node = cpu_to_node(0); + node = cpu_to_mem(0); for (i = 0; i < count; i++) { irq_set_chip_data(i, &cfg[i]); @@ -1348,7 +1348,7 @@ static bool __init io_apic_pin_not_connected(int idx, int ioapic_idx, int pin) static void __init __io_apic_setup_irqs(unsigned int ioapic_idx) { - int idx, node = cpu_to_node(0); + int idx, node = cpu_to_mem(0); struct io_apic_irq_attr attr; unsigned int pin, irq; @@ -1394,7 +1394,7 @@ static void __init setup_IO_APIC_irqs(void) */ void setup_IO_APIC_irq_extra(u32 gsi) { - int ioapic_idx = 0, pin, idx, irq, node = cpu_to_node(0); + int ioapic_idx = 0, pin, idx, irq, node = cpu_to_mem(0); struct io_apic_irq_attr attr; /* @@ -2662,7 +2662,7 @@ int timer_through_8259 __initdata; static inline void __init check_timer(void) { struct irq_cfg *cfg = irq_get_chip_data(0); - int node = cpu_to_node(0); + int node = cpu_to_mem(0); int apic1, pin1, apic2, pin2; unsigned long flags; int no_pin1 = 0; @@ -3387,7 +3387,7 @@ int io_apic_set_pci_routing(struct device *dev, int irq, return -EINVAL; } - node = dev ? dev_to_node(dev) : cpu_to_node(0); + node = dev ? dev_to_node(dev) : cpu_to_mem(0); return io_apic_setup_irq_pin_once(irq, node, irq_attr); } diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 7db54b5d5f86..289762f4ea06 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -295,7 +295,7 @@ static int ioapic_xlate(struct irq_domain *domain, set_io_apic_irq_attr(&attr, idx, line, it->trigger, it->polarity); rc = io_apic_setup_irq_pin_once(irq_find_mapping(domain, line), - cpu_to_node(0), &attr); + cpu_to_mem(0), &attr); if (rc) return rc; diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c index 63ce838e5a54..425bb4b1110a 100644 --- a/arch/x86/kernel/irq_32.c +++ b/arch/x86/kernel/irq_32.c @@ -128,12 +128,12 @@ void irq_ctx_init(int cpu) if (per_cpu(hardirq_stack, cpu)) return; - irqstk = page_address(alloc_pages_node(cpu_to_node(cpu), + irqstk = page_address(alloc_pages_node(cpu_to_mem(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER)); per_cpu(hardirq_stack, cpu) = irqstk; - irqstk = page_address(alloc_pages_node(cpu_to_node(cpu), + irqstk = page_address(alloc_pages_node(cpu_to_mem(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER)); per_cpu(softirq_stack, cpu) = irqstk; -- 1.7.10.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>