linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: rppt@kernel.org, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone
Date: Wed, 22 May 2024 07:29:59 +0000	[thread overview]
Message-ID: <20240522072959.23741-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20240522072959.23741-1-richard.weiyang@gmail.com>

Since we always populate low zones, it is not necessary to count
nr_initialised for them. Let's move the last zone check ahead to skip
the nr_initialised reset.

Assume low zones counts for 4G, this change may reduce 1M times
comparison of prev_end_pfn and end_pfn.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/mm_init.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 2dfb87841fdb..4cc627b4ebfe 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -676,6 +676,11 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
 
 	if (early_page_ext_enabled())
 		return false;
+
+	/* Always populate low zones for address-constrained allocations */
+	if (end_pfn < pgdat_end_pfn(NODE_DATA(nid)))
+		return false;
+
 	/*
 	 * prev_end_pfn static that contains the end of previous zone
 	 * No need to protect because called very early in boot before smp_init.
@@ -685,10 +690,6 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
 		nr_initialised = 0;
 	}
 
-	/* Always populate low zones for address-constrained allocations */
-	if (end_pfn < pgdat_end_pfn(NODE_DATA(nid)))
-		return false;
-
 	if (NODE_DATA(nid)->first_deferred_pfn != ULONG_MAX)
 		return true;
 	/*
-- 
2.34.1



  reply	other threads:[~2024-05-22  7:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22  7:29 [PATCH 1/2] mm/mm_init.c: use memblock_region_memory_base_pfn() to get startpfn Wei Yang
2024-05-22  7:29 ` Wei Yang [this message]
2024-05-23 14:53   ` [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone Mike Rapoport
2024-05-24  0:59     ` Wei Yang

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=20240522072959.23741-2-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@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