[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/9] mm: introduce hw_pte_t for PTE table storage
- To: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
- From: Anshuman Khandual <anshuman.khandual@xxxxxxx>
- Date: Wed, 30 Sep 2026 09:43:37 +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 05:01:25 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Sep 22, 2026 at 06:12:29PM +0100, Muhammad Usama Anjum wrote:
> pte_t is used both for software PTE values and for entries stored in a PTE
> table, so pte_t * does not distinguish a pointer to a software PTE
> value from a pointer to table storage.
>
> Introduce hw_pte_t as the generic name for a PTE table element. Define it
> as a macro alias of pte_t by default. When an architecture selects
> ARCH_HAS_HW_PTE_T, define it as a structure containing a pte_t instead.
> This preserves the representation while allowing converted architectures
> to enforce the distinction at compile time.
>
> Name the generic wrapper structure __hw_pte_t so architectures can
> forward-declare it when pgtable_t must be defined before the generic
> hw_pte_t typedef is visible. This avoids header-order dependencies.
>
> Keep the C type definitions behind an __ASSEMBLY__ check because
> architecture assembly sources can include this header indirectly. Include
> asm/page.h so consumers such as linux/vmalloc.h retain the page definitions
> they previously obtained from that header.
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
LGTM
Reviewed-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
> ---
> Changes since v1:
> - Name the generic wrapper structure __hw_pte_t so architectures can
> forward-declare it, and explain why this is required.
> - Use software PTE value terminology.
>
> Changes since RFC v1:
> - Add the ARCH_HAS_HW_PTE_T opt-in and generic wrapper definition.
> - Exclude the C type definitions from assembly sources.
> - Update the description for the new opt-in model.
> ---
> MAINTAINERS | 1 +
> include/linux/pgtable_types.h | 17 +++++++++++++++++
> mm/Kconfig | 3 +++
> 3 files changed, 21 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2133aec4a2004..da60a8bdcddb5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -17140,6 +17140,7 @@ F: include/linux/mmu_notifier.h
> F: include/linux/pagewalk.h
> F: include/linux/pgalloc.h
> F: include/linux/pgtable.h
> +F: include/linux/pgtable_types.h
> F: include/linux/ptdump.h
> F: include/linux/vmpressure.h
> F: include/linux/vmstat.h
> diff --git a/include/linux/pgtable_types.h b/include/linux/pgtable_types.h
> new file mode 100644
> index 0000000000000..07da05d375c2c
> --- /dev/null
> +++ b/include/linux/pgtable_types.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _LINUX_PGTABLE_TYPES_H
> +#define _LINUX_PGTABLE_TYPES_H
> +
> +#include <asm/page.h>
> +
> +#ifndef __ASSEMBLY__
> +
> +#ifdef CONFIG_ARCH_HAS_HW_PTE_T
> +typedef struct __hw_pte_t { pte_t __pte; } hw_pte_t;
> +#else
> +#define hw_pte_t pte_t
> +#endif
> +
> +#endif /* !__ASSEMBLY__ */
> +
> +#endif /* _LINUX_PGTABLE_TYPES_H */
> diff --git a/mm/Kconfig b/mm/Kconfig
> index c1ddf59c0d71a..5f462ec6fa5e5 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -1312,6 +1312,9 @@ comment "GUP_TEST needs to have DEBUG_FS enabled"
> config GUP_GET_PXX_LOW_HIGH
> bool
>
> +config ARCH_HAS_HW_PTE_T
> + bool
> +
> config DMAPOOL_TEST
> tristate "Enable a module to run time tests on dma_pool"
> depends on HAS_DMA
>
> --
> 2.47.3
>
|