Skip to contentSkip to conversation

mm-stop-making-sparsemem_vmemmap-user-selectable.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Sep 21, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: stop making SPARSEMEM_VMEMMAP user-selectable
has been removed from the -mm tree. Its filename was
mm-stop-making-sparsemem_vmemmap-user-selectable.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: David Hildenbrand <[email protected]>
Subject: mm: stop making SPARSEMEM_VMEMMAP user-selectable
Date: Mon, 1 Sep 2025 17:03:22 +0200

Patch series "mm: remove nth_page()", v2.

As discussed recently with Linus, nth_page() is just nasty and we would like to remove it.

To recap, the reason we currently need nth_page() within a folio is because on some kernel configs (SPARSEMEM without SPARSEMEM_VMEMMAP), the memmap is allocated per memory section.

While buddy allocations cannot cross memory section boundaries, hugetlb and dax folios can.

So crossing a memory section means that "page++" could do the wrong thing. Instead, nth_page() on these problematic configs always goes from page->pfn, to the go from (++pfn)->page, which is rather nasty.

Likely, many people have no idea when nth_page() is required and when it might be dropped.

We refer to such problematic PFN ranges and "non-contiguous pages". If we only deal with "contiguous pages", there is not need for nth_page().

Besides that "obvious" folio case, we might end up using nth_page() within CMA allocations (again, could span memory sections), and in one corner case (kfence) when processing memblock allocations (again, could span memory sections).

So let's handle all that, add sanity checks, and remove nth_page().

Patch #1 -> #5 : stop making SPARSEMEM_VMEMMAP user-selectable + cleanups
Patch #6 -> #13 : disallow folios to have non-contiguous pages Patch #14 -> #20 : remove nth_page() usage within folios
Patch #22 : disallow CMA allocations of non-contiguous pages
Patch #23 -> #33 : sanity+check + remove nth_page() usage within SG entry
Patch #34 : sanity-check + remove nth_page() usage in
unpin_user_page_range_dirty_lock()

Patch #35        : remove nth_page() in kfence
Patch #36        : adjust stale comment regarding nth_page
Patch #37        : mm: remove nth_page()

A lot of this is inspired from the discussion at [1] between Linus, Jason and me, so cudos to them.

This patch (of 37):

In an ideal world, we wouldn't have to deal with SPARSEMEM without SPARSEMEM_VMEMMAP, but in particular for 32bit SPARSEMEM_VMEMMAP is considered too costly and consequently not supported.

However, if an architecture does support SPARSEMEM with SPARSEMEM_VMEMMAP, let's forbid the user to disable VMEMMAP: just like we already do for arm64, s390 and x86.

So if SPARSEMEM_VMEMMAP is supported, don't allow to use SPARSEMEM without SPARSEMEM_VMEMMAP.

This implies that the option to not use SPARSEMEM_VMEMMAP will now be gone for loongarch, powerpc, riscv and sparc. All architectures only enable SPARSEMEM_VMEMMAP with 64bit support, so there should not really be a big downside to using the VMEMMAP (quite the contrary).

This is a preparation for not supporting

(1) folio sizes that exceed a single memory section

(2) CMA allocations of non-contiguous page ranges

in SPARSEMEM without SPARSEMEM_VMEMMAP configs, whereby we want to limit possible impact as much as possible (e.g., gigantic hugetlb page allocations suddenly fails).

Cc Huacai Chen <[email protected]>
Cc WANG Xuerui <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Nicholas Piggin <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Albert Ou <[email protected]>
Cc Alexandre Ghiti <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Andreas Larsson <[email protected]>
Cc Alexander Gordeev <[email protected]>
Cc Alexander Potapenko <[email protected]>
Cc Alexandru Elisei <[email protected]>
Cc Alex Dubov <[email protected]>
Cc Alex Willamson <[email protected]>
Cc Bart van Assche <[email protected]>
Cc Borislav Betkov <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Brett Creeley <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christoph Lameter (Ampere) <[email protected]>
Cc Damien Le Maol <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Dmitriy Vyukov <[email protected]>
Cc Doug Gilbert <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Inki Dae <[email protected]>
Cc James Bottomley <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Jason A. Donenfeld <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Jesper Nilsson <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc John Hubbard <[email protected]>
Cc Jonas Lahtinen <[email protected]>
Cc Kevin Tian <[email protected]>
Cc Lars Persson <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Marco Elver <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc Maxim Levitky <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Muchun Song <[email protected]>
Cc Niklas Cassel <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Pavel Begunkov <[email protected]>
Cc Peter Xu <[email protected]>
Cc Robin Murohy <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Shameerali Kolothum Thodi <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Thomas Gleinxer <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Will Deacon <[email protected]>
Cc Yishai Hadas <[email protected]>

---

 mm/Kconfig |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/Kconfig renamed from mm/Kconfig~mm-stop-making-sparsemem_vmemmap-user-selectable +1 -2
@@ -412,9 +412,8 @@ config SPARSEMEM_VMEMMAP_ENABLE
 	bool
 
 config SPARSEMEM_VMEMMAP
-	bool "Sparse Memory virtual memmap"
+	def_bool y
 	depends on SPARSEMEM && SPARSEMEM_VMEMMAP_ENABLE
-	default y
 	help
 	  SPARSEMEM_VMEMMAP uses a virtually mapped memmap to optimise
 	  pfn_to_page and page_to_pfn operations.  This is the most

_

Patches currently in -mm which might be from [email protected] are