On Fri, Jun 27, 2025 at 01:55:09PM +0200, David Hildenbrand wrote:
Many users (including upcoming ones) don't really need the flags etc,
and can live with a function call.
So let's provide a basic, non-inlined folio_pte_batch().
Hm, but why non-inlined, when it invokes an inlined function? Seems odd no?
In zap_present_ptes(), where we care about performance, the compiler
already seem to generate a call to a common inlined folio_pte_batch()
variant, shared with fork() code. So calling the new non-inlined variant
should not make a difference.
While at it, drop the "addr" parameter that is unused.
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
Other than the query above + nit on name below, this is really nice!
---
mm/internal.h | 11 ++++++++---
mm/madvise.c | 4 ++--
mm/memory.c | 6 ++----
mm/mempolicy.c | 3 +--
mm/mlock.c | 3 +--
mm/mremap.c | 3 +--
mm/rmap.c | 3 +--
mm/util.c | 29 +++++++++++++++++++++++++++++
8 files changed, 45 insertions(+), 17 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index ca6590c6d9eab..6000b683f68ee 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -218,9 +218,8 @@ static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags)
}
/**
- * folio_pte_batch - detect a PTE batch for a large folio
+ * folio_pte_batch_ext - detect a PTE batch for a large folio
* @folio: The large folio to detect a PTE batch for.
- * @addr: The user virtual address the first page is mapped at.
* @ptep: Page table pointer for the first entry.
* @pte: Page table entry for the first page.
* @max_nr: The maximum number of table entries to consider.
@@ -243,9 +242,12 @@ static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags)
* must be limited by the caller so scanning cannot exceed a single VMA and
* a single page table.
*
+ * This function will be inlined to optimize based on the input parameters;
+ * consider using folio_pte_batch() instead if applicable.
+ *
* Return: the number of table entries in the batch.
*/
-static inline unsigned int folio_pte_batch(struct folio *folio, unsigned long addr,
+static inline unsigned int folio_pte_batch_ext(struct folio *folio,
pte_t *ptep, pte_t pte, unsigned int max_nr, fpb_t flags,
bool *any_writable, bool *any_young, bool *any_dirty)
Sorry this is really really annoying feedback :P but _ext() makes me think of
page_ext and ugh :))
Wonder if __folio_pte_batch() is better?
This is obviously, not a big deal (TM)