diff options
author | Tang Chen <tangchen@cn.fujitsu.com> | 2014-11-13 18:19:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-11-13 19:17:06 -0500 |
commit | 0bd854200873894a76f32603ff2c4c988ad6b5b5 (patch) | |
tree | 60100ead27da07ef7f454727d00483c07a9257e5 /mm/memory_hotplug.c | |
parent | f784a3f19613901ca4539a5b0eed3bdc700e6ee7 (diff) |
mem-hotplug: reset node present pages when hot-adding a new pgdat
When memory is hot-added, all the memory is in offline state. So clear
all zones' present_pages because they will be updated in online_pages()
and offline_pages(). Otherwise, /proc/zoneinfo will corrupt:
When the memory of node2 is offline:
# cat /proc/zoneinfo
......
Node 2, zone Movable
......
spanned 8388608
present 8388608
managed 0
When we online memory on node2:
# cat /proc/zoneinfo
......
Node 2, zone Movable
......
spanned 8388608
present 16777216
managed 8388608
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: <stable@vger.kernel.org> [3.16+]
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 | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index c5f7fe199a60..1bf4807cb21e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -1067,6 +1067,16 @@ out: | |||
1067 | } | 1067 | } |
1068 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ | 1068 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ |
1069 | 1069 | ||
1070 | static void reset_node_present_pages(pg_data_t *pgdat) | ||
1071 | { | ||
1072 | struct zone *z; | ||
1073 | |||
1074 | for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) | ||
1075 | z->present_pages = 0; | ||
1076 | |||
1077 | pgdat->node_present_pages = 0; | ||
1078 | } | ||
1079 | |||
1070 | /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ | 1080 | /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ |
1071 | static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) | 1081 | static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) |
1072 | { | 1082 | { |
@@ -1105,6 +1115,13 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) | |||
1105 | */ | 1115 | */ |
1106 | reset_node_managed_pages(pgdat); | 1116 | reset_node_managed_pages(pgdat); |
1107 | 1117 | ||
1118 | /* | ||
1119 | * When memory is hot-added, all the memory is in offline state. So | ||
1120 | * clear all zones' present_pages because they will be updated in | ||
1121 | * online_pages() and offline_pages(). | ||
1122 | */ | ||
1123 | reset_node_present_pages(pgdat); | ||
1124 | |||
1108 | return pgdat; | 1125 | return pgdat; |
1109 | } | 1126 | } |
1110 | 1127 | ||