Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755313AbZKIVsL (ORCPT ); Mon, 9 Nov 2009 16:48:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754925AbZKIVsK (ORCPT ); Mon, 9 Nov 2009 16:48:10 -0500 Received: from sh.osrg.net ([192.16.179.4]:57516 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754831AbZKIVsJ convert rfc822-to-8bit (ORCPT ); Mon, 9 Nov 2009 16:48:09 -0500 Date: Tue, 10 Nov 2009 06:47:05 +0900 To: penberg@cs.helsinki.fi Cc: fujita.tomonori@lab.ntt.co.jp, linux-kernel@vger.kernel.org, chrisw@sous-sol.org, dwmw2@infradead.org, joerg.roedel@amd.com, mingo@elte.hu, akpm@linux-foundation.org, hannes@cmpxchg.org, tj@kernel.org Subject: Re: [PATCH 07/10] bootmem: add free_bootmem_late From: FUJITA Tomonori In-Reply-To: <84144f020911091221n1d025d9bv3915751bf474b47a@mail.gmail.com> References: <1256712464-21472-8-git-send-email-fujita.tomonori@lab.ntt.co.jp> <84144f020911091213j393a9761pe13808d1e091e169@mail.gmail.com> <84144f020911091221n1d025d9bv3915751bf474b47a@mail.gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Message-Id: <20091110064650H.fujita.tomonori@lab.ntt.co.jp> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Tue, 10 Nov 2009 06:47:07 +0900 (JST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2946 Lines: 92 On Mon, 9 Nov 2009 22:21:48 +0200 Pekka Enberg wrote: > On Mon, Nov 9, 2009 at 10:13 PM, Pekka Enberg wrote: > >> ? ? ? ?for (cursor = start; cursor < end; cursor += BITS_PER_LONG) { > >> - ? ? ? ? ? ? ? unsigned long idx, vec; > >> + ? ? ? ? ? ? ? unsigned long vec; > >> > >> - ? ? ? ? ? ? ? idx = cursor - start; > >> - ? ? ? ? ? ? ? vec = ~map[idx / BITS_PER_LONG]; > >> + ? ? ? ? ? ? ? if (map) { > >> + ? ? ? ? ? ? ? ? ? ? ? unsigned long idx = cursor - start; > >> + ? ? ? ? ? ? ? ? ? ? ? vec = ~map[idx / BITS_PER_LONG]; > >> + ? ? ? ? ? ? ? } else { > >> + ? ? ? ? ? ? ? ? ? ? ? if (end - cursor >= BITS_PER_LONG) > >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? vec = ~0UL; > > > > Why do we need the above? > > OK, I figured that out. I'm not sure why you want to play tricks with > "vec" when you could just add a new helper that calls > __free_pages_bootmem() for the full contiguous page range. I'm not sure why Chris did that, but yeah, I think that it's cleaner to leave free_all_bootmem_core alone. There is just one user of free_bootmem_late to free some memory so how about the following simple patch instead 7/10? diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index dd97fb8..b10ec49 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h @@ -53,6 +53,7 @@ extern void free_bootmem_node(pg_data_t *pgdat, unsigned long addr, unsigned long size); extern void free_bootmem(unsigned long addr, unsigned long size); +extern void free_bootmem_late(unsigned long addr, unsigned long size); /* * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE, diff --git a/mm/bootmem.c b/mm/bootmem.c index 94ef2e7..b0b393b 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -196,6 +196,30 @@ static unsigned long __init free_bootmem_pages(unsigned long start, return count; } +/* + * free_bootmem_late - free bootmem pages directly to page allocator + * @addr: starting address of the range + * @size: size of the range in bytes + * + * This is only useful when the bootmem allocator has already been torn + * down, but we are still initializing the system. Pages are given directly + * to the page allocator, no bootmem metadata is updated because it is gone. + */ +void __init free_bootmem_late(unsigned long addr, unsigned long size) +{ + unsigned long cursor, end; + + kmemleak_free_part(__va(addr), size); + + cursor = PFN_UP(addr); + end = PFN_DOWN(addr + size); + + for (; cursor < end; cursor++) { + __free_pages_bootmem(pfn_to_page(cursor), 0); + totalram_pages++; + } +} + static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) { struct page *page; -- 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/