diff options
author | Jiang Liu <jiang.liu@huawei.com> | 2012-07-31 19:43:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-31 21:42:44 -0400 |
commit | 08dff7b7d629807dbb1f398c68dd9cd58dd657a1 (patch) | |
tree | 4cbd0e4aa0b04f4089509ecf1042007cd57d0e5f /mm/memory_hotplug.c | |
parent | 9adb62a5df9c0fbef7b4665919329f73a34651ed (diff) |
mm/hotplug: correctly add new zone to all other nodes' zone lists
When online_pages() is called to add new memory to an empty zone, it
rebuilds all zone lists by calling build_all_zonelists(). But there's a
bug which prevents the new zone to be added to other nodes' zone lists.
online_pages() {
build_all_zonelists()
.....
node_set_state(zone_to_nid(zone), N_HIGH_MEMORY)
}
Here the node of the zone is put into N_HIGH_MEMORY state after calling
build_all_zonelists(), but build_all_zonelists() only adds zones from
nodes in N_HIGH_MEMORY state to the fallback zone lists.
build_all_zonelists()
->__build_all_zonelists()
->build_zonelists()
->find_next_best_node()
->for_each_node_state(n, N_HIGH_MEMORY)
So memory in the new zone will never be used by other nodes, and it may
cause strange behavor when system is under memory pressure. So put node
into N_HIGH_MEMORY state before calling build_all_zonelists().
Signed-off-by: Jianguo Wu <wujianguo@huawei.com>
Signed-off-by: Jiang Liu <liuj97@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Keping Chen <chenkeping@huawei.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 | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b8731040b9f9..597d371329d3 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -512,19 +512,20 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages) | |||
512 | 512 | ||
513 | zone->present_pages += onlined_pages; | 513 | zone->present_pages += onlined_pages; |
514 | zone->zone_pgdat->node_present_pages += onlined_pages; | 514 | zone->zone_pgdat->node_present_pages += onlined_pages; |
515 | if (need_zonelists_rebuild) | 515 | if (onlined_pages) { |
516 | build_all_zonelists(NULL, zone); | 516 | node_set_state(zone_to_nid(zone), N_HIGH_MEMORY); |
517 | else | 517 | if (need_zonelists_rebuild) |
518 | zone_pcp_update(zone); | 518 | build_all_zonelists(NULL, zone); |
519 | else | ||
520 | zone_pcp_update(zone); | ||
521 | } | ||
519 | 522 | ||
520 | mutex_unlock(&zonelists_mutex); | 523 | mutex_unlock(&zonelists_mutex); |
521 | 524 | ||
522 | init_per_zone_wmark_min(); | 525 | init_per_zone_wmark_min(); |
523 | 526 | ||
524 | if (onlined_pages) { | 527 | if (onlined_pages) |
525 | kswapd_run(zone_to_nid(zone)); | 528 | kswapd_run(zone_to_nid(zone)); |
526 | node_set_state(zone_to_nid(zone), N_HIGH_MEMORY); | ||
527 | } | ||
528 | 529 | ||
529 | vm_total_pages = nr_free_pagecache_pages(); | 530 | vm_total_pages = nr_free_pagecache_pages(); |
530 | 531 | ||