linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: skseofh <skseofh@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org
Subject: [PATCH] mm/page_alloc:Check pfn valid once in every page blocks
Date: Sun, 28 Jun 2020 02:17:22 +0900	[thread overview]
Message-ID: <20200627171722.GA16398@roro-Lenovo-Y520-15IKBN> (raw)

Hi, all

Please check the patch below.
Thanks:)


No need to check validity for every pfn in [spfn, epfn).
---
 mm/page_alloc.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 174c849ba9f2..212460c9fe0f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6936,11 +6936,19 @@ void __init free_area_init_memoryless_node(int nid)
  */
 static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
 {
-	unsigned long pfn;
+	unsigned long pfn, block_pfn;
 	u64 pgcnt = 0;
+	bool in_block = 0;
+
+	block_pfn = ALIGN_DOWN(spfn, pageblock_nr_pages);
 
 	for (pfn = spfn; pfn < epfn; pfn++) {
-		if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
+		if (block_pfn != ALIGN_DOWN(pfn, pageblock_nr_pages)) {
+			block_pfn = ALIGN_DOWN(pfn, pageblock_nr_pages);
+			in_block = 0;
+		}
+
+		if (!in_block && !pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
 			pfn = ALIGN_DOWN(pfn, pageblock_nr_pages)
 				+ pageblock_nr_pages - 1;
 			continue;
@@ -6953,6 +6961,7 @@ static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
 		__init_single_page(pfn_to_page(pfn), pfn, 0, 0);
 		__SetPageReserved(pfn_to_page(pfn));
 		pgcnt++;
+		in_block = 1;
 	}
 
 	return pgcnt;
-- 
2.17.1



             reply	other threads:[~2020-06-27 17:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-27 17:17 skseofh [this message]
2020-06-27 17:46 ` Matthew Wilcox

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=20200627171722.GA16398@roro-Lenovo-Y520-15IKBN \
    --to=skseofh@gmail.com \
    --cc=akpm@linux-foundation.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