Commit 6dcd73d7 authored by Wen Congyang's avatar Wen Congyang Committed by Linus Torvalds

memory-hotplug: allocate zone's pcp before onlining pages

We use __free_page() to put a page to buddy system when onlining pages.
__free_page() will store NR_FREE_PAGES in zone's pcp.vm_stat_diff, so we
should allocate zone's pcp before onlining pages, otherwise we will lose
some free pages.

[ make zone_pcp_reset independent of MEMORY_HOTREMOVE]
Signed-off-by: default avatarWen Congyang <>
Cc: David Rientjes <>
Cc: Jiang Liu <>
Cc: Len Brown <>
Cc: Benjamin Herrenschmidt <>
Cc: Paul Mackerras <>
Cc: Christoph Lameter <>
Cc: Minchan Kim <>
Cc: KOSAKI Motohiro <>
Cc: Yasuaki Ishimatsu <>
Cc: Dave Hansen <>
Cc: Mel Gorman <>
Signed-off-by: default avatarMichal Hocko <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 3ac19f8e
......@@ -498,12 +498,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
* So, zonelist must be updated after online.
if (!populated_zone(zone))
if (!populated_zone(zone)) {
need_zonelists_rebuild = 1;
build_all_zonelists(NULL, zone);
ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages,
if (ret) {
if (need_zonelists_rebuild)
printk(KERN_DEBUG "online_pages [mem %#010llx-%#010llx] failed\n",
(unsigned long long) pfn << PAGE_SHIFT,
......@@ -519,7 +523,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
if (onlined_pages) {
node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
if (need_zonelists_rebuild)
build_all_zonelists(NULL, zone);
build_all_zonelists(NULL, NULL);
......@@ -5983,7 +5983,6 @@ void __meminit zone_pcp_update(struct zone *zone)
void zone_pcp_reset(struct zone *zone)
unsigned long flags;
......@@ -6003,6 +6002,7 @@ void zone_pcp_reset(struct zone *zone)
* All pages in the range must be isolated before calling this.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment