[RFC PATCH 15/23 V2] memory_hotplug: fix missing nodemask management

Lai Jiangshan laijs at cn.fujitsu.com
Thu Aug 2 02:53:03 UTC 2012


Currently memory_hotplug only manages the node_states[N_HIGH_MEMORY],
it forgot to manage node_states[N_NORMAL_MEMORY]. fix it.

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 Documentation/memory-hotplug.txt |    2 +-
 mm/memory_hotplug.c              |   23 +++++++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
index 6d0c251..89f21b2 100644
--- a/Documentation/memory-hotplug.txt
+++ b/Documentation/memory-hotplug.txt
@@ -382,7 +382,7 @@ struct memory_notify {
 
 start_pfn is start_pfn of online/offline memory.
 nr_pages is # of pages of online/offline memory.
-status_change_nid is set node id when N_HIGH_MEMORY of nodemask is (will be)
+status_change_nid is set node id when N_MEMORY of nodemask is (will be)
 set/clear. It means a new(memoryless) node gets new memory by online and a
 node loses all memory. If this is -1, then nodemask status is not changed.
 If status_changed_nid >= 0, callback should create/discard structures for the
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 427bb29..c44b39e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -522,8 +522,18 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
 	init_per_zone_wmark_min();
 
 	if (onlined_pages) {
+		enum zone_type zoneid = zone_idx(zone);
+
 		kswapd_run(zone_to_nid(zone));
-		node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
+
+		node_set_state(nid, N_MEMORY);
+		if (zoneid <= ZONE_NORMAL && N_NORMAL_MEMORY != N_MEMORY)
+			node_set_state(nid, N_NORMAL_MEMORY);
+#ifdef CONFIG_HIGMEM
+		if (zoneid <= ZONE_HIGHMEM && N_HIGH_MEMORY != N_MEMORY)
+			node_set_state(nid, N_HIGH_MEMORY);
+#endif
+
 	}
 
 	vm_total_pages = nr_free_pagecache_pages();
@@ -966,7 +976,16 @@ repeat:
 	init_per_zone_wmark_min();
 
 	if (!node_present_pages(node)) {
-		node_clear_state(node, N_HIGH_MEMORY);
+		enum zone_type zoneid = zone_idx(zone);
+
+		node_clear_state(node, N_MEMORY);
+		if (zoneid <= ZONE_NORMAL && N_NORMAL_MEMORY != N_MEMORY)
+			node_clear_state(node, N_NORMAL_MEMORY);
+#ifdef CONFIG_HIGMEM
+		if (zoneid <= ZONE_HIGHMEM && N_HIGH_MEMORY != N_MEMORY)
+			node_clear_state(node, N_HIGH_MEMORY);
+#endif
+
 		kswapd_stop(node);
 	}
 
-- 
1.7.1



More information about the Containers mailing list