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

Re: [PATCH v2 3/8] mm: use hw_pte_t for generic PTE table storage



On 9/3/26 12:29, Muhammad Usama Anjum wrote:
> Generic page-table interfaces use pte_t * for both pointers to PTE table
> storage and pointers to software PTE values. Convert the generic
> declarations and their MM, fs, and kernel users together so parameters,
> return types, callbacks, and local pointers that designate table storage
> use hw_pte_t *.
> 
> Include linux/pgtable_types.h from headers that expose the converted
> interfaces. It continues to provide pgprot_t to vmalloc.h through
> asm/page.h.
> 
> Keep software PTE values as pte_t and retain pte_t * for value interfaces.
> 
> No architecture selects ARCH_HAS_HW_PTE_T at this point, so hw_pte_t
> remains an alias of pte_t and this changes the interface vocabulary without
> changing representation or behavior.
> 
> Most of this mechanical conversion was generated with the Coccinelle script
> included in the cover letter. The script deliberately ignores pte_t *
> pointers named ptentp because they designate software PTE values. The
> result was then audited, and sites the script could not convert were
> updated by hand.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
> ---
> Changes since v1:
> - Fold the header includes into their first user instead of keeping a
>   stand-alone preparation patch.
> - Rebase onto mm-new and rerun the Coccinelle script.
> - Use software PTE value terminology.
> 
> Changes since RFC v1:
> - Clarify that linux/pgtable_types.h provides both generic hw_pte_t
>   definitions.
> - Clarify that the distinct generic definition is activated by an
>   architecture opt-in.
> ---
>  fs/hugetlbfs/inode.c             |  3 +-
>  fs/proc/task_mmu.c               | 33 ++++++-------
>  include/asm-generic/hugetlb.h    | 15 +++---
>  include/asm-generic/pgalloc.h    |  6 +--
>  include/asm-generic/tlb.h        |  5 +-
>  include/linux/hugetlb.h          | 50 +++++++++++---------
>  include/linux/mm.h               | 26 +++++------
>  include/linux/page_table_check.h | 10 ++--
>  include/linux/pagewalk.h         |  8 ++--
>  include/linux/pgtable.h          | 79 +++++++++++++++++---------------
>  include/linux/rmap.h             |  2 +-
>  include/linux/swapops.h          |  6 ++-
>  include/linux/vmalloc.h          |  4 +-
>  include/trace/events/xen.h       | 10 ++--
>  kernel/bpf/arena.c               |  9 ++--
>  kernel/events/core.c             |  3 +-
>  mm/damon/ops-common.c            |  2 +-
>  mm/damon/ops-common.h            |  2 +-
>  mm/damon/vaddr.c                 | 20 ++++----
>  mm/debug_vm_pgtable.c            |  2 +-
>  mm/filemap.c                     |  4 +-
>  mm/gup.c                         |  9 ++--
>  mm/highmem.c                     | 15 +++---
>  mm/hmm.c                         |  6 +--
>  mm/huge_memory.c                 |  4 +-
>  mm/hugetlb.c                     | 60 ++++++++++++------------
>  mm/hugetlb_vmemmap.c             | 13 +++---
>  mm/internal.h                    | 16 +++----
>  mm/kasan/init.c                  | 12 ++---
>  mm/kasan/shadow.c                |  6 +--
>  mm/khugepaged.c                  | 50 ++++++++++++--------
>  mm/ksm.c                         |  7 +--
>  mm/madvise.c                     | 14 +++---
>  mm/mapping_dirty_helpers.c       |  4 +-
>  mm/memory-failure.c              |  6 +--
>  mm/memory.c                      | 78 ++++++++++++++++---------------
>  mm/mempolicy.c                   |  4 +-
>  mm/migrate.c                     |  4 +-
>  mm/migrate_device.c              |  4 +-
>  mm/mincore.c                     |  4 +-
>  mm/mlock.c                       |  4 +-
>  mm/mprotect.c                    | 19 ++++----
>  mm/mremap.c                      |  4 +-
>  mm/page_table_check.c            |  4 +-
>  mm/pagewalk.c                    |  9 ++--
>  mm/percpu.c                      |  2 +-
>  mm/pgtable-generic.c             | 20 ++++----
>  mm/ptdump.c                      |  2 +-
>  mm/rmap.c                        |  6 +--
>  mm/sparse-vmemmap.c              | 22 ++++-----
>  mm/swap_state.c                  |  3 +-
>  mm/swapfile.c                    |  5 +-
>  mm/userfaultfd.c                 | 32 +++++++------
>  mm/util.c                        |  2 +-
>  mm/vmalloc.c                     | 11 +++--
>  mm/vmscan.c                      |  6 +--
>  56 files changed, 410 insertions(+), 356 deletions(-)
> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 7611a8470ea26..ddaab714c3e02 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -328,7 +328,8 @@ static void hugetlb_delete_from_page_cache(struct folio 
> *folio)
>  static bool hugetlb_vma_maps_pfn(struct vm_area_struct *vma,
>                               unsigned long addr, unsigned long pfn)
>  {
> -     pte_t *ptep, pte;
> +     hw_pte_t *ptep;
> +     pte_t pte;
>  
>       ptep = hugetlb_walk(vma, addr, huge_page_size(hstate_vma(vma)));
>       if (!ptep)

This is interesting.

Assuming we'd had a hugetlb_hw_pte_t, we be able tojust naturally catch things
like using

        ptep_get()

instead of

        huge_ptep_get()

That caused bugs and headakes before.

But I'm not actually proposing that at this point, because it would make messed
up infrastructure where we hacked in hugetlb, like page_vma_mapped_walk() harder
to use.


Regarding this patch, I guess we'll regenerate it when the time comes. We
*might* have to do this stepwise.

E.g., merge patch #1 first, to then convert individual MM components. But we can
discuss that once the time comes.

-- 
Cheers,

David



 


Rackspace

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