diff options
author | Wen Congyang <wency@cn.fujitsu.com> | 2013-02-22 19:33:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:13 -0500 |
commit | d822b86a99e8d2b7ebbe3aba099288354287a885 (patch) | |
tree | 2f2785f5fb7b55c0ed682e8bed5e3b729f9c4f5a /mm/memory_hotplug.c | |
parent | 60a5a19e7419ba0bc22ed01b3285e8940b42944c (diff) |
memory-hotplug: free node_data when a node is offlined
We call hotadd_new_pgdat() to allocate memory to store node_data. So we
should free it when removing a node.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Jiang Liu <jiang.liu@huawei.com>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Wu Jianguo <wujianguo@huawei.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory_hotplug.c')
-rw-r--r-- | mm/memory_hotplug.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index aea6374f435a..3409134ff20a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -1700,9 +1700,12 @@ static int check_cpu_on_node(void *data) | |||
1700 | /* offline the node if all memory sections of this node are removed */ | 1700 | /* offline the node if all memory sections of this node are removed */ |
1701 | static void try_offline_node(int nid) | 1701 | static void try_offline_node(int nid) |
1702 | { | 1702 | { |
1703 | unsigned long start_pfn = NODE_DATA(nid)->node_start_pfn; | 1703 | pg_data_t *pgdat = NODE_DATA(nid); |
1704 | unsigned long end_pfn = start_pfn + NODE_DATA(nid)->node_spanned_pages; | 1704 | unsigned long start_pfn = pgdat->node_start_pfn; |
1705 | unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; | ||
1705 | unsigned long pfn; | 1706 | unsigned long pfn; |
1707 | struct page *pgdat_page = virt_to_page(pgdat); | ||
1708 | int i; | ||
1706 | 1709 | ||
1707 | for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { | 1710 | for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { |
1708 | unsigned long section_nr = pfn_to_section_nr(pfn); | 1711 | unsigned long section_nr = pfn_to_section_nr(pfn); |
@@ -1720,7 +1723,7 @@ static void try_offline_node(int nid) | |||
1720 | return; | 1723 | return; |
1721 | } | 1724 | } |
1722 | 1725 | ||
1723 | if (stop_machine(check_cpu_on_node, NODE_DATA(nid), NULL)) | 1726 | if (stop_machine(check_cpu_on_node, pgdat, NULL)) |
1724 | return; | 1727 | return; |
1725 | 1728 | ||
1726 | /* | 1729 | /* |
@@ -1729,6 +1732,27 @@ static void try_offline_node(int nid) | |||
1729 | */ | 1732 | */ |
1730 | node_set_offline(nid); | 1733 | node_set_offline(nid); |
1731 | unregister_one_node(nid); | 1734 | unregister_one_node(nid); |
1735 | |||
1736 | if (!PageSlab(pgdat_page) && !PageCompound(pgdat_page)) | ||
1737 | /* node data is allocated from boot memory */ | ||
1738 | return; | ||
1739 | |||
1740 | /* free waittable in each zone */ | ||
1741 | for (i = 0; i < MAX_NR_ZONES; i++) { | ||
1742 | struct zone *zone = pgdat->node_zones + i; | ||
1743 | |||
1744 | if (zone->wait_table) | ||
1745 | vfree(zone->wait_table); | ||
1746 | } | ||
1747 | |||
1748 | /* | ||
1749 | * Since there is no way to guarentee the address of pgdat/zone is not | ||
1750 | * on stack of any kernel threads or used by other kernel objects | ||
1751 | * without reference counting or other symchronizing method, do not | ||
1752 | * reset node_data and free pgdat here. Just reset it to 0 and reuse | ||
1753 | * the memory when the node is online again. | ||
1754 | */ | ||
1755 | memset(pgdat, 0, sizeof(*pgdat)); | ||
1732 | } | 1756 | } |
1733 | 1757 | ||
1734 | int __ref remove_memory(int nid, u64 start, u64 size) | 1758 | int __ref remove_memory(int nid, u64 start, u64 size) |