linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: hannes@cmpxchg.org
Cc: linux-mm@kvack.org
Subject: Re: [PATCH 2/2] MM: check limit while deallocating bootmem node
Date: Sat, 28 Apr 2012 09:38:02 +0800	[thread overview]
Message-ID: <20120428013802.GA8061@shangw> (raw)
In-Reply-To: <1335498104-31900-2-git-send-email-shangw@linux.vnet.ibm.com>

Hi Johannes,

Could you take a look on this while you have available time?

Thanks,
Gavin

>For the particular bootmem node, the minimal and maximal PFN (
>Page Frame Number) have been traced in the instance of "struct
>bootmem_data_t". On current implementation, the maximal PFN isn't
>checked while deallocating a bunch (BITS_PER_LONG) of page frames.
>So the current implementation won't work if the maximal PFN isn't
>aligned with BITS_PER_LONG.
>
>The patch will check the maximal PFN of the given bootmem node.
>Also, we needn't check all the bits map when the starting PFN isn't
>BITS_PER_LONG aligned. Actually, we should start from the offset
>of the bits map, which indicated by the starting PFN.
>
>Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
>---
> mm/bootmem.c |   11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
>diff --git a/mm/bootmem.c b/mm/bootmem.c
>index 5a04536..ebac3ba 100644
>--- a/mm/bootmem.c
>+++ b/mm/bootmem.c
>@@ -194,16 +194,20 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
> 		 * BITS_PER_LONG block of pages in front of us, free
> 		 * it in one go.
> 		 */
>-		if (IS_ALIGNED(start, BITS_PER_LONG) && vec == ~0UL) {
>+		if (end - start >= BITS_PER_LONG &&
>+		    IS_ALIGNED(start, BITS_PER_LONG) &&
>+		    vec == ~0UL) {
> 			int order = ilog2(BITS_PER_LONG);
>
> 			__free_pages_bootmem(pfn_to_page(start), order);
> 			count += BITS_PER_LONG;
> 			start += BITS_PER_LONG;
> 		} else {
>-			unsigned long off = 0;
>+			unsigned long cursor = start;
>+			unsigned long off = cursor & (BITS_PER_LONG - 1);
>
>-			while (vec && off < BITS_PER_LONG) {
>+			vec >>= off;
>+			while (vec && off < BITS_PER_LONG && cursor < end) {
> 				if (vec & 1) {
> 					page = pfn_to_page(start + off);
> 					__free_pages_bootmem(page, 0);
>@@ -211,6 +215,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
> 				}
> 				vec >>= 1;
> 				off++;
>+				cursor++;
> 			}
> 			start = ALIGN(start + 1, BITS_PER_LONG);
> 		}
>-- 
>1.7.5.4
>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2012-04-28  1:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27  3:41 [PATCH 1/2] MM: fixup on addition to bootmem data list Gavin Shan
2012-04-27  3:41 ` [PATCH 2/2] MM: check limit while deallocating bootmem node Gavin Shan
2012-04-27 23:27   ` Johannes Weiner
2012-04-28  1:58     ` Gavin Shan
2012-04-28  1:38   ` Gavin Shan [this message]
2012-04-28  2:00     ` Gavin Shan
2012-05-09 21:25 ` [PATCH 1/2] MM: fixup on addition to bootmem data list Johannes Weiner
2012-05-10  1:02   ` Gavin Shan

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=20120428013802.GA8061@shangw \
    --to=shangw@linux.vnet.ibm.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).