Re: [PATCH v1 3/4] mm: split folio_pte_batch() into folio_pte_batch() and folio_pte_batch_ext()

From: David Hildenbrand
Date: Mon Jun 30 2025 - 06:54:22 EST


On 30.06.25 12:41, Lorenzo Stoakes wrote:
On Mon, Jun 30, 2025 at 11:19:13AM +0200, David Hildenbrand wrote:
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.

I mean I suppose code bloat is a thing too. Would the compiler not also optimise
out checks if it were inlined though?

The compiler will optimize all (most) inlined variants, yes.

But we will end up creating the same optimized variant for each folio_pte_batch() user before this change.

And as Andrew put it

"And why the heck is folio_pte_batch() inlined? It's larger then my first hard disk" [1]

I should probably add a suggested-by + link to that discussion.

[1] https://lore.kernel.org/linux-mm/20250503182858.5a02729fcffd6d4723afcfc2@xxxxxxxxxxxxxxxxxxxx/

[...]


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.

Yeah, and of course we break this convention all over the place :)

Maybe folio_pte_batch_flags()?

Works for me as well.

--
Cheers,

David / dhildenb