mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Yuan-Hao Hsu <aa9736195201@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand	 <david@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard	 <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Lorenzo Stoakes	 <ljs@kernel.org>,
	liam@infradead.org, Vlastimil Babka <vbabka@kernel.org>,
	 Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	 Aristeu Rozanski	 <aris@ruivo.org>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/gup: batch PTE-mapped large folios in gup_fast_pte_range()
Date: Mon, 12 Oct 2026 13:58:50 -0400	[thread overview]
Message-ID: <ff62aeaeb5ced49640c959c047b2e9f320f5c10f.camel@surriel.com> (raw)
In-Reply-To: <20261010195202.689-1-aa9736195201@gmail.com>

On Sun, 2026-10-11 at 03:52 +0800, Yuan-Hao Hsu wrote:
> On Wed, 07 Oct 2026 06:47:06 -0400, Rik van Riel wrote:
> > Since this is lockless, the PTEs could change under
> > us between when we walk them in folio_pte_batch_flags()
> > and the batched try_grab_folio().
> > 
> > Is that race condition safe, or do we need to re-check
> > afterward that:
> > 1) the ptes still point at the same folio, and/or
> > 2) the folio still spans the entire range, and was
> >    not split before we grabbed the refcount?
> 
> It is safe, because the batch only runs after the first page of the
> run has gone through the unchanged per-page path: the folio reference
> is already held (and for FOLL_PIN the _pincount already raised, with
> the smp_mb__after_atomic() in try_grab_folio_fast()) before any of
> the other ptes is read.
> 
> 2) With that reference held the folio cannot be split:

You are right. The page tables can still be remapped
to point at something else after gup_fast_pte_range()
grabs a reference to the folio, but that can happen
no matter what precautions we take inside gup_fast,
because it can happen after gup_fast has returned.

I have no other concerns, so feel free to add my:

Reviewed-by: Rik van Riel <riel@surriel.com>


Could I convince you to take a look through my
earlier series to make regular GUP go faster?

If there are any issues left in that, I would
like to fix them before the maintainers get
around to reviewing that series:

https://lore.kernel.org/r/20260811025157.1632867-1-riel@surriel.com/

-- 
All Rights Reversed.

  reply	other threads:[~2026-10-12 17:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  8:37 Yuan-Hao Hsu
2026-09-17  8:42 ` David Hildenbrand (Arm)
2026-09-17  8:43   ` David Hildenbrand (Arm)
2026-09-17  9:01     ` Yuan-Hao Hsu
2026-10-07 10:07   ` Rik van Riel
2026-10-07 10:14     ` David Hildenbrand (Arm)
2026-10-07 10:47 ` Rik van Riel
2026-10-10 19:52   ` Yuan-Hao Hsu
2026-10-12 17:58     ` Rik van Riel [this message]
2026-10-12 19:05       ` David Hildenbrand (Arm)

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=ff62aeaeb5ced49640c959c047b2e9f320f5c10f.camel@surriel.com \
    --to=riel@surriel.com \
    --cc=aa9736195201@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aris@ruivo.org \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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

all inboxes | Powered by JetHome®