Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yeoreum Yun" <yeoreum.yun@arm.com>, linux-mm@kvack.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>,
	"David Hildenbrand" <david@kernel.org>,
	"Rik van Riel" <riel@surriel.com>,
	"Yuan-Hao Hsu" <aa9736195201@gmail.com>
Subject: Re: [PATCH v3 2/6] mm: gup: clarify a reason to check pte/pmd in gup_fast_pte_range()
Date: Tue, 10 Nov 2026 12:33:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-207030@kernel.org> (raw)
In-Reply-To: <20261109-refactor_gup_fast-v3-2-2aaef02df0e1@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm: gup: duplicate comment with typos in gup_fast_pte_range()
--

commit a105945d4180d981c8509ad500ce443d7fbb662c
Author: Yeoreum Yun <yeoreum.yun@arm.com>

mm: gup: clarify a reason to check pte/pmd in gup_fast_pte_range()

This commit adds an inline comment in gup_fast_pte_range() explaining why
the PMD and PTE are rechecked after grabbing the folio.

> diff --git a/mm/gup.c b/mm/gup.c
> index 7d43ce717b246..7f9348c633d58 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2881,6 +2881,14 @@ static unsigned long gup_fast_pte_range(pmd_t pmd, pmd_t *pmdp,
>  		if (!folio)
>  			goto pte_unmap;
>  
> +		/*
> +		 * Recheck the PTE after grabbing the folio to detect concurrent
> +		 * unmapping or protection changes such as by KSM.
> +		 *
> +		 * Also, recheck the PMD: THP collpase can detach the PTE table
> +		 * while its entries remain unchaged. Checking the PTE alone
> +		 * would not dtect that we are walking a detached page table.
> +		 */
>  		if (unlikely(pmd_val(pmd) != pmd_val(pmdp_get_lockless(pmdp))) ||
>  		    unlikely(pte_val(pte) != pte_val(ptep_get_lockless(ptep)))) {
>  			gup_put_folio(folio, 1, flags);

[Severity: Low]
This isn't a bug, but does this comment duplicate the existing block
comment directly above gup_fast_pte_range()?

mm/gup.c:gup_fast_pte_range() {
/*
 * GUP-fast relies on pte change detection to avoid concurrent pgtable
 * operations.
 *
 * To pin the page, GUP-fast needs to do below in order:
 * (1) pin the page (by prefetching pte), then (2) check pte not changed.
 ...
 * For THP collapse, it's a bit more complicated because GUP-fast may be
 * walking a pgtable page that is being freed (pte is still valid but pmd
 * can be cleared already).  To avoid race in such condition, we need to
 * also check pmd here to make sure pmd doesn't change (corresponds to
 * pmdp_collapse_flush() in the THP collapse code path).
 */
}

The commit message also repeats the subject line verbatim without
explaining what is missing from the existing function comment.  If the
new comment is kept or merged into the existing one, note that it has
three typos: "collpase" (collapse), "unchaged" (unchanged), and "dtect"
(detect).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-refactor_gup_fast-v3-0-2aaef02df0e1@arm.com?part=2


  parent reply	other threads:[~2026-11-10 12:33 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 [this message]
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)
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=sashiko-outbox-207030@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aa9736195201@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=liam@infradead.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=sashiko-reviews@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox