From: Alexander Gordeev <agordeev@linux.ibm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Oscar Salvador <osalvador@suse.de>,
linux-s390@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH v2] mm/page_vma_mapped_walk: Use ptep_get_lockless() for lockless access
Date: Fri, 8 May 2026 10:34:34 +0200 [thread overview]
Message-ID: <af7d5142-261f-4521-8abd-39ef299916e2-agordeev@linux.ibm.com> (raw)
In-Reply-To: <be6b10ac-7170-47df-b1fc-71098270c343@kernel.org>
On Fri, May 08, 2026 at 10:17:16AM +0200, David Hildenbrand (Arm) wrote:
> >> So the rule here is:
> >>
> >> * ptep_get_lockless() could be used for locked and not locked
> >> * ptep_get() only used when locked
> >>
> >> Right?
> >
> > Yes, this is my assumption.
>
> I agree, ptep_get_lockless() simply makes sense to return something sensible if
> there are concurrent modifications (which cannot happen when the PTL is held).
>
> That's why only 32bit with 64bit PTEs and arm64 even has to special-case it.
>
>
> We should clarify in the patch description that in the do-while loop, we might
> or might not hold the PTL, and that calling ptep_get_lockless() with the PTL
> held is OK.
>
> I wonder if it's more efficient and clearer, to use the correct variant, though?
>
>
> diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
> index a4d52fdb3056..36d97661a4e5 100644
> --- a/mm/page_vma_mapped.c
> +++ b/mm/page_vma_mapped.c
> @@ -187,6 +187,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
> p4d_t *p4d;
> pud_t *pud;
> pmd_t pmde;
> + pte_t pteval;
>
> /* The only possible pmd mapping has been handled on last iteration */
> if (pvmw->pmd && !pvmw->pte)
> @@ -310,7 +311,11 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
> goto restart;
> }
> pvmw->pte++;
> - } while (pte_none(ptep_get(pvmw->pte)));
> + if (!pvmw->ptl)
> + pteval = ptep_get_lockless(pvmw->pte);
> + else
> + pteval = ptep_get(pvmw->pte);
> + } while (pte_none(pteval));
Looks fine to me. I will try and add it to the next version.
> if (!pvmw->ptl) {
> spin_lock(ptl);
>
>
> --
> Cheers,
>
> David
Thanks!
prev parent reply other threads:[~2026-05-08 8:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 13:04 [PATCH v2] mm/page_vma_mapped_walk: Use ptep_get_lockless() for lockless access Alexander Gordeev
2026-05-07 9:34 ` Wei Yang
2026-05-07 10:32 ` Alexander Gordeev
2026-05-08 1:00 ` Wei Yang
2026-05-08 5:15 ` Alexander Gordeev
2026-05-08 6:23 ` Wei Yang
2026-05-08 8:17 ` David Hildenbrand (Arm)
2026-05-08 8:34 ` Alexander Gordeev [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=af7d5142-261f-4521-8abd-39ef299916e2-agordeev@linux.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=david@kernel.org \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=osalvador@suse.de \
--cc=richard.weiyang@gmail.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