Patch "memblock: free allocated memblock_reserved_regions later" has been added to the 3.4-stable tree
This is a note to let you know that I've just added the patch titled
memblock: free allocated memblock_reserved_regions later
to the 3.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
memblock-free-allocated-memblock_reserved_regions-later.patch
and it can be found in the queue-3.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
29f6738609e40227dabcc63bfb3b84b3726a75bdMon Sep 17 00:00:00 2001
From: Yinghai Lu <[email protected]>
Date: Wed, 11 Jul 2012 14:02:56 -0700
Subject: memblock: free allocated memblock_reserved_regions later
From: Yinghai Lu <[email protected]>
commit 29f6738609e40227dabcc63bfb3b84b3726a75bd upstream.
memblock_free_reserved_regions() calls memblock_free(), but memblock_free() would double reserved.regions too, so we could free the old range for reserved.regions.
Also tj said there is another bug which could be related to this.
| I don't think we're saving any noticeable | amount by doing this "free - give it to page allocator - reserve | again" dancing. We should just allocate regions aligned to page | boundaries and free them later when memblock is no longer in use.
in that case, when DEBUG_PAGEALLOC, will get panic:
memblock_free: [0x0000102febc080-0x0000102febf080] memblock_free_reserved_regions+0x37/0x39 BUG: unable to handle kernel paging request at ffff88102febd948 IP: [<ffffffff836a5774>] __next_free_mem_range+0x9b/0x155 PGD 4826063 PUD cf67a067 PMD cf7fa067 PTE 800000102febd160 Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC CPU 0 Pid: 0, comm: swapper Not tainted 3.5.0-rc2-next-20120614-sasha #447 RIP: 0010:[<ffffffff836a5774>] [<ffffffff836a5774>] __next_free_mem_range+0x9b/0x155
See the discussion at https://lkml.org/lkml/2012/6/13/469
So try to allocate with PAGE_SIZE alignment and free it later.
--- include/linux/memblock.h | 4 --- mm/memblock.c | 51 +++++++++++++++++++++-------------------------- mm/nobootmem.c | 36 ++++++++++++++++++++------------- 3 files changed, 46 insertions(+), 45 deletions(-)
include/linux/memblock.h +1 -3
@@ -50,9 +50,7 @@ phys_addr_t memblock_find_in_range_node( phys_addr_t size, phys_addr_t align, int nid);phys_addr_t memblock_find_in_range (phys_addr_t start,phys_addr_t end,phys_addr_t size,phys_addr_t align); -int memblock_free_reserved_regions (void ); -int memblock_reserve_reserved_regions (void ); - +phys_addr_t get_allocated_memblock_reserved_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);
mm/memblock.c +23 -28
95 lines not on this page · raw message
mm/nobootmem.c +22 -14
@@ -105,27 +105,35 @@ static void __init __free_pages_memory(u__free_pages_bootmem (pfn_to_page (i),0 ); } +static unsigned long __init __free_memory_core (phys_addr_t start, +phys_addr_t end) +{ +unsigned long start_pfn =PFN_UP (start); + unsigned long end_pfn = min_t(unsigned long, +PFN_DOWN (end), max_low_pfn); + +if (start_pfn > end_pfn) +return 0 ; + +__free_pages_memory (start_pfn, end_pfn); + +return end_pfn - start_pfn; +} +unsigned long __init free_low_memory_core_early (int nodeid) {unsigned long count =0 ; -phys_addr_t start, end; +phys_addr_t start, end, size;u64 i; -/* free reserved array temporarily so that it's treated as free area */ -memblock_free_reserved_regions (); +for_each_free_mem_range (i,MAX_NUMNODES , &start, &end,NULL ) + count +=__free_memory_core (start, end); -for_each_free_mem_range (i,MAX_NUMNODES , &start, &end,NULL ) { -unsigned long start_pfn =PFN_UP (start); - unsigned long end_pfn = min_t(unsigned long, -PFN_DOWN (end), max_low_pfn); -if (start_pfn < end_pfn) { -__free_pages_memory (start_pfn, end_pfn); - count += end_pfn - start_pfn; - } - } +/* free range that is used for reserved array if we allocate it */ + size =get_allocated_memblock_reserved_regions_info (&start); +if (size) + count +=__free_memory_core (start, start + size); -/* put region array back? */ -memblock_reserve_reserved_regions ();return count; }
Patches currently in stable-queue which might be from [email protected] are
queue-3.4/memblock-free-allocated-memblock_reserved_regions-later.patch queue-3.4/mm-memblock-fix-overlapping-allocation-when-doubling-reserved-array.patch