]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - mm/sparse.c
memory hotplug: allocate usemap on the section with pgdat
[net-next-2.6.git] / mm / sparse.c
index 5398d48c360a96efafe69a7e5ad2f590c7693a43..08f053218ee8202aede708b139f83002f6deceb0 100644 (file)
@@ -249,11 +249,22 @@ static unsigned long *__kmalloc_section_usemap(void)
 
 static unsigned long *__init sparse_early_usemap_alloc(unsigned long pnum)
 {
-       unsigned long *usemap;
+       unsigned long *usemap, section_nr;
        struct mem_section *ms = __nr_to_section(pnum);
        int nid = sparse_early_nid(ms);
+       struct pglist_data *pgdat = NODE_DATA(nid);
 
-       usemap = alloc_bootmem_node(NODE_DATA(nid), usemap_size());
+       /*
+        * Usemap's page can't be freed until freeing other sections
+        * which use it. And, Pgdat has same feature.
+        * If section A has pgdat and section B has usemap for other
+        * sections (includes section A), both sections can't be removed,
+        * because there is the dependency each other.
+        * To solve above issue, this collects all usemap on the same section
+        * which has pgdat.
+        */
+       section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);
+       usemap = alloc_bootmem_section(usemap_size(), section_nr);
        if (usemap)
                return usemap;