Commit e13fe869 authored by Wen Congyang's avatar Wen Congyang Committed by Linus Torvalds

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.

[ numa_clear_node() and numa_set_node() can no longer be __cpuinit]
Signed-off-by: default avatarWen Congyang <>
Signed-off-by: default avatarTang 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: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 76bba142
......@@ -57,8 +57,8 @@ static inline int numa_cpu_node(int cpu)
extern void __cpuinit numa_set_node(int cpu, int node);
extern void __cpuinit numa_clear_node(int cpu);
extern void numa_set_node(int cpu, int node);
extern void numa_clear_node(int cpu);
extern void __init init_cpu_to_node(void);
extern void __cpuinit numa_add_cpu(int cpu);
extern void __cpuinit numa_remove_cpu(int cpu);
......@@ -78,7 +78,7 @@ EXPORT_SYMBOL(node_to_cpumask_map);
DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE);
void __cpuinit numa_set_node(int cpu, int node)
void numa_set_node(int cpu, int node)
int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map);
......@@ -101,7 +101,7 @@ void __cpuinit numa_set_node(int cpu, int node)
set_cpu_numa_node(cpu, node);
void __cpuinit numa_clear_node(int cpu)
void numa_clear_node(int cpu)
numa_set_node(cpu, NUMA_NO_NODE);
......@@ -1705,6 +1705,34 @@ static int check_cpu_on_node(void *data)
return 0;
static void unmap_cpu_on_node(void *data)
struct pglist_data *pgdat = data;
int cpu;
if (cpu_to_node(cpu) == pgdat->node_id)
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.
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)
if (stop_machine(check_cpu_on_node, pgdat, NULL))
if (stop_machine(check_and_unmap_cpu_on_node, pgdat, NULL))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment