Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sang-Heon Jeon <ekffu200098@gmail.com>
To: rppt@kernel.org, Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Sang-Heon Jeon <ekffu200098@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 7/8] mm: remove unnecessary empty range check in early_calculate_totalpages()
Date: Wed,  1 Jul 2026 00:04:12 +0900	[thread overview]
Message-ID: <20260630150413.1718632-8-ekffu200098@gmail.com> (raw)
In-Reply-To: <20260630150413.1718632-1-ekffu200098@gmail.com>

early_calculate_totalpages() iterates the memory ranges with
for_each_mem_pfn_range() and calls node_set_state(nid, N_MEMORY) only when
end_pfn - start_pfn is non-zero. for_each_mem_pfn_range() never returns an
empty range, so start_pfn < end_pfn always.

Therefore the check is unnecessary, so remove it.

No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 mm/mm_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 0f64909e8d20..17498a13eb99 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -332,8 +332,7 @@ static unsigned long __init early_calculate_totalpages(void)
 		unsigned long pages = end_pfn - start_pfn;
 
 		totalpages += pages;
-		if (pages)
-			node_set_state(nid, N_MEMORY);
+		node_set_state(nid, N_MEMORY);
 	}
 	return totalpages;
 }
-- 
2.43.0



  parent reply	other threads:[~2026-06-30 15:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 15:04 [PATCH v3 0/8] treewide: remove unnecessary invalid range checks in memblock iteration loops Sang-Heon Jeon
2026-06-30 15:04 ` [PATCH v3 1/8] arm64: mm: remove unreachable invalid range check in kasan_init_shadow() Sang-Heon Jeon
2026-06-30 15:04 ` [PATCH v3 2/8] LoongArch: remove unreachable invalid range check in kasan_init() Sang-Heon Jeon
2026-06-30 15:04 ` [PATCH v3 3/8] riscv: remove unreachable invalid range check in create_linear_mapping_page_table() Sang-Heon Jeon
2026-06-30 15:04 ` [PATCH v3 4/8] riscv: remove unreachable invalid range check in kasan_init() Sang-Heon Jeon
2026-06-30 15:04 ` [PATCH v3 5/8] ARM: " Sang-Heon Jeon
2026-06-30 15:04 ` [PATCH v3 6/8] powerpc64/kasan: Remove unreachable invalid range check in kasan_init_phys_region() Sang-Heon Jeon
2026-06-30 15:04 ` Sang-Heon Jeon [this message]
2026-06-30 15:04 ` [PATCH v3 8/8] mm/hugetlb: remove unnecessary empty range check in hugetlb_bootmem_set_nodes() Sang-Heon Jeon

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=20260630150413.1718632-8-ekffu200098@gmail.com \
    --to=ekffu200098@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.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