Re: [PATCH 8/8] mm/gup: batch contiguous same-folio PTEs into one refcount grab

From: Rik van Riel

Date: Tue Nov 03 2026 - 12:43:56 EST


On Tue, 2026-11-03 at 09:35 +0100, David Hildenbrand (Arm) wrote:
> On 11/2/26 20:30, Rik van Riel wrote:
> >
> > +/*
> > + * Return how many PTEs map consecutive pages of the same folio
> > and can be
> > + * committed as one run. Always at least 1.
> > + *
> > + * The write-fault and unshare checks in gup_lookup_pte() are per
> > PTE, but a
> > + * writable run needs no repeat: a writable anon page is
> > exclusive. A read-only
> > + * run under FOLL_WRITE or FOLL_PIN does need the per-page check,
> > so it stays
> > + * one page at a time.
>
> That's a clear indication that this needs more work.
>
> I'll try to get to it soon and see how it could be done in a cleaner
> way, likely
> it should be based on top of the gup-fast series where we will have
> helpers to
> check for required unsharing of multiple PTEs.

I'm all for sharing the same helpers.

How would you like to sequence things?

Do you prefer to merge both series separately,
and then get a follow-up series that merges
the helper functions?

Would you like Yeoreum Yun and me to combine
the series, merge the helper functions beforehand,
and then send you one larger, combined series?

I have spent enough time in gup.c that I would
be happy to get rid of some more of that code.

--
All Rights Reversed.