Re: [PATCH v2] mm/page_vma_mapped_walk: Use ptep_get_lockless() for lockless access
From: Wei Yang
Date: Fri May 08 2026 - 02:24:18 EST
On Fri, May 08, 2026 at 07:15:45AM +0200, Alexander Gordeev wrote:
>On Fri, May 08, 2026 at 01:00:40AM +0000, Wei Yang wrote:
>> 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?
>
>Yes, this is my assumption.
>
Thanks, if so, it looks good.
>> >> >
>> >> > if (!pvmw->ptl) {
>> >> > spin_lock(ptl);
>> >> >--
>> >> >2.51.0
>> >> >
>> >>
>> >> --
>> >> Wei Yang
>> >
>> >Thanks!
>>
>> --
>> Wei Yang
>> Help you, Help me
--
Wei Yang
Help you, Help me