Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] treewide: remove unnecessary invalid range checks in memblock iteration loops
@ 2026-06-29 16:37 Sang-Heon Jeon
  2026-06-29 16:37 ` [PATCH v2 1/8] arm64: mm: remove unreachable invalid range check in kasan_init_shadow() Sang-Heon Jeon
  2026-06-29 16:37 ` [PATCH v2 5/8] ARM: remove unreachable invalid range check in kasan_init() Sang-Heon Jeon
  0 siblings, 2 replies; 3+ messages in thread
From: Sang-Heon Jeon @ 2026-06-29 16:37 UTC (permalink / raw)
  To: rppt, Albert Ou, Andrew Morton, Andrey Ryabinin, Catalin Marinas,
	Huacai Chen, Madhavan Srinivasan, Michael Ellerman, Muchun Song,
	Oscar Salvador, Palmer Dabbelt, Paul Walmsley, Russell King,
	Will Deacon
  Cc: linux-mm, Sang-Heon Jeon, Alexander Potapenko, Alexandre Ghiti,
	Andrey Konovalov, Christophe Leroy (CS GROUP), David Hildenbrand,
	Dmitry Vyukov, kasan-dev, linux-arm-kernel, linux-kernel,
	linuxppc-dev, linux-riscv, loongarch, Nicholas Piggin,
	Vincenzo Frascino, WANG Xuerui

The memblock API guarantees that for_each_mem_range() and
for_each_mem_pfn_range() never return an invalid range, meaning start is
always less than end.

Several memblock callers still have unnecessary invalid range checks in
their loop bodies, so remove them.

Patches 1-6 cover for_each_mem_range() callers. memblock never stores a
zero-size region, so the range it returns always has start < end. Some
callers apply __va() or __phys_to_virt() before comparing, but these keep
start < end too, so the check is unreachable.

Patches 7-8 cover for_each_mem_pfn_range() callers. __next_mem_pfn_range()
skips any region that contains no whole page, so it only ever returns
start_pfn < end_pfn and the check is unnecessary.

For reference, commit 36ca7f4be809 ("arm64: mm: Remove bogus stop
condition from map_mem() loop") did a similar cleanup in arm64 map_mem().

All these checks are in different trees, so I split the change into one
patch per arch/subsystem. The patches are independent and can be applied
separately.

---
Changes from v1 [1]
- Add review-by, tested-by tags from v1
- Add missing simliar patches(5,6) to patch series
- Change base to rppt/for-next

[1] https://lore.kernel.org/all/20260621145919.1453-1-ekffu200098@gmail.com/
---

Sang-Heon Jeon (8):
  arm64: mm: remove unreachable invalid range check in
    kasan_init_shadow()
  LoongArch: remove unreachable invalid range check in kasan_init()
  riscv: remove unreachable invalid range check in
    create_linear_mapping_page_table()
  riscv: remove unreachable invalid range check in kasan_init()
  ARM: remove unreachable invalid range check in kasan_init()
  powerpc64/kasan: Remove unreachable invalid range check in
    kasan_init_phys_region()
  mm: remove unnecessary empty range check in
    early_calculate_totalpages()
  mm/hugetlb: remove unnecessary empty range check in
    hugetlb_bootmem_set_nodes()

 arch/arm/mm/kasan_init.c               | 6 ------
 arch/arm64/mm/kasan_init.c             | 3 ---
 arch/loongarch/mm/kasan_init.c         | 3 ---
 arch/powerpc/mm/kasan/init_book3e_64.c | 3 ---
 arch/powerpc/mm/kasan/init_book3s_64.c | 3 ---
 arch/riscv/mm/init.c                   | 2 --
 arch/riscv/mm/kasan_init.c             | 3 ---
 mm/hugetlb.c                           | 3 +--
 mm/mm_init.c                           | 3 +--
 9 files changed, 2 insertions(+), 27 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-29 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 16:37 [PATCH v2 0/8] treewide: remove unnecessary invalid range checks in memblock iteration loops Sang-Heon Jeon
2026-06-29 16:37 ` [PATCH v2 1/8] arm64: mm: remove unreachable invalid range check in kasan_init_shadow() Sang-Heon Jeon
2026-06-29 16:37 ` [PATCH v2 5/8] ARM: remove unreachable invalid range check in kasan_init() Sang-Heon Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox