Merge branch 'audit.b10' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[firefly-linux-kernel-4.4.55.git] / mm / sparse.c
index 72079b538e2dac74c136bcebfa47bca7dceb0daa..d7c32de99ee8c49d0e850a06084d5efe508a7625 100644 (file)
  */
 #ifdef CONFIG_SPARSEMEM_EXTREME
 struct mem_section *mem_section[NR_SECTION_ROOTS]
-       ____cacheline_maxaligned_in_smp;
+       ____cacheline_internodealigned_in_smp;
 #else
 struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
-       ____cacheline_maxaligned_in_smp;
+       ____cacheline_internodealigned_in_smp;
 #endif
 EXPORT_SYMBOL(mem_section);
 
@@ -32,7 +32,10 @@ static struct mem_section *sparse_index_alloc(int nid)
        unsigned long array_size = SECTIONS_PER_ROOT *
                                   sizeof(struct mem_section);
 
-       section = alloc_bootmem_node(NODE_DATA(nid), array_size);
+       if (system_state == SYSTEM_RUNNING)
+               section = kmalloc_node(array_size, GFP_KERNEL, nid);
+       else
+               section = alloc_bootmem_node(NODE_DATA(nid), array_size);
 
        if (section)
                memset(section, 0, array_size);
@@ -281,9 +284,9 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
 
        ret = sparse_init_one_section(ms, section_nr, memmap);
 
-       if (ret <= 0)
-               __kfree_section_memmap(memmap, nr_pages);
 out:
        pgdat_resize_unlock(pgdat, &flags);
+       if (ret <= 0)
+               __kfree_section_memmap(memmap, nr_pages);
        return ret;
 }