From: Wen Congyang Date: Wed, 20 Feb 2013 02:14:23 +0000 (+1100) Subject: cpu-hotplug,memory-hotplug: clear cpu_to_node() when offlining the node X-Git-Tag: next-20130220~1^2~516 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7a16edbd4b3c84856d5bc78d65e2db4085fc85dd;p=karo-tx-linux.git cpu-hotplug,memory-hotplug: clear cpu_to_node() when offlining the node When the node is offlined, there is no memory/cpu on the node. If a sleep task runs on a cpu of this node, it will be migrated to the cpu on the other node. So we can clear cpu-to-node mapping. Signed-off-by: Wen Congyang Signed-off-by: Tang Chen Cc: Yasuaki Ishimatsu Cc: David Rientjes Cc: Jiang Liu Cc: Minchan Kim Cc: KOSAKI Motohiro Cc: Mel Gorman Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Peter Zijlstra Signed-off-by: Andrew Morton --- diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index d4a9820edfc7..0653b97988fc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1705,6 +1705,34 @@ static int check_cpu_on_node(void *data) return 0; } +static void unmap_cpu_on_node(void *data) +{ +#ifdef CONFIG_ACPI_NUMA + struct pglist_data *pgdat = data; + int cpu; + + for_each_possible_cpu(cpu) + if (cpu_to_node(cpu) == pgdat->node_id) + numa_clear_node(cpu); +#endif +} + +static int check_and_unmap_cpu_on_node(void *data) +{ + int ret = check_cpu_on_node(data); + + if (ret) + return ret; + + /* + * the node will be offlined when we come here, so we can clear + * the cpu_to_node() now. + */ + + unmap_cpu_on_node(data); + return 0; +} + /* offline the node if all memory sections of this node are removed */ void try_offline_node(int nid) { @@ -1731,7 +1759,7 @@ void try_offline_node(int nid) return; } - if (stop_machine(check_cpu_on_node, pgdat, NULL)) + if (stop_machine(check_and_unmap_cpu_on_node, pgdat, NULL)) return; /*