Re: [PATCH v2] mm/page_vma_mapped_walk: Use ptep_get_lockless() for lockless access

From: Wei Yang

Date: Thu May 07 2026 - 21:00:53 EST


On Thu, May 07, 2026 at 12:32:09PM +0200, Alexander Gordeev wrote:
>On Thu, May 07, 2026 at 09:34:33AM +0000, Wei Yang wrote:
>> >@@ -310,7 +310,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
>> > goto restart;
>> > }
>> > pvmw->pte++;
>> >- } while (pte_none(ptep_get(pvmw->pte)));
>> >+ } while (pte_none(ptep_get_lockless(pvmw->pte)));
>>
>> As Oscar mentioned in lkml.org/lkml/2026/4/27/630, map_pte() may take the
>> lock. So probably it is not right?
>
>If I read the code correctly map_pte() might take the lock, but also
>might not take it. If it took the lock and uses ptep_get_lockless(),
>then it is fine. But if it did not take the lock and uses ptep_get(),
>then it is an issue.
>

So the rule here is:

* ptep_get_lockless() could be used for locked and not locked
* ptep_get() only used when locked

Right?

>> >
>> > if (!pvmw->ptl) {
>> > spin_lock(ptl);
>> >--
>> >2.51.0
>> >
>>
>> --
>> Wei Yang
>
>Thanks!

--
Wei Yang
Help you, Help me