All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Yeoreum Yun <yeoreum.yun@arm.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rik van Riel <riel@surriel.com>,
	Yuan-Hao Hsu <aa9736195201@gmail.com>
Subject: Re: [PATCH v3 5/6] mm: gup: introduce gup_unshared_pages()
Date: Tue, 10 Nov 2026 14:06:23 +0100	[thread overview]
Message-ID: <e66b6c19-95d2-459a-926c-8429df693acb@kernel.org> (raw)
In-Reply-To: <20261109-refactor_gup_fast-v3-5-2aaef02df0e1@arm.com>

On 11/9/26 13:32, Yeoreum Yun wrote:
> This is preparatory patch to make gup_fast_pte_range() batchable.
> 
> Introduce gup_unshared_pages() to count consecutive pages within a folio
> that do not require unsharing, and use it to implement gup_must_unshare().
> 
> Also add a folio argument to gup_must_unshare() so callers can reuse an
> existing folio and avoid the compound_head() call implicit in PageAnon().
> 
> There is no functional change.
> 
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> ---
>  mm/gup.c | 111 +++++++++++++++++++++++++++++++++++++--------------------------
>  1 file changed, 66 insertions(+), 45 deletions(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index bfe83ce1411d5..c863bae33e2f1 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -633,58 +633,39 @@ static struct page *no_page_table(struct vm_area_struct *vma,
>  	return NULL;
>  }
>  
> -/*
> - * Indicates for which pages that are write-protected in the page table,
> - * whether GUP has to trigger unsharing via FAULT_FLAG_UNSHARE such that the
> - * GUP pin will remain consistent with the pages mapped into the page tables
> - * of the MM.
> - *
> - * Temporary unmapping of PageAnonExclusive() pages or clearing of
> - * PageAnonExclusive() has to protect against concurrent GUP:
> - * * Ordinary GUP: Using the PT lock
> - * * GUP-fast and fork(): mm->write_protect_seq
> - * * GUP-fast and KSM or temporary unmapping (swap, migration): see
> - *    folio_try_share_anon_rmap_*()
> - *
> - * Must be called with the (sub)page that's actually referenced via the
> - * page table entry, which might not necessarily be the head page for a
> - * PTE-mapped THP.
> - *
> - * If the vma is NULL, we're coming from the GUP-fast path and might have
> - * to fallback to the slow path just to lookup the vma.
> - */
> -static inline bool gup_must_unshare(struct vm_area_struct *vma,
> -				    unsigned int flags, struct page *page)
> +static unsigned long gup_unshared_pages(struct vm_area_struct *vma,

Besides the function name, LGTM.

gup_pages_requiring_unsharing() ? Don't quite like it, but something along those
lines.

-- 
Cheers,

David


  parent reply	other threads:[~2026-11-11 10:30 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 12:32 [PATCH v3 0/6] mm: gup: batch PTE-mapped large folios in gup_fast_pte_range() Yeoreum Yun
2026-11-09 12:32 ` [PATCH v3 1/6] mm: khugepaged: ignore MADV_HUGEPAGE for shadow stacks Yeoreum Yun
2026-11-09 14:22   ` David Hildenbrand (Arm)
2026-11-09 15:24     ` Yeoreum Yun
2026-11-09 12:32 ` [PATCH v3 2/6] mm: gup: clarify a reason to check pte/pmd in gup_fast_pte_range() Yeoreum Yun
2026-11-10  3:50   ` Rik van Riel
2026-11-10  9:52     ` Yeoreum Yun
2026-11-10 13:01     ` David Hildenbrand (Arm)
2026-11-10 12:33   ` sashiko-bot
2026-11-10 13:00     ` David Hildenbrand (Arm)
2026-11-09 12:32 ` [PATCH v3 3/6] mm: gup: move gup_must_unshare() and INTERNAL_GUP_FLAGS to gup.c Yeoreum Yun
2026-11-10  4:49   ` Rik van Riel
2026-11-10 13:02   ` David Hildenbrand (Arm)
2026-11-09 12:32 ` [PATCH v3 4/6] mm: internal: introduce FPB_LOCKLESS for folio_pte_batch_flags() Yeoreum Yun
2026-11-10  4:51   ` Rik van Riel
2026-11-10 13:02   ` David Hildenbrand (Arm)
2026-11-09 12:32 ` [PATCH v3 5/6] mm: gup: introduce gup_unshared_pages() Yeoreum Yun
2026-11-10  5:26   ` Rik van Riel
2026-11-10  9:58     ` Yeoreum Yun
2026-11-10 13:04       ` David Hildenbrand (Arm)
2026-11-10 13:58         ` Yeoreum Yun
2026-11-10 19:21         ` Rik van Riel
2026-11-10 20:19           ` Yeoreum Yun
2026-11-10 20:23             ` Rik van Riel
2026-11-10 21:27               ` Yeoreum Yun
2026-11-10 22:35                 ` David Hildenbrand (Arm)
2026-11-10 22:39                   ` Yeoreum Yun
2026-11-10 20:23             ` David Hildenbrand (Arm)
2026-11-10 13:06   ` David Hildenbrand (Arm) [this message]
2026-11-11 15:03     ` Rik van Riel
2026-11-09 12:32 ` [PATCH v3 6/6] mm: gup: batch PTE-mapped large folios in gup_fast_pte_range() Yeoreum Yun
2026-11-10  5:46   ` Rik van Riel
2026-11-10 13:09   ` David Hildenbrand (Arm)
2026-11-10 14:04     ` Yeoreum Yun

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=e66b6c19-95d2-459a-926c-8429df693acb@kernel.org \
    --to=david@kernel.org \
    --cc=aa9736195201@gmail.com \
    --cc=akpm@linux-foundation.org \
    --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=surenb@google.com \
    --cc=vbabka@kernel.org \
    --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.