mm: introduce new field "managed_pages" to struct zone
[~shefty/rdma-dev.git] / mm / memory_hotplug.c
index c6cd8b51542467437b93a64297cb17284c71c5dc..b7c93ca896d6de8179697b908132b0d34dffb479 100644 (file)
@@ -106,6 +106,7 @@ static void get_page_bootmem(unsigned long info,  struct page *page,
 void __ref put_page_bootmem(struct page *page)
 {
        unsigned long type;
+       static DEFINE_MUTEX(ppb_lock);
 
        type = (unsigned long) page->lru.next;
        BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
@@ -115,7 +116,14 @@ void __ref put_page_bootmem(struct page *page)
                ClearPagePrivate(page);
                set_page_private(page, 0);
                INIT_LIST_HEAD(&page->lru);
+
+               /*
+                * Please refer to comment for __free_pages_bootmem()
+                * for why we serialize here.
+                */
+               mutex_lock(&ppb_lock);
                __free_pages_bootmem(page, 0);
+               mutex_unlock(&ppb_lock);
        }
 
 }
@@ -748,6 +756,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
                return ret;
        }
 
+       zone->managed_pages += onlined_pages;
        zone->present_pages += onlined_pages;
        zone->zone_pgdat->node_present_pages += onlined_pages;
        if (onlined_pages) {
@@ -1321,6 +1330,7 @@ repeat:
        /* reset pagetype flags and makes migrate type to be MOVABLE */
        undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
        /* removal success */
+       zone->managed_pages -= offlined_pages;
        zone->present_pages -= offlined_pages;
        zone->zone_pgdat->node_present_pages -= offlined_pages;
        totalram_pages -= offlined_pages;