mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Haifeng Xu <haifeng.xu@shopee.com>
To: rppt@kernel.org
Cc: mhocko@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Haifeng Xu <haifeng.xu@shopee.com>
Subject: [PATCH 2/2] mm/mm_init.c: do not calculate memmap and reserved pages for empty zone
Date: Thu,  1 Jun 2023 06:35:36 +0000	[thread overview]
Message-ID: <20230601063536.26882-2-haifeng.xu@shopee.com> (raw)

For empty zone, it's unnecessary to account for pages used by memmap.
Also, the pages reserved in dma zone can be ignored.

Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
---
 mm/mm_init.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 232efac9a929..b82718d596c3 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1543,6 +1543,13 @@ static void __init free_area_init_core(struct pglist_data *pgdat)
 		size = zone->spanned_pages;
 		freesize = zone->present_pages;
 
+		if (!size) {
+			nr_kernel_pages += 0;
+			nr_all_pages += 0;
+			zone_init_internals(zone, j, nid, 0);
+			continue;
+		}
+
 		/*
 		 * Adjust freesize so that it accounts for how much memory
 		 * is used by this zone for memmap. This affects the watermark
@@ -1579,10 +1586,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat)
 		 * And all highmem pages will be managed by the buddy system.
 		 */
 		zone_init_internals(zone, j, nid, freesize);
-
-		if (!size)
-			continue;
-
 		setup_usemap(zone);
 		init_currently_empty_zone(zone, zone->zone_start_pfn, size);
 	}
-- 
2.25.1


             reply	other threads:[~2023-06-01  6:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01  6:35 Haifeng Xu [this message]
2023-06-01 16:35 ` Mike Rapoport

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=20230601063536.26882-2-haifeng.xu@shopee.com \
    --to=haifeng.xu@shopee.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.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

all inboxes | Powered by JetHome®