[lkml]   [2013]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] driver core / cpu: Check if NUMA node is valid before bringing CPU up
From: Rafael J. Wysocki <>

There is a potential race condition between cpu_subsys_online()
and either acpi_processor_remove() or remove_memory() that execute
try_offline_node(). Namely, it is possible that cpu_subsys_online()
will run right after the CPUs NUMA node has been put offline and
cpu_to_node() executed by it will return NUMA_NO_NODE (-1). In
that case the CPU is gone and it doesn't make sense to call cpu_up()
for it, so make cpu_subsys_online() return -ENODEV then.

Signed-off-by: Rafael J. Wysocki <>
Acked-by: Toshi Kani <>

Hi Greg,

Can you please kindly queue up this one for 3.12?

I've added the Toshi's ACK as he said it looked good to him. :-)


drivers/base/cpu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/base/cpu.c
--- linux-pm.orig/drivers/base/cpu.c
+++ linux-pm/drivers/base/cpu.c
@@ -43,11 +43,14 @@ static int __ref cpu_subsys_online(struc
struct cpu *cpu = container_of(dev, struct cpu, dev);
int cpuid = dev->id;
int from_nid, to_nid;
- int ret;
+ int ret = -ENODEV;


from_nid = cpu_to_node(cpuid);
+ if (from_nid == NUMA_NO_NODE)
+ goto out;
ret = cpu_up(cpuid);
* When hot adding memory to memoryless node and enabling a cpu
@@ -57,6 +60,7 @@ static int __ref cpu_subsys_online(struc
if (from_nid != to_nid)
change_cpu_under_node(cpu, from_nid, to_nid);

+ out:
return ret;

 \ /
  Last update: 2013-08-13 03:21    [W:0.055 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site