From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7EB8559CBC; Tue, 22 Sep 2026 17:13:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790097197; cv=none; b=rvIrbaobrOS6+FK21kV68eLcUAhxzhvkVnlymMrbdmFDwv9riqAdN+9B9k8X/uj4LgGgjnsB0u8h3Uw8hQvg7M4ur2491wfxm//S6dLjk8tq7QF6P4gk2uV+a7n7WbGRbXyOhTWOYFQLKucsF9iIJTbPbv718LWf+gM5WYvWdkY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790097197; c=relaxed/simple; bh=6PW1tkj08QGo8QdckrPX0ODHoxUb6pqu2veO+kTTZ/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jzEdWGdhSWr1zFaMm2bRjkTp0BAaxiVRilwP8XY4qK6HtJnChl0GbHTqR2U1auzr6BLwcpdPuAkVZYQziLE7CHEO85ykOaAv3IyzCyPVL0/7uW54aIa5beWPiSXuxYJCJgQLhOqSWDJI2xeD5bKVQ/wPyluYr+rzae6AfgBEOFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=pCTPM03m; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="pCTPM03m" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A463E1BF7; Tue, 22 Sep 2026 10:13:11 -0700 (PDT) Received: from [127.0.1.1] (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 479AD3F86C; Tue, 22 Sep 2026 10:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1790097195; bh=6PW1tkj08QGo8QdckrPX0ODHoxUb6pqu2veO+kTTZ/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pCTPM03mJphkPxfc35zeUUsQF8Wf+c8WL4VK71wDLX28hB9HGW7S8BbVsmZ2JQk5T Yo0zY8RCJu6/8P4pPe9u2C/m6SJk9j0y0fparJfvZTMlzq4fTIbQBDrgjycGf2yHZq HemyfHlHgY+jLXxIgf46qiftTUNRZqsbU5Uy10Sg= From: Muhammad Usama Anjum Date: Tue, 22 Sep 2026 18:12:29 +0100 Subject: [PATCH v3 1/9] mm: introduce hw_pte_t for PTE table storage Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260922-pte0-v3-1-5670b8cb9059@arm.com> References: <20260922-pte0-v3-0-5670b8cb9059@arm.com> In-Reply-To: <20260922-pte0-v3-0-5670b8cb9059@arm.com> To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Xu Xin , Chengming Zhou , Jann Horn , Muchun Song , Oscar Salvador , Pedro Falcato , Arnd Bergmann , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Pasha Tatashin , Rik van Riel , Harry Yoo , Lance Yang , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , Uladzislau Rezki , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Ian Rogers , Adrian Hunter , James Clark , SJ Park , "Matthew Wilcox (Oracle)" , Jan Kara , Jason Gunthorpe , John Hubbard , Peter Xu , Leon Romanovsky , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Kiryl Shutsemau , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Miaohe Lin , Naoya Horiguchi , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Dennis Zhou , Tejun Heo , Christoph Lameter , Johannes Weiner , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, damon@lists.linux.dev, kasan-dev@googlegroups.com, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, Muhammad Usama Anjum X-Mailer: b4 0.16.0 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) Signed-off-by: Muhammad Usama Anjum --- 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 + +#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