From: David Hildenbrand <david@redhat.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Zi Yan <ziy@nvidia.com>,
Matthew Brost <matthew.brost@intel.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
Rakie Kim <rakie.kim@sk.com>, Byungchul Park <byungchul@sk.com>,
Gregory Price <gourry@gourry.net>,
Ying Huang <ying.huang@linux.alibaba.com>,
Alistair Popple <apopple@nvidia.com>,
Pedro Falcato <pfalcato@suse.de>, Rik van Riel <riel@surriel.com>,
Harry Yoo <harry.yoo@oracle.com>
Subject: Re: [PATCH v1 3/4] mm: split folio_pte_batch() into folio_pte_batch() and folio_pte_batch_ext()
Date: Mon, 30 Jun 2025 11:19:13 +0200 [thread overview]
Message-ID: <9185c50a-1427-45fc-941d-e9796cea4831@redhat.com> (raw)
In-Reply-To: <ec53b2ad-9c1b-4039-b59e-905e1853c1a0@lucifer.local>
On 27.06.25 20:48, Lorenzo Stoakes wrote:
> 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?
We want to always generate a function that uses as little runtime checks
as possible. Essentially, optimize out the "flags" as much as possible.
In case of folio_pte_batch(), where we won't use any flags, any checks
will be optimized out by the compiler.
So we get a single, specialized, non-inlined function.
>
>>
>> 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@redhat.com>
>
> 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)
Obviously, I had that as part of the development, and decided against it
at some point. :)
Yeah, _ext() is not common in MM yet, in contrast to other subsystems.
The only user is indeed page_ext. On arm we seem to have set_pte_ext().
But it's really "page_ext", that's the problematic part, not "_ext" :P
No strong opinion, but I tend to dislike here "__", because often it
means "internal helper you're not supposed to used", which isn't really
the case here.
E.g.,
alloc_frozen_pages() -> alloc_frozen_pages_noprof() ->
__alloc_frozen_pages_noprof()
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-06-30 9:19 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 11:55 [PATCH v1 0/4] mm: folio_pte_batch() improvements David Hildenbrand
2025-06-27 11:55 ` [PATCH v1 1/4] mm: convert FPB_IGNORE_* into FPB_HONOR_* David Hildenbrand
2025-06-27 13:40 ` Lance Yang
2025-06-27 16:28 ` Lorenzo Stoakes
2025-06-27 16:30 ` David Hildenbrand
2025-06-27 16:33 ` Lorenzo Stoakes
2025-06-29 8:59 ` Mike Rapoport
2025-06-30 13:47 ` David Hildenbrand
2025-06-28 3:37 ` Dev Jain
2025-06-28 21:00 ` David Hildenbrand
2025-06-30 3:34 ` Dev Jain
2025-06-30 9:04 ` Ryan Roberts
2025-06-30 9:08 ` David Hildenbrand
2025-06-30 9:18 ` Ryan Roberts
2025-06-30 9:24 ` David Hildenbrand
2025-06-30 10:57 ` Ryan Roberts
2025-06-30 11:01 ` David Hildenbrand
2025-06-30 14:35 ` Zi Yan
2025-07-02 8:31 ` Oscar Salvador
2025-06-27 11:55 ` [PATCH v1 2/4] mm: smaller folio_pte_batch() improvements David Hildenbrand
2025-06-27 13:58 ` Lance Yang
2025-06-27 16:51 ` Lorenzo Stoakes
2025-06-27 17:02 ` David Hildenbrand
2025-06-27 18:39 ` Lorenzo Stoakes
2025-06-30 17:40 ` Zi Yan
2025-07-02 8:42 ` Oscar Salvador
2025-07-02 8:48 ` David Hildenbrand
2025-07-02 8:51 ` Lorenzo Stoakes
2025-07-02 9:00 ` David Hildenbrand
2025-07-02 9:08 ` Lorenzo Stoakes
2025-07-02 9:11 ` David Hildenbrand
2025-06-27 11:55 ` [PATCH v1 3/4] mm: split folio_pte_batch() into folio_pte_batch() and folio_pte_batch_ext() David Hildenbrand
2025-06-27 14:19 ` Lance Yang
2025-06-27 15:09 ` David Hildenbrand
2025-06-27 15:45 ` Lance Yang
2025-06-27 18:48 ` Lorenzo Stoakes
2025-06-30 9:19 ` David Hildenbrand [this message]
2025-06-30 10:41 ` Lorenzo Stoakes
2025-06-30 10:54 ` David Hildenbrand
2025-06-30 17:45 ` Zi Yan
2025-07-02 9:02 ` Oscar Salvador
2025-07-02 9:05 ` David Hildenbrand
2025-07-02 9:07 ` Oscar Salvador
2025-07-02 9:11 ` David Hildenbrand
2025-07-02 9:09 ` Oscar Salvador
2025-06-27 11:55 ` [PATCH v1 4/4] mm: remove boolean output parameters from folio_pte_batch_ext() David Hildenbrand
2025-06-27 14:34 ` Lance Yang
2025-06-27 15:11 ` David Hildenbrand
2025-06-27 15:40 ` Lance Yang
2025-06-27 19:04 ` Lorenzo Stoakes
2025-06-30 9:32 ` David Hildenbrand
2025-06-30 11:08 ` Lorenzo Stoakes
2025-06-30 11:16 ` David Hildenbrand
2025-06-30 11:18 ` Lorenzo Stoakes
2025-06-30 11:21 ` David Hildenbrand
2025-06-30 17:59 ` Zi Yan
2025-07-02 9:08 ` David Hildenbrand
2025-07-02 9:09 ` David Hildenbrand
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=9185c50a-1427-45fc-941d-e9796cea4831@redhat.com \
--to=david@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=gourry@gourry.net \
--cc=harry.yoo@oracle.com \
--cc=jannh@google.com \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=rakie.kim@sk.com \
--cc=riel@surriel.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.com \
/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