From: Ingo Molnar <mingo@elte.hu>
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
Subject: Re: [PATCH 06/10] bootmem: refactor free_all_bootmem_core
Date: Wed, 28 Oct 2009 08:36:45 +0100 [thread overview]
Message-ID: <20091028073645.GB19402@elte.hu> (raw)
In-Reply-To: <1256712464-21472-7-git-send-email-fujita.tomonori@lab.ntt.co.jp>
* FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
> From: Chris Wright <chrisw@sous-sol.org>
>
> Move the loop that frees all bootmem pages back to page allocator into
> its own function. This should have not functional effect and allows the
> function to be reused later.
>
> Reviewed-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
> ---
> mm/bootmem.c | 61 +++++++++++++++++++++++++++++++++++++++-------------------
> 1 files changed, 41 insertions(+), 20 deletions(-)
>
> diff --git a/mm/bootmem.c b/mm/bootmem.c
> index 555d5d2..94ef2e7 100644
> --- a/mm/bootmem.c
> +++ b/mm/bootmem.c
> @@ -143,17 +143,22 @@ unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
> return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
> }
>
> -static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
> +/**
> + * free_bootmem_pages - frees bootmem pages to page allocator
> + * @start: start pfn
> + * @end: end pfn
> + * @map: bootmem bitmap of reserved pages
> + *
> + * This will free the pages in the range @start to @end, making them
> + * available to the page allocator. The @map will be used to skip
> + * reserved pages. Returns the count of pages freed.
> + */
> +static unsigned long __init free_bootmem_pages(unsigned long start,
> + unsigned long end,
> + unsigned long *map)
> {
> + unsigned long cursor, count = 0;
> int aligned;
> - struct page *page;
> - unsigned long start, end, pages, count = 0;
> -
> - if (!bdata->node_bootmem_map)
> - return 0;
> -
> - start = bdata->node_min_pfn;
> - end = bdata->node_low_pfn;
>
> /*
> * If the start is aligned to the machines wordsize, we might
> @@ -161,27 +166,25 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
> */
> aligned = !(start & (BITS_PER_LONG - 1));
>
> - bdebug("nid=%td start=%lx end=%lx aligned=%d\n",
> - bdata - bootmem_node_data, start, end, aligned);
> + for (cursor = start; cursor < end; cursor += BITS_PER_LONG) {
> + unsigned long idx, vec;
>
> - while (start < end) {
> - unsigned long *map, idx, vec;
> -
> - map = bdata->node_bootmem_map;
> - idx = start - bdata->node_min_pfn;
> + idx = cursor - start;
> vec = ~map[idx / BITS_PER_LONG];
>
> - if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) {
> + if (aligned && vec == ~0UL && cursor + BITS_PER_LONG < end) {
> int order = ilog2(BITS_PER_LONG);
>
> - __free_pages_bootmem(pfn_to_page(start), order);
> + __free_pages_bootmem(pfn_to_page(cursor), order);
> count += BITS_PER_LONG;
> } else {
> unsigned long off = 0;
>
> while (vec && off < BITS_PER_LONG) {
> if (vec & 1) {
> - page = pfn_to_page(start + off);
> + struct page *page;
> +
> + page = pfn_to_page(cursor + off);
> __free_pages_bootmem(page, 0);
> count++;
> }
> @@ -189,8 +192,26 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
> off++;
> }
> }
> - start += BITS_PER_LONG;
> }
> + return count;
> +}
> +
> +static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
> +{
> + struct page *page;
> + unsigned long start, end, *map, pages, count = 0;
> +
> + if (!bdata->node_bootmem_map)
> + return 0;
> +
> + start = bdata->node_min_pfn;
> + end = bdata->node_low_pfn;
> + map = bdata->node_bootmem_map;
> +
> + bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data,
> + start, end);
> +
> + count = free_bootmem_pages(start, end, map);
>
> page = virt_to_page(bdata->node_bootmem_map);
> pages = bdata->node_low_pfn - bdata->node_min_pfn;
Small nit: the initialization of count to 0 seems superfluous.
Ingo
next prev parent reply other threads:[~2009-10-28 7:37 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 [this message]
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
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=20091028073645.GB19402@elte.hu \
--to=mingo@elte.hu \
--cc=chrisw@sous-sol.org \
--cc=dwmw2@infradead.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=joerg.roedel@amd.com \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®