[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/8] mm: introduce hw_pte_t for PTE table storage



On 23/09/2026 12:52 pm, Alexander Gordeev wrote:
> On Thu, Sep 03, 2026 at 11:29:53AM +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.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@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(+)
>>  create mode 100644 include/linux/pgtable_types.h
>>
>> 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
> 
> I would suggest to provide __hw_pte() in this series - it is needed
> by architectures along with __pte_from_hw() right away (as opposed
> to when lands in arm64).

* __pte_from_hw() is added by 4th patch in this series.
* __hw_pte() was added in arm64 specific series. But it has been dropped
  because of [1] in v2 of arm64 series [2]. There is no user of it in my both 
series.
  Please feel free to add it if s390 needs it.
* hw_pte_val() was in arm64 specific series. It has since been moved to generic
series in v3 [3].

[1] https://lore.kernel.org/all/86d4aea6-4272-427e-9229-295489e068d7@xxxxxxx
[2] arm64 v2: 
https://lore.kernel.org/all/20260922-pte0_arm-v2-0-a3f1ddff0a8a@xxxxxxx 
[3] genric v3: 
https://lore.kernel.org/all/20260922-pte0-v3-0-5670b8cb9059@xxxxxxx 

> 
>> +#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
>>


-- 
Thanks,
Usama



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.