]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memory-hotplug: allocate zone's pcp before onlining pages
authorWen Congyang <wency@cn.fujitsu.com>
Thu, 25 Oct 2012 01:14:51 +0000 (12:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 31 Oct 2012 05:49:47 +0000 (16:49 +1100)
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.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Jiang Liu <liuj97@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory_hotplug.c

index 72f4fef2b7283cdabb071b189ec7a5900e68059a..5c8ad6dcd18f4a4e95883cbd0fe4dc86960f1cf1 100644 (file)
@@ -505,12 +505,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
         * So, zonelist must be updated after online.
         */
        mutex_lock(&zonelists_mutex);
-       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,
                online_pages_range);
        if (ret) {
+               if (need_zonelists_rebuild)
+                       zone_pcp_reset(zone);
                mutex_unlock(&zonelists_mutex);
                printk(KERN_DEBUG "online_pages [mem %#010llx-%#010llx] failed\n",
                       (unsigned long long) pfn << PAGE_SHIFT,
@@ -525,9 +529,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
        zone->zone_pgdat->node_present_pages += onlined_pages;
        if (onlined_pages) {
                node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
-               if (need_zonelists_rebuild)
-                       build_all_zonelists(NULL, zone);
-               else
+               if (!need_zonelists_rebuild)
                        zone_pcp_update(zone);
        }