Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yeoreum Yun <yeoreum.yun@arm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Rik van Riel <riel@surriel.com>,
	Yuan-Hao Hsu <aa9736195201@gmail.com>,
	Andrew Morton <akpm@linux-foundation.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: Tue, 27 Oct 2026 12:22:27 +0000	[thread overview]
Message-ID: <auCXg7VMr7NdkPdN@e129823.arm.com> (raw)
In-Reply-To: <c3c6f83d-380f-4a9b-a204-fd157ee77648@kernel.org>

On Mon, Oct 12, 2026 at 09:05:55PM +0200, David Hildenbrand (Arm) wrote:
> On 10/12/26 19:58, Rik van Riel wrote:
> > 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>
> 
> There are a bunch of things I don't like about this, including suspiciously LLM
> -sloppy looking stuff like
> 
> +	if (!pte_write(pte)) {
> +		for (i = 1; i < nr; i++) {
> +			if (gup_must_unshare(NULL, flags, page + i))
> +				break;
> +		}
> +		nr = i;
> +	}
> 
> I'll find someone to polish this up.

Thanks David, I'll post with a little bit fix in next rc-period.

-- 
Sincerely,
Yeoreum Yun


      reply	other threads:[~2026-10-27 12:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  8:37 [PATCH] mm/gup: batch PTE-mapped large folios in gup_fast_pte_range() 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
2026-10-12 19:05       ` David Hildenbrand (Arm)
2026-10-27 12:22         ` Yeoreum Yun [this message]

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=auCXg7VMr7NdkPdN@e129823.arm.com \
    --to=yeoreum.yun@arm.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=riel@surriel.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