[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 4/9] mm: convert PTE table entries in ptep_get()
- To: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
- From: Anshuman Khandual <anshuman.khandual@xxxxxxx>
- Date: Wed, 30 Sep 2026 10:40:33 +0530
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=foss header.d=arm.com header.i="@arm.com" header.h="Date:From:To:Cc:Subject:References:In-Reply-To"
- Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Lorenzo Stoakes <ljs@xxxxxxxxxx>, "Liam R. Howlett" <liam@xxxxxxxxxxxxx>, Vlastimil Babka <vbabka@xxxxxxxxxx>, Mike Rapoport <rppt@xxxxxxxxxx>, Suren Baghdasaryan <surenb@xxxxxxxxxx>, Michal Hocko <mhocko@xxxxxxxx>, Xu Xin <xu.xin16@xxxxxxxxxx>, Chengming Zhou <chengming.zhou@xxxxxxxxx>, Jann Horn <jannh@xxxxxxxxxx>, Muchun Song <muchun.song@xxxxxxxxx>, Oscar Salvador <osalvador@xxxxxxx>, Pedro Falcato <pfalcato@xxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Will Deacon <will@xxxxxxxxxx>, "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxx>, Nick Piggin <npiggin@xxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>, Rik van Riel <riel@xxxxxxxxxxx>, Harry Yoo <harry@xxxxxxxxxx>, Lance Yang <lance.yang@xxxxxxxxx>, Chris Li <chrisl@xxxxxxxxxx>, Kairui Song <kasong@xxxxxxxxxxx>, Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>, Nhat Pham <nphamcs@xxxxxxxxx>, Baoquan He <baoquan.he@xxxxxxxxx>, Barry Song <baohua@xxxxxxxxxx>, Youngjun Park <youngjun.park@xxxxxxx>, Uladzislau Rezki <urezki@xxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Masami Hiramatsu <mhiramat@xxxxxxxxxx>, Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>, Alexei Starovoitov <ast@xxxxxxxxxx>, Daniel Borkmann <daniel@xxxxxxxxxxxxx>, Andrii Nakryiko <andrii@xxxxxxxxxx>, Eduard Zingerman <eddyz87@xxxxxxxxx>, Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>, Martin KaFai Lau <martin.lau@xxxxxxxxx>, Song Liu <song@xxxxxxxxxx>, Yonghong Song <yonghong.song@xxxxxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Emil Tsalapatis <emil@xxxxxxxxxxxxxxx>, Ihor Solodrai <ihor.solodrai@xxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>, Namhyung Kim <namhyung@xxxxxxxxxx>, Mark Rutland <mark.rutland@xxxxxxx>, Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>, Ian Rogers <irogers@xxxxxxxxxx>, Adrian Hunter <adrian.hunter@xxxxxxxxx>, James Clark <james.clark@xxxxxxxxxx>, SJ Park <sj@xxxxxxxxxx>, "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>, Jan Kara <jack@xxxxxxx>, Jason Gunthorpe <jgg@xxxxxxxx>, John Hubbard <jhubbard@xxxxxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Leon Romanovsky <leon@xxxxxxxxxx>, Zi Yan <ziy@xxxxxxxxxx>, Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>, Nico Pache <nico.pache@xxxxxxxxx>, Ryan Roberts <ryan.roberts@xxxxxxx>, Dev Jain <dev.jain@xxxxxxx>, Usama Arif <usama.arif@xxxxxxxxx>, Kiryl Shutsemau <kas@xxxxxxxxxx>, Andrey Ryabinin <ryabinin.a.a@xxxxxxxxx>, Alexander Potapenko <glider@xxxxxxxxxx>, Andrey Konovalov <andreyknvl@xxxxxxxxx>, Dmitry Vyukov <dvyukov@xxxxxxxxxx>, Vincenzo Frascino <vincenzo.frascino@xxxxxxx>, Miaohe Lin <linmiaohe@xxxxxxxxxx>, Naoya Horiguchi <nao.horiguchi@xxxxxxxxx>, Matthew Brost <matthew.brost@xxxxxxxxx>, Joshua Hahn <joshua.hahnjy@xxxxxxxxx>, Rakie Kim <rakie.kim@xxxxxx>, Byungchul Park <byungchul@xxxxxx>, Gregory Price <gourry@xxxxxxxxxx>, Ying Huang <ying.huang@xxxxxxxxxxxxxxxxx>, Alistair Popple <apopple@xxxxxxxxxx>, Dennis Zhou <dennis@xxxxxxxxxx>, Tejun Heo <tj@xxxxxxxxxx>, Christoph Lameter <cl@xxxxxxxxxx>, Johannes Weiner <hannes@xxxxxxxxxxx>, Qi Zheng <qi.zheng@xxxxxxxxx>, Shakeel Butt <shakeel.butt@xxxxxxxxx>, Axel Rasmussen <axelrasmussen@xxxxxxxxxx>, Yuanchu Xie <yuanchu@xxxxxxxxxx>, Wei Xu <weixugc@xxxxxxxxxx>, Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>, Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>, Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>, Tvrtko Ursulin <tursulin@xxxxxxxxxxx>, David Airlie <airlied@xxxxxxxxx>, Simona Vetter <simona@xxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, linux-arch@xxxxxxxxxxxxxxx, linux-trace-kernel@xxxxxxxxxxxxxxx, bpf@xxxxxxxxxxxxxxx, linux-perf-users@xxxxxxxxxxxxxxx, damon@xxxxxxxxxxxxxxx, kasan-dev@xxxxxxxxxxxxxxxx, intel-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Wed, 30 Sep 2026 08:51:15 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Sep 22, 2026 at 06:12:32PM +0100, Muhammad Usama Anjum wrote:
> ptep_get() now accepts a pointer to hw_pte_t storage but must continue to
> return a software PTE value. Add __pte_from_hw for both generic hw_pte_t
> definitions. Read the hw_pte_t table element atomically before converting
> it to pte_t.
>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
> ---
> Changes since v1:
> - Use software PTE value terminology.
>
> Changes since RFC v1:
> - Define __pte_from_hw for the opted-in generic wrapper.
> - Apply READ_ONCE() to hw_pte_t before converting it to pte_t.
> ---
> include/linux/pgtable.h | 2 +-
> include/linux/pgtable_types.h | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index 19098e302b75a..41337da0d65aa 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 __pte_from_hw(READ_ONCE(*ptep));
> }
Just curious - when would other pgtable levels (PMD, PUD, P4D and PGD) be
converted
in this format as well ?
> #endif
>
> diff --git a/include/linux/pgtable_types.h b/include/linux/pgtable_types.h
> index 07da05d375c2c..d6c5a7548550b 100644
> --- a/include/linux/pgtable_types.h
> +++ b/include/linux/pgtable_types.h
> @@ -8,8 +8,10 @@
>
> #ifdef CONFIG_ARCH_HAS_HW_PTE_T
> typedef struct __hw_pte_t { pte_t __pte; } hw_pte_t;
> +#define __pte_from_hw(pte) ((pte).__pte)
> #else
> #define hw_pte_t pte_t
> +#define __pte_from_hw(pte) (pte)
> #endif
>
> #endif /* !__ASSEMBLY__ */
>
> --
> 2.47.3
>
|