All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: linux-kernel@vger.kernel.org, Yeoreum Yun <yeoreum.yun@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Yuan-Hao Hsu <aa9736195201@gmail.com>,
	Christoph Hellwig <hch@infradead.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH 8/8] mm/gup: batch contiguous same-folio PTEs into one refcount grab
Date: Tue, 3 Nov 2026 21:08:30 -0500	[thread overview]
Message-ID: <20261103210830.2870eaae@fangorn> (raw)
In-Reply-To: <1affac11-da98-40b3-8cc2-6e8374b5ab69@kernel.org>

On Tue, 3 Nov 2026 17:55:31 +0100
"David Hildenbrand (Arm)" <david@kernel.org> wrote:


> My plan is to get the small series for gup-fast ready, stage that, and then
> build on top of it.
> 
> By then I should have been able to dig through most of your series. The cleanups
> can stay part of this series.
> 
That sounds good. It looks like with this small change below,
GUP-fast and slow GUP can share another helper.

I can fold that into my series as well, or send the cleanups
in a separate series, whatever works best for you.

The PUD and PMD paths do not look as easy to untangle, but
maybe after some more cleanups on each end?

---8<---

diff --git a/mm/gup.c b/mm/gup.c
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -940,14 +940,20 @@
  * run under FOLL_WRITE or FOLL_PIN does need the per-page check, so it stays
  * one page at a time.
+ *
+ * @fpb_flags selects the scan: slow GUP merges young/dirty so
+ * folio_mark_dirty() sees any dirty PTE in the run; fast GUP scans
+ * locklessly and revalidates the run after grabbing it. @vma is only
+ * needed for FPB_MERGE_WRITE and may be NULL otherwise.
  */
 static unsigned long gup_pte_batch_len(struct vm_area_struct *vma,
 		unsigned long address, unsigned long walk_end,
-		struct folio *folio, pte_t *ptep, pte_t *batch_pte, unsigned int flags)
+		struct folio *folio, pte_t *ptep, pte_t *batch_pte,
+		unsigned int flags, fpb_t fpb_flags)
 {
 	unsigned long max;
@@ -961,8 +961,7 @@
 	max = (walk_end - address) >> PAGE_SHIFT;
 	if (max <= 1)
 		return 1;
 
-	/* Merge young/dirty across batch so folio_mark_dirty sees any dirty. */
 	return folio_pte_batch_flags(folio, vma, ptep, batch_pte, max,
-				     FPB_RESPECT_WRITE | FPB_MERGE_YOUNG_DIRTY);
+				     fpb_flags);
 }
@@ -1018,7 +1018,8 @@
 			folio = page_folio(page);
 			batch_pte = pte;
 
 			batch = gup_pte_batch_len(vma, address, walk_end, folio,
-					 ptep, &batch_pte, flags);
+					 ptep, &batch_pte, flags,
+					 FPB_RESPECT_WRITE | FPB_MERGE_YOUNG_DIRTY);
 			ret = gup_grab_folio_pages(folio, page, batch,
 						     pte_dirty(batch_pte), flags,



  reply	other threads:[~2026-11-04  2:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 19:30 [RFC PATCH v5 0/8] batch lookups in follow_page_mask() Rik van Riel
2026-11-02 19:30 ` [PATCH 1/8] mm/gup: break out gup_fill_pages() helper Rik van Riel
2026-11-03  8:43   ` David Hildenbrand (Arm)
2026-11-03 16:29     ` Rik van Riel
2026-11-03 16:39       ` David Hildenbrand (Arm)
2026-11-03 17:00         ` Rik van Riel
2026-11-03 17:04           ` David Hildenbrand (Arm)
2026-11-03 19:30             ` Rik van Riel
2026-11-05 10:31               ` David Hildenbrand (Arm)
2026-11-02 19:30 ` [PATCH 2/8] mm/gup: convert follow_page_mask() to return a long Rik van Riel
2026-11-03 19:31   ` sashiko-bot
2026-11-02 19:30 ` [PATCH 3/8] mm/gup: split out folio grab-and-store helper Rik van Riel
2026-11-02 19:30 ` [PATCH 4/8] mm/gup: break out gup_lookup_pte() helper Rik van Riel
2026-11-02 19:30 ` [PATCH 5/8] mm/gup: fill the pages array outside the pud/pmd lock Rik van Riel
2026-11-02 19:30 ` [PATCH 6/8] mm/gup: return a huge page's full count from follow_page_mask() Rik van Riel
2026-11-02 19:30 ` [PATCH 7/8] mm/gup: walk multiple PTEs per follow_page_pte() call Rik van Riel
2026-11-03 19:31   ` sashiko-bot
2026-11-02 19:30 ` [PATCH 8/8] mm/gup: batch contiguous same-folio PTEs into one refcount grab Rik van Riel
2026-11-03  8:35   ` David Hildenbrand (Arm)
2026-11-03 16:42     ` Rik van Riel
2026-11-03 16:55       ` David Hildenbrand (Arm)
2026-11-04  2:08         ` Rik van Riel [this message]
2026-11-03 19:31   ` sashiko-bot

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=20261103210830.2870eaae@fangorn \
    --to=riel@surriel.com \
    --cc=aa9736195201@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hch@infradead.org \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=surenb@google.com \
    --cc=yeoreum.yun@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.