From 77f9a542c8b62499643cc56ca1c6a3df3d47c994 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Wed, 20 Feb 2013 13:14:22 +1100 Subject: [PATCH] memory-hotplug: export the function try_offline_node() try_offline_node() will be needed in the tristate drivers/acpi/processor_driver.c. The node will be offlined when all memory/cpu on the node have been hotremoved. So we need the function try_offline_node() in cpu-hotplug path. If the memory-hotplug is disabled, and cpu-hotplug is enabled 1. no memory no the node we don't online the node, and cpu's node is the nearest node. 2. the node contains some memory the node has been onlined, and cpu's node is still needed to migrate the sleep task on the cpu to the same node. So we do nothing in try_offline_node() in this case. 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 Cc: Len Brown Signed-off-by: Andrew Morton --- include/linux/memory_hotplug.h | 2 ++ mm/memory_hotplug.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 69903ccf549e..0b2878e34d1e 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -193,6 +193,7 @@ extern void get_page_bootmem(unsigned long ingo, struct page *page, void lock_memory_hotplug(void); void unlock_memory_hotplug(void); +extern void try_offline_node(int nid); #else /* ! CONFIG_MEMORY_HOTPLUG */ /* @@ -227,6 +228,7 @@ static inline void register_page_bootmem_info_node(struct pglist_data *pgdat) static inline void lock_memory_hotplug(void) {} static inline void unlock_memory_hotplug(void) {} +static inline void try_offline_node(int nid) {} #endif /* ! CONFIG_MEMORY_HOTPLUG */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 559e4409cf90..d4a9820edfc7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1706,7 +1706,7 @@ static int check_cpu_on_node(void *data) } /* offline the node if all memory sections of this node are removed */ -static void try_offline_node(int nid) +void try_offline_node(int nid) { pg_data_t *pgdat = NODE_DATA(nid); unsigned long start_pfn = pgdat->node_start_pfn; @@ -1762,6 +1762,7 @@ static void try_offline_node(int nid) */ memset(pgdat, 0, sizeof(*pgdat)); } +EXPORT_SYMBOL(try_offline_node); int __ref remove_memory(int nid, u64 start, u64 size) { -- 2.39.5