[PATCH v1 0/4] mm: folio_pte_batch() improvements

From: David Hildenbrand
Date: Fri Jun 27 2025 - 07:56:09 EST


Ever since we added folio_pte_batch() for fork() + munmap() purposes,
a lot more users appeared (and more are being proposed), and more
functionality was added.

Most of the users only need basic functionality, and could benefit from
a non-inlined version.

So let's clean up folio_pte_batch() and split it into a basic
folio_pte_batch() (no flags) and a more advanced folio_pte_batch_ext().
Using either variant will now look much cleaner.

This series will likely conflict with some changes in some
(old+new) folio_pte_batch() users, but conflicts should be trivial to
resolve.

Tested on x86-64. Cross-compile tested.

Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>
Cc: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
Cc: Vlastimil Babka <vbabka@xxxxxxx>
Cc: Jann Horn <jannh@xxxxxxxxxx>
Cc: Mike Rapoport <rppt@xxxxxxxxxx>
Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Zi Yan <ziy@xxxxxxxxxx>
Cc: Matthew Brost <matthew.brost@xxxxxxxxx>
Cc: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>
Cc: Rakie Kim <rakie.kim@xxxxxx>
Cc: Byungchul Park <byungchul@xxxxxx>
Cc: Gregory Price <gourry@xxxxxxxxxx>
Cc: Ying Huang <ying.huang@xxxxxxxxxxxxxxxxx>
Cc: Alistair Popple <apopple@xxxxxxxxxx>
Cc: Pedro Falcato <pfalcato@xxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxxx>
Cc: Harry Yoo <harry.yoo@xxxxxxxxxx>

David Hildenbrand (4):
mm: convert FPB_IGNORE_* into FPB_HONOR_*
mm: smaller folio_pte_batch() improvements
mm: split folio_pte_batch() into folio_pte_batch() and
folio_pte_batch_ext()
mm: remove boolean output parameters from folio_pte_batch_ext()

mm/internal.h | 110 +++++++++++++++++++++++++++----------------------
mm/madvise.c | 27 +++---------
mm/memory.c | 21 ++++------
mm/mempolicy.c | 5 +--
mm/mlock.c | 4 +-
mm/mremap.c | 4 +-
mm/rmap.c | 4 +-
mm/util.c | 29 +++++++++++++
8 files changed, 105 insertions(+), 99 deletions(-)


base-commit: 0051fec1d393b659ffee707f869f8ffe4d1632e2
--
2.49.0