mm: free memblock.memory in free_all_bootmem
authorPhilipp Hachtmann <phacht@linux.vnet.ibm.com>
Thu, 23 Jan 2014 23:53:11 +0000 (15:53 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Jan 2014 00:36:51 +0000 (16:36 -0800)
When calling free_all_bootmem() the free areas under memblock's control
are released to the buddy allocator.  Additionally the reserved list is
freed if it was reallocated by memblock.  The same should apply for the
memory list.

Signed-off-by: Philipp Hachtmann <phacht@linux.vnet.ibm.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/memblock.h
mm/memblock.c
mm/nobootmem.c

index cd0274bebd4c8a7dc1f2412a58f0489c2d713865..1ef66360f0b092b751f430bf31ca693a8a85ed46 100644 (file)
@@ -61,6 +61,7 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
 phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
                                   phys_addr_t size, phys_addr_t align);
 phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
+phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
 void memblock_allow_resize(void);
 int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
 int memblock_add(phys_addr_t base, phys_addr_t size);
index 1c2ef2c7edabc635de699015e2984c21849e06a0..64ed2439cf7563b794858608b175a0b14cabac46 100644 (file)
@@ -291,6 +291,22 @@ phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
                          memblock.reserved.max);
 }
 
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
+
+phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
+                                       phys_addr_t *addr)
+{
+       if (memblock.memory.regions == memblock_memory_init_regions)
+               return 0;
+
+       *addr = __pa(memblock.memory.regions);
+
+       return PAGE_ALIGN(sizeof(struct memblock_region) *
+                         memblock.memory.max);
+}
+
+#endif
+
 /**
  * memblock_double_array - double the size of the memblock regions array
  * @type: memblock type of the regions array being doubled
index bb1a70cc97a7f165ebfbfd38c565c67acb8cb438..17c89023184f1e49f6a74415b5850851143f1099 100644 (file)
@@ -122,11 +122,19 @@ static unsigned long __init free_low_memory_core_early(void)
        for_each_free_mem_range(i, NUMA_NO_NODE, &start, &end, NULL)
                count += __free_memory_core(start, end);
 
-       /* free range that is used for reserved array if we allocate it */
+       /* Free memblock.reserved array if it was allocated */
        size = get_allocated_memblock_reserved_regions_info(&start);
        if (size)
                count += __free_memory_core(start, start + size);
 
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
+
+       /* Free memblock.memory array if it was allocated */
+       size = get_allocated_memblock_memory_regions_info(&start);
+       if (size)
+               count += __free_memory_core(start, start + size);
+#endif
+
        return count;
 }