提交 c7991b0b 编写于 作者: R Rafael J. Wysocki 提交者: Greg Kroah-Hartman

driver core / cpu: Check if NUMA node is valid before bringing CPU up

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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: NToshi Kani <toshi.kani@hp.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 910f5c7c
...@@ -43,11 +43,14 @@ static int __ref cpu_subsys_online(struct device *dev) ...@@ -43,11 +43,14 @@ static int __ref cpu_subsys_online(struct device *dev)
struct cpu *cpu = container_of(dev, struct cpu, dev); struct cpu *cpu = container_of(dev, struct cpu, dev);
int cpuid = dev->id; int cpuid = dev->id;
int from_nid, to_nid; int from_nid, to_nid;
int ret; int ret = -ENODEV;
cpu_hotplug_driver_lock(); cpu_hotplug_driver_lock();
from_nid = cpu_to_node(cpuid); from_nid = cpu_to_node(cpuid);
if (from_nid == NUMA_NO_NODE)
goto out;
ret = cpu_up(cpuid); ret = cpu_up(cpuid);
/* /*
* When hot adding memory to memoryless node and enabling a cpu * When hot adding memory to memoryless node and enabling a cpu
...@@ -57,6 +60,7 @@ static int __ref cpu_subsys_online(struct device *dev) ...@@ -57,6 +60,7 @@ static int __ref cpu_subsys_online(struct device *dev)
if (from_nid != to_nid) if (from_nid != to_nid)
change_cpu_under_node(cpu, from_nid, to_nid); change_cpu_under_node(cpu, from_nid, to_nid);
out:
cpu_hotplug_driver_unlock(); cpu_hotplug_driver_unlock();
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册