Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757602AbaAHXbA (ORCPT ); Wed, 8 Jan 2014 18:31:00 -0500 Received: from mail-ie0-f182.google.com ([209.85.223.182]:49241 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757109AbaAHXa6 (ORCPT ); Wed, 8 Jan 2014 18:30:58 -0500 MIME-Version: 1.0 In-Reply-To: <20140108144213.4c1995b2@lilie> References: <1389107774-54978-1-git-send-email-phacht@linux.vnet.ibm.com> <1389107774-54978-3-git-send-email-phacht@linux.vnet.ibm.com> <52CCCF24.4080300@huawei.com> <20140108144213.4c1995b2@lilie> Date: Wed, 8 Jan 2014 15:30:57 -0800 X-Google-Sender-Auth: -xH8FafCMYblyLQ4IMglDqcHxJw Message-ID: Subject: Re: [PATCH 2/2] mm: free memblock.memory in free_all_bootmem From: Yinghai Lu To: Philipp Hachtmann Cc: Jianguo Wu , Andrew Morton , Jiang Liu , Linux Kernel Mailing List , Linux MM , Joonsoo Kim , Johannes Weiner , Tang Chen , Tejun Heo , Toshi Kani Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 8, 2014 at 5:42 AM, Philipp Hachtmann wrote: > Am Wed, 8 Jan 2014 12:08:04 +0800 > schrieb Jianguo Wu : > >> For some archs, like arm64, would use memblock.memory after system >> booting, so we can not simply released to the buddy allocator, maybe >> need !defined(CONFIG_ARCH_DISCARD_MEMBLOCK). > > Oh, I see. I have added some ifdefs to prevent memblock.memory from > being freed when CONFIG_ARCH_DISCARD_MEMBLOCK is not set. > > Here is a replacement for the patch. > > Kind regards > > Philipp > > From aca95bcb9d79388b68bf18e7bae4353259b6758f Mon Sep 17 00:00:00 2001 > From: Philipp Hachtmann > Date: Thu, 19 Dec 2013 15:53:46 +0100 > Subject: [PATCH 2/2] mm: free memblock.memory in free_all_bootmem > > 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 > --- > include/linux/memblock.h | 1 + > mm/memblock.c | 16 ++++++++++++++++ > mm/nobootmem.c | 10 +++++++++- > 3 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h > index 77c60e5..d174922 100644 > --- a/include/linux/memblock.h > +++ b/include/linux/memblock.h > @@ -52,6 +52,7 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end, > 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); > diff --git a/mm/memblock.c b/mm/memblock.c > index 53e477b..a78b2e9 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -271,6 +271,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 > diff --git a/mm/nobootmem.c b/mm/nobootmem.c > index 3a7e14d..63ff3f6 100644 > --- a/mm/nobootmem.c > +++ b/mm/nobootmem.c > @@ -122,11 +122,19 @@ static unsigned long __init free_low_memory_core_early(void) > for_each_free_mem_range(i, MAX_NUMNODES, &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; > } I sent similar before. http://www.gossamer-threads.com/lists/engine?do=post_attachment;postatt_id=49616;list=linux http://www.gossamer-threads.com/lists/linux/kernel/1556026?do=post_view_threaded#1556026 Also for arches that do not free memblock, do they still need to access memblock.reserved.regions ? Yinghai -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/