From: Pekka Enberg <penberg@cs.helsinki.fi>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: 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
Date: Tue, 10 Nov 2009 10:05:52 +0200 [thread overview]
Message-ID: <4AF91EE0.9090906@cs.helsinki.fi> (raw)
In-Reply-To: <20091110064650H.fujita.tomonori@lab.ntt.co.jp>
FUJITA Tomonori wrote:
> On Mon, 9 Nov 2009 22:21:48 +0200
> Pekka Enberg <penberg@cs.helsinki.fi> wrote:
>
>> On Mon, Nov 9, 2009 at 10:13 PM, Pekka Enberg <penberg@cs.helsinki.fi> 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?
Looks good to me!
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
> 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;
>
>
next prev parent reply other threads:[~2009-11-10 8:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-28 6:47 [PATCH 0/10] x86: handle HW IOMMU initialization failure gracely FUJITA Tomonori
2009-10-28 6:47 ` [PATCH 01/10] Add iommu_init to x86_init_ops FUJITA Tomonori
2009-11-09 20:02 ` Pekka Enberg
2009-11-09 20:11 ` FUJITA Tomonori
2009-11-10 4:45 ` Ingo Molnar
2009-10-28 6:47 ` [PATCH 02/10] Calgary: convert detect_calgary to use iommu_init hook FUJITA Tomonori
2009-10-28 13:38 ` Muli Ben-Yehuda
2009-10-28 6:47 ` [PATCH 03/10] GART: convert gart_iommu_hole_init " FUJITA Tomonori
2009-10-28 6:47 ` [PATCH 04/10] amd_iommu: convert amd_iommu_detect " FUJITA Tomonori
2009-10-28 6:47 ` [PATCH 05/10] intel-iommu: convert detect_intel_iommu " FUJITA Tomonori
2009-10-28 6:47 ` [PATCH 06/10] bootmem: refactor free_all_bootmem_core FUJITA Tomonori
2009-10-28 7:34 ` Ingo Molnar
2009-10-28 7:36 ` Ingo Molnar
2009-10-28 6:47 ` [PATCH 07/10] bootmem: add free_bootmem_late FUJITA Tomonori
2009-10-28 7:48 ` Ingo Molnar
2009-10-28 8:00 ` Tejun Heo
2009-10-28 11:38 ` Pekka Enberg
2009-10-28 12:12 ` Tejun Heo
2009-10-29 11:19 ` Pekka Enberg
2009-11-08 9:57 ` Ingo Molnar
2009-11-16 10:27 ` Joerg Roedel
2009-11-06 1:50 ` FUJITA Tomonori
2009-11-08 10:00 ` Ingo Molnar
2009-11-09 19:22 ` FUJITA Tomonori
2009-11-09 20:13 ` Pekka Enberg
2009-11-09 20:21 ` Pekka Enberg
2009-11-09 21:47 ` FUJITA Tomonori
2009-11-10 8:05 ` Pekka Enberg [this message]
2009-11-13 21:11 ` Chris Wright
2009-10-28 6:47 ` [PATCH 08/10] swiotlb: add swiotlb_free function FUJITA Tomonori
2009-10-28 6:47 ` [PATCH 09/10] swiotlb: export swiotlb_print_info FUJITA Tomonori
2009-10-28 6:47 ` [PATCH 10/10] x86: handle HW IOMMU initialization failure gracely FUJITA Tomonori
2009-10-28 13:21 ` [PATCH 0/10] " Joerg Roedel
2009-10-29 8:27 ` FUJITA Tomonori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AF91EE0.9090906@cs.helsinki.fi \
--to=penberg@cs.helsinki.fi \
--cc=akpm@linux-foundation.org \
--cc=chrisw@sous-sol.org \
--cc=dwmw2@infradead.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hannes@cmpxchg.org \
--cc=joerg.roedel@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox