]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - mm/memory_hotplug.c
mem-hotplug: avoid multiple zones sharing same boot strapping boot_pageset
[net-next-2.6.git] / mm / memory_hotplug.c
index 85eb4d342ac5010ccc0997be9a251d20cb82bb50..089cc97aed3c5506e22487e158106502c6dde666 100644 (file)
@@ -389,6 +389,11 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
        int nid;
        int ret;
        struct memory_notify arg;
+       /*
+        * mutex to protect zone->pageset when it's still shared
+        * in onlined_pages()
+        */
+       static DEFINE_MUTEX(zone_pageset_mutex);
 
        arg.start_pfn = pfn;
        arg.nr_pages = nr_pages;
@@ -415,12 +420,14 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
         * This means the page allocator ignores this zone.
         * So, zonelist must be updated after online.
         */
+       mutex_lock(&zone_pageset_mutex);
        if (!populated_zone(zone))
                need_zonelists_rebuild = 1;
 
        ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages,
                online_pages_range);
        if (ret) {
+               mutex_unlock(&zone_pageset_mutex);
                printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
                        nr_pages, pfn);
                memory_notify(MEM_CANCEL_ONLINE, &arg);
@@ -429,8 +436,12 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
 
        zone->present_pages += onlined_pages;
        zone->zone_pgdat->node_present_pages += onlined_pages;
+       if (need_zonelists_rebuild)
+               build_all_zonelists(zone);
+       else
+               zone_pcp_update(zone);
 
-       zone_pcp_update(zone);
+       mutex_unlock(&zone_pageset_mutex);
        setup_per_zone_wmarks();
        calculate_zone_inactive_ratio(zone);
        if (onlined_pages) {
@@ -438,10 +449,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
                node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
        }
 
-       if (need_zonelists_rebuild)
-               build_all_zonelists();
-       else
-               vm_total_pages = nr_free_pagecache_pages();
+       vm_total_pages = nr_free_pagecache_pages();
 
        writeback_set_ratelimit();