Re: [PATCH RFC 05/11] mm: convert PTE table entries in ptep_get()
Muhammad Usama Anjum <[email protected]> Thu, 30 Jul 2026 11:25:29 +0100
| Newsgroups | org.kernel.vger.linux-parisc,dev.linux.lists.damon,org.freedesktop.lists.dri-devel,org.freedesktop.lists.intel-gfx,org.kernel.vger.bpf,org.kernel.vger.linux-arch,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-trace-kernel,org.kvack.linux-mm,org.xenproject.lists.xen-devel |
|---|---|
| Message-ID | <[email protected]> |
On 30/07/2026 11:24 am, Alexander Gordeev wrote: > On Thu, Jul 30, 2026 at 11:11:35AM +0100, Muhammad Usama Anjum wrote: >> On 30/07/2026 11:08 am, Alexander Gordeev wrote: >>> On Mon, Jul 27, 2026 at 05:46:56PM +0100, Muhammad Usama Anjum wrote: >>>> ptep_get() now accepts a pointer to hw_pte_t storage but must continue to >>>> return a logical pte_t value. Add __pte_from_hw() as the conversion hook >>>> and apply it in the generic ptep_get() implementation. >>>> >>>> Signed-off-by: Muhammad Usama Anjum <[email protected]> >>>> --- >>>> include/linux/pgtable.h | 2 +- >>>> include/linux/pgtable_types.h | 1 + >>>> 2 files changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h >>>> index dad80d264aac2..3003ac9cd81fe 100644 >>>> --- a/include/linux/pgtable.h >>>> +++ b/include/linux/pgtable.h >>>> @@ -493,7 +493,7 @@ static inline int pudp_set_access_flags(struct vm_area_struct *vma, >>>> #ifndef ptep_get >>>> static inline pte_t ptep_get(hw_pte_t *ptep) >>>> { >>>> - return READ_ONCE(*ptep); >>>> + return READ_ONCE(__pte_from_hw(*ptep)); >>> >>> Should it be something like? >>> >>> return __pte_from_hw(READ_ONCE(*ptep)); >> I'd thought about it. My thinking is that we should get the pte_t first before >> before calling READ_ONCE(). Please correct me what makes more sense? > > I have a problem with "get the pte_t first" part ;) I think what we want > is atomically read the hw_pte_t from the HW table and then convert the > result to pte_t. Got it. I'll fix it in the next version. > >>> >>>> } >>>> #endif >>>> >>>> diff --git a/include/linux/pgtable_types.h b/include/linux/pgtable_types.h >>>> index ed5dba42a4f8c..61afe27307ec2 100644 >>>> --- a/include/linux/pgtable_types.h >>>> +++ b/include/linux/pgtable_types.h >>>> @@ -6,6 +6,7 @@ >>>> >>>> #ifndef __HAVE_ARCH_HW_PTE_T >>>> #define hw_pte_t pte_t >>>> +#define __pte_from_hw(pte) (pte) >>>> #endif >>>> >>>> #endif /* _LINUX_PGTABLE_TYPES_H */ >>>> -- >>>> 2.47.3 >>>> >> >> -- >> Thanks, >> Usama >> -- Thanks, Usama