mm/treewide: Replace pXd_large() with pXd_leaf()
Subsystems (13)
cover mm/treewide: Replace pXd_large() with pXd_leaf()
From: Peter Xu <[email protected]>
[based on latest akpm/mm-unstable, commit 1274e7646240]
These two APIs are mostly always the same. It's confusing to have both of them. Merge them into one. Here I used pXd_leaf() only because pXd_leaf() is a global API which is always defined, while pXd_large() is not.
We have yet one more API that is similar which is pXd_huge(), but that's even trickier, so let's do it step by step.
Some cautions are needed on either x86 or ppc: x86 is currently the only user of p4d_large(), while ppc used to define pXd_large() only with THP, while it is not the case for pXd_leaf(). For the rest archs, afaict they're 100% identical.
Only lightly tested on x86.
Please have a look, thanks.
Peter Xu (5):
mm/ppc: Define pXd_large() with pXd_leaf() mm/x86: Replace p4d_large() with p4d_leaf() mm/treewide: Replace pmd_large() with pmd_leaf() mm/treewide: Replace pud_large() with pud_leaf() mm/treewide: Drop pXd_large()
arch/arm/include/asm/pgtable-2level.h | 1 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/arm/mm/dump.c | 4 ++-- arch/powerpc/include/asm/book3s/64/pgtable.h | 14 -------------- arch/powerpc/include/asm/pgtable.h | 4 ---- arch/powerpc/mm/book3s64/pgtable.c | 4 ++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +- arch/powerpc/mm/pgtable_64.c | 2 +- arch/s390/boot/vmem.c | 4 ++-- arch/s390/include/asm/pgtable.h | 20 ++++++++++---------- arch/s390/mm/gmap.c | 14 +++++++------- arch/s390/mm/hugetlbpage.c | 6 +++--- arch/s390/mm/pageattr.c | 4 ++-- arch/s390/mm/pgtable.c | 8 ++++---- arch/s390/mm/vmem.c | 12 ++++++------ arch/sparc/include/asm/pgtable_64.h | 8 ++++---- arch/sparc/mm/init_64.c | 6 +++--- arch/x86/boot/compressed/ident_map_64.c | 2 +- arch/x86/include/asm/pgtable.h | 15 +++++++-------- arch/x86/kvm/mmu/mmu.c | 4 ++-- arch/x86/mm/fault.c | 16 ++++++++-------- arch/x86/mm/ident_map.c | 2 +- arch/x86/mm/init_32.c | 2 +- arch/x86/mm/init_64.c | 14 +++++++------- arch/x86/mm/kasan_init_64.c | 4 ++-- arch/x86/mm/mem_encrypt_identity.c | 6 +++--- arch/x86/mm/pat/set_memory.c | 14 +++++++------- arch/x86/mm/pgtable.c | 4 ++-- arch/x86/mm/pti.c | 8 ++++---- arch/x86/power/hibernate.c | 6 +++--- arch/x86/xen/mmu_pv.c | 10 +++++----- drivers/misc/sgi-gru/grufault.c | 2 +- 32 files changed, 101 insertions(+), 122 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/5 mm/ppc: Define pXd_large() with pXd_leaf()
From: Peter Xu <[email protected]>
The two definitions are the same. The only difference is that pXd_large() is only defined with THP selected, and only on book3s 64bits.
Instead of implementing it twice, make pXd_large() a macro to pXd_leaf(). Define it unconditionally just like pXd_leaf(). This helps to prepare merging the two APIs.
--- arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++-------------- arch/powerpc/include/asm/pgtable.h | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/book3s/64/pgtable.h +2 -14
@@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned long addr, pud_t *pudp,return pud_val (*pudp); } -/* -* returns true for pmd migration entries, THP, devmap, hugetlb -* But compile time dependent on THP config -*/ -static inline int pmd_large (pmd_t pmd) -{ -return !!(pmd_raw (pmd) &cpu_to_be64 (_PAGE_PTE)); -} - -static inline int pud_large (pud_t pud) -{ -return !!(pud_raw (pud) &cpu_to_be64 (_PAGE_PTE)); -} -/* * For radix we should always find H_PAGE_HASHPTE zero. Hence * the below will work for radix too
@@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va*/ #define pmd_is_leaf pmd_is_leaf#define pmd_leaf pmd_is_leaf +#define pmd_large pmd_leafstatic inline bool pmd_is_leaf (pmd_t pmd) {return !!(pmd_raw (pmd) &cpu_to_be64 (_PAGE_PTE));
@@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd)#define pud_is_leaf pud_is_leaf#define pud_leaf pud_is_leaf +#define pud_large pud_leafstatic inline bool pud_is_leaf (pud_t pud) {return !!(pud_raw (pud) &cpu_to_be64 (_PAGE_PTE));
arch/powerpc/include/asm/pgtable.h +1 -1
@@ -101,7 +101,7 @@ void poking_init(void);extern unsigned long ioremap_bot;extern const pgprot_t protection_map[16 ]; -#ifndef CONFIG_TRANSPARENT_HUGEPAGE +#ifndef pmd_large#define pmd_large (pmd) 0#endif
Signature · 1 line
2.43.0
PATCH 2/5 mm/x86: Replace p4d_large() with p4d_leaf()
In reply to [email protected]From: Peter Xu <[email protected]>
p4d_large() is always defined as p4d_leaf(). Merge their usages. Chose p4d_leaf() because p4d_leaf() is a global API, while p4d_large() is not.
Only x86 has p4d_leaf() defined as of now. So it also means after this patch we removed all p4d_large() usages.
--- arch/x86/mm/fault.c | 4 ++-- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/pat/set_memory.c | 4 ++-- arch/x86/mm/pti.c | 2 +- arch/x86/power/hibernate.c | 2 +- arch/x86/xen/mmu_pv.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
arch/x86/mm/fault.c +2 -2
@@ -368,7 +368,7 @@ static void dump_pagetable(unsigned long address) goto bad;pr_cont ("P4D %lx " ,p4d_val (*p4d)); -if (!p4d_present (*p4d) ||p4d_large (*p4d)) +if (!p4d_present (*p4d) ||p4d_leaf (*p4d)) goto out; pud =pud_offset (p4d, address);
@@ -1039,7 +1039,7 @@ spurious_kernel_fault(unsigned long error_code, unsigned long address)if (!p4d_present (*p4d))return 0 ; -if (p4d_large (*p4d)) +if (p4d_leaf (*p4d))return spurious_kernel_fault_check (error_code, (pte_t *) p4d); pud =pud_offset (p4d, address);
arch/x86/mm/init_64.c +1 -1
@@ -1197,7 +1197,7 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end,if (!p4d_present (*p4d))continue ; -BUILD_BUG_ON (p4d_large (*p4d)); +BUILD_BUG_ON (p4d_leaf (*p4d)); pud_base =pud_offset (p4d,0 );remove_pud_table (pud_base, addr, next, altmap, direct);
arch/x86/mm/pat/set_memory.c +2 -2
@@ -676,7 +676,7 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address,return NULL ; *level =PG_LEVEL_512G ; -if (p4d_large (*p4d) || !p4d_present (*p4d)) +if (p4d_leaf (*p4d) || !p4d_present (*p4d))return (pte_t *)p4d; pud =pud_offset (p4d, address);
@@ -739,7 +739,7 @@ pmd_t *lookup_pmd_address(unsigned long address)return NULL ; p4d =p4d_offset (pgd, address); -if (p4d_none (*p4d) ||p4d_large (*p4d) || !p4d_present (*p4d)) +if (p4d_none (*p4d) ||p4d_leaf (*p4d) || !p4d_present (*p4d))return NULL ; pud =pud_offset (p4d, address);
arch/x86/mm/pti.c +1 -1
@@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address)if (!p4d)return NULL ; -BUILD_BUG_ON (p4d_large (*p4d) !=0 ); +BUILD_BUG_ON (p4d_leaf (*p4d) !=0 );if (p4d_none (*p4d)) {unsigned long new_pud_page =__get_free_page (gfp);if (WARN_ON_ONCE (!new_pud_page))
arch/x86/power/hibernate.c +1 -1
@@ -165,7 +165,7 @@ int relocate_restore_code(void) pgd = (pgd_t *)__va (read_cr3_pa ()) +pgd_index (relocated_restore_code); p4d =p4d_offset (pgd, relocated_restore_code); -if (p4d_large (*p4d)) { +if (p4d_leaf (*p4d)) {set_p4d (p4d,__p4d (p4d_val (*p4d) & ~_PAGE_NX)); goto out; }
arch/x86/xen/mmu_pv.c +1 -1
@@ -1104,7 +1104,7 @@ static void __init xen_cleanmfnmap_p4d(p4d_t *p4d, bool unpin)pud_t *pud_tbl;int i; -if (p4d_large (*p4d)) { +if (p4d_leaf (*p4d)) { pa =p4d_val (*p4d) &PHYSICAL_PAGE_MASK ;xen_free_ro_pages (pa,P4D_SIZE );return ;
Signature · 1 line
2.43.0
PATCH 4/5 mm/treewide: Replace pud_large() with pud_leaf()
In reply to [email protected]From: Peter Xu <[email protected]>
pud_large() is always defined as pud_leaf(). Merge their usages. Chose pud_leaf() because pud_leaf() is a global API, while pud_large() is not.
--- arch/powerpc/mm/book3s64/pgtable.c | 2 +- arch/s390/boot/vmem.c | 2 +- arch/s390/include/asm/pgtable.h | 4 ++-- arch/s390/mm/gmap.c | 2 +- arch/s390/mm/hugetlbpage.c | 4 ++-- arch/s390/mm/pageattr.c | 2 +- arch/s390/mm/pgtable.c | 2 +- arch/s390/mm/vmem.c | 6 +++--- arch/sparc/mm/init_64.c | 2 +- arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/mm/fault.c | 4 ++-- arch/x86/mm/ident_map.c | 2 +- arch/x86/mm/init_64.c | 4 ++-- arch/x86/mm/kasan_init_64.c | 2 +- arch/x86/mm/mem_encrypt_identity.c | 2 +- arch/x86/mm/pat/set_memory.c | 6 +++--- arch/x86/mm/pgtable.c | 2 +- arch/x86/mm/pti.c | 2 +- arch/x86/power/hibernate.c | 2 +- arch/x86/xen/mmu_pv.c | 4 ++-- 20 files changed, 29 insertions(+), 29 deletions(-)
arch/powerpc/mm/book3s64/pgtable.c +1 -1
@@ -130,7 +130,7 @@ void set_pud_at(struct mm_struct *mm, unsigned long addr,WARN_ON (pte_hw_valid (pud_pte (*pudp)));assert_spin_locked (pud_lockptr (mm, pudp)); -WARN_ON (!(pud_large (pud))); +WARN_ON (!(pud_leaf (pud)));#endif trace_hugepage_set_pud (addr,pud_val (pud));return set_pte_at (mm, addr,pudp_ptep (pudp),pud_pte (pud));
arch/s390/boot/vmem.c +1 -1
@@ -366,7 +366,7 @@ static void pgtable_pud_populate(p4d_t *p4d, unsigned long addr, unsigned long e } pmd =boot_crst_alloc (_SEGMENT_ENTRY_EMPTY);pud_populate (&init_mm, pud, pmd); - }else if (pud_large (*pud)) { + }else if (pud_leaf (*pud)) {continue ; }pgtable_pmd_populate (pud, addr, next, mode);
arch/s390/include/asm/pgtable.h +2 -2
@@ -730,7 +730,7 @@ static inline int pud_bad(pud_t pud) {unsigned long type =pud_val (pud) & _REGION_ENTRY_TYPE_MASK; -if (type > _REGION_ENTRY_TYPE_R3 ||pud_large (pud)) +if (type > _REGION_ENTRY_TYPE_R3 ||pud_leaf (pud))return 1 ;if (type < _REGION_ENTRY_TYPE_R3)return 0 ;
@@ -1400,7 +1400,7 @@ static inline unsigned long pud_deref(pud_t pud)unsigned long origin_mask; origin_mask = _REGION_ENTRY_ORIGIN; -if (pud_large (pud)) +if (pud_leaf (pud)) origin_mask = _REGION3_ENTRY_ORIGIN_LARGE;return (unsigned long )__va (pud_val (pud) & origin_mask); }
arch/s390/mm/gmap.c +1 -1
@@ -596,7 +596,7 @@ int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr) pud =pud_offset (p4d, vmaddr);VM_BUG_ON (pud_none (*pud));/* large puds cannot yet be handled */ -if (pud_large (*pud)) +if (pud_leaf (*pud))return -EFAULT ; pmd =pmd_offset (pud, vmaddr);VM_BUG_ON (pmd_none (*pmd));
arch/s390/mm/hugetlbpage.c +2 -2
@@ -224,7 +224,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,if (p4d_present (*p4dp)) { pudp =pud_offset (p4dp, addr);if (pud_present (*pudp)) { -if (pud_large (*pudp)) +if (pud_leaf (*pudp))return (pte_t *) pudp; pmdp =pmd_offset (pudp, addr); }
@@ -240,7 +240,7 @@ int pmd_huge(pmd_t pmd)int pud_huge (pud_t pud) { -return pud_large (pud); +return pud_leaf (pud); }bool __init arch_hugetlb_valid_size (unsigned long size)
arch/s390/mm/pageattr.c +1 -1
@@ -274,7 +274,7 @@ static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end,if (pud_none (*pudp))return -EINVAL ; next =pud_addr_end (addr, end); -if (pud_large (*pudp)) { +if (pud_leaf (*pudp)) { need_split = !!(flags &SET_MEMORY_4K ); need_split |= !!(addr & ~PUD_MASK ); need_split |= !!(addr +PUD_SIZE > next);
arch/s390/mm/pgtable.c +1 -1
@@ -470,7 +470,7 @@ static int pmd_lookup(struct mm_struct *mm, unsigned long addr, pmd_t **pmdp)return -ENOENT ;/* Large PUDs are not supported yet. */ -if (pud_large (*pud)) +if (pud_leaf (*pud))return -EFAULT ; *pmdp =pmd_offset (pud, addr);
arch/s390/mm/vmem.c +3 -3
@@ -329,7 +329,7 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,if (!add) {if (pud_none (*pud))continue ; -if (pud_large (*pud)) { +if (pud_leaf (*pud)) {if (IS_ALIGNED (addr,PUD_SIZE ) &&IS_ALIGNED (next,PUD_SIZE )) {pud_clear (pud);
@@ -350,7 +350,7 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,if (!pmd) goto out;pud_populate (&init_mm, pud, pmd); - }else if (pud_large (*pud)) { + }else if (pud_leaf (*pud)) {continue ; } ret =modify_pmd_table (pud, addr, next, add, direct, altmap);
@@ -599,7 +599,7 @@ pte_t *vmem_get_alloc_pte(unsigned long addr, bool alloc)if (!pmd) goto out;pud_populate (&init_mm, pud, pmd); - }else if (WARN_ON_ONCE (pud_large (*pud))) { + }else if (WARN_ON_ONCE (pud_leaf (*pud))) { goto out; } pmd =pmd_offset (pud, addr);
arch/sparc/mm/init_64.c +1 -1
@@ -1665,7 +1665,7 @@ bool kern_addr_valid(unsigned long addr)if (pud_none (*pud))return false; -if (pud_large (*pud)) +if (pud_leaf (*pud))return pfn_valid (pud_pfn (*pud)); pmd =pmd_offset (pud, addr);
arch/x86/kvm/mmu/mmu.c +1 -1
@@ -3126,7 +3126,7 @@ static int host_pfn_mapping_level(struct kvm *kvm, gfn_t gfn,if (pud_none (pud) || !pud_present (pud)) goto out; -if (pud_large (pud)) { +if (pud_leaf (pud)) { level =PG_LEVEL_1G ; goto out; }
arch/x86/mm/fault.c +2 -2
@@ -376,7 +376,7 @@ static void dump_pagetable(unsigned long address) goto bad;pr_cont ("PUD %lx " ,pud_val (*pud)); -if (!pud_present (*pud) ||pud_large (*pud)) +if (!pud_present (*pud) ||pud_leaf (*pud)) goto out; pmd =pmd_offset (pud, address);
@@ -1046,7 +1046,7 @@ spurious_kernel_fault(unsigned long error_code, unsigned long address)if (!pud_present (*pud))return 0 ; -if (pud_large (*pud)) +if (pud_leaf (*pud))return spurious_kernel_fault_check (error_code, (pte_t *) pud); pmd =pmd_offset (pud, address);
arch/x86/mm/ident_map.c +1 -1
@@ -33,7 +33,7 @@ static int ident_pud_init(struct x86_mapping_info *info, pud_t *pud_page, next = end;/* if this is already a gbpage, this portion is already mapped */ -if (pud_large (*pud)) +if (pud_leaf (*pud))continue ;/* Is using a gbpage allowed? */
arch/x86/mm/init_64.c +2 -2
@@ -617,7 +617,7 @@ phys_pud_init(pud_t *pud_page, unsigned long paddr, unsigned long paddr_end, }if (!pud_none (*pud)) { -if (!pud_large (*pud)) { +if (!pud_leaf (*pud)) { pmd =pmd_offset (pud,0 ); paddr_last = phys_pmd_init(pmd, paddr, paddr_end,
@@ -1163,7 +1163,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end,if (!pud_present (*pud))continue ; -if (pud_large (*pud) && +if (pud_leaf (*pud) &&IS_ALIGNED (addr,PUD_SIZE ) &&IS_ALIGNED (next,PUD_SIZE )) {spin_lock (&init_mm.page_table_lock);
arch/x86/mm/kasan_init_64.c +1 -1
@@ -115,7 +115,7 @@ static void __init kasan_populate_p4d(p4d_t *p4d, unsigned long addr, pud =pud_offset (p4d, addr);do { next =pud_addr_end (addr, end); -if (!pud_large (*pud)) +if (!pud_leaf (*pud))kasan_populate_pud (pud, addr, next, nid); }while (pud++, addr = next, addr != end); }
arch/x86/mm/mem_encrypt_identity.c +1 -1
@@ -145,7 +145,7 @@ static pud_t __init *sme_prepare_pgd(struct sme_populate_pgd_data *ppd)set_pud (pud,__pud (PUD_FLAGS |__pa (pmd))); } -if (pud_large (*pud)) +if (pud_leaf (*pud))return NULL ;return pud;
arch/x86/mm/pat/set_memory.c +3 -3
@@ -684,7 +684,7 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address,return NULL ; *level =PG_LEVEL_1G ; -if (pud_large (*pud) || !pud_present (*pud)) +if (pud_leaf (*pud) || !pud_present (*pud))return (pte_t *)pud; pmd =pmd_offset (pud, address);
@@ -743,7 +743,7 @@ pmd_t *lookup_pmd_address(unsigned long address)return NULL ; pud =pud_offset (p4d, address); -if (pud_none (*pud) ||pud_large (*pud) || !pud_present (*pud)) +if (pud_none (*pud) ||pud_leaf (*pud) || !pud_present (*pud))return NULL ;return pmd_offset (pud, address);
@@ -1274,7 +1274,7 @@ static void unmap_pud_range(p4d_t *p4d, unsigned long start, unsigned long end)*/ while (end - start >=PUD_SIZE ) { -if (pud_large (*pud)) +if (pud_leaf (*pud))pud_clear (pud);else unmap_pmd_range (pud, start, start +PUD_SIZE );
arch/x86/mm/pgtable.c +1 -1
@@ -777,7 +777,7 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)*/ int pud_clear_huge (pud_t *pud) { -if (pud_large (*pud)) { +if (pud_leaf (*pud)) {pud_clear (pud);return 1 ; }
arch/x86/mm/pti.c +1 -1
@@ -217,7 +217,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address) pud =pud_offset (p4d, address);/* The user page tables do not use large mappings: */ -if (pud_large (*pud)) { +if (pud_leaf (*pud)) {WARN_ON (1 );return NULL ; }
arch/x86/power/hibernate.c +1 -1
@@ -170,7 +170,7 @@ int relocate_restore_code(void) goto out; } pud =pud_offset (p4d, relocated_restore_code); -if (pud_large (*pud)) { +if (pud_leaf (*pud)) {set_pud (pud,__pud (pud_val (*pud) & ~_PAGE_NX)); goto out; }
arch/x86/xen/mmu_pv.c +2 -2
@@ -1082,7 +1082,7 @@ static void __init xen_cleanmfnmap_pud(pud_t *pud, bool unpin)pmd_t *pmd_tbl;int i; -if (pud_large (*pud)) { +if (pud_leaf (*pud)) { pa =pud_val (*pud) &PHYSICAL_PAGE_MASK ;xen_free_ro_pages (pa,PUD_SIZE );return ;
@@ -1863,7 +1863,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)if (!pud_present (pud))return 0 ; pa =pud_val (pud) &PTE_PFN_MASK ; -if (pud_large (pud)) +if (pud_leaf (pud))return pa + (vaddr & ~PUD_MASK ); pmd = native_make_pmd(xen_read_phys_ulong(pa + pmd_index(vaddr) *
Signature · 1 line
2.43.0
PATCH 5/5 mm/treewide: Drop pXd_large()
In reply to [email protected]From: Peter Xu <[email protected]>
They're not used anymore, drop all of them.
--- arch/arm/include/asm/pgtable-2level.h | 1 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/powerpc/include/asm/book3s/64/pgtable.h | 2 -- arch/powerpc/include/asm/pgtable.h | 4 ---- arch/s390/include/asm/pgtable.h | 8 ++++---- arch/sparc/include/asm/pgtable_64.h | 8 ++++---- arch/x86/include/asm/pgtable.h | 15 +++++++-------- 7 files changed, 15 insertions(+), 24 deletions(-)
arch/arm/include/asm/pgtable-2level.h +0 -1
@@ -213,7 +213,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)#define pmd_pfn (pmd) (__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) -#define pmd_large (pmd) (pmd_val(pmd) & 2)#define pmd_leaf (pmd) (pmd_val(pmd) & 2)#define pmd_bad (pmd) (pmd_val(pmd) & 2)#define pmd_present (pmd) (pmd_val(pmd))
arch/arm/include/asm/pgtable-3level.h +0 -1
@@ -118,7 +118,6 @@ PMD_TYPE_TABLE)#define pmd_sect (pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_SECT) -#define pmd_large (pmd) pmd_sect(pmd)#define pmd_leaf (pmd) pmd_sect(pmd)#define pud_clear (pudp) \
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -2
@@ -1441,7 +1441,6 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va*/ #define pmd_is_leaf pmd_is_leaf#define pmd_leaf pmd_is_leaf -#define pmd_large pmd_leafstatic inline bool pmd_is_leaf (pmd_t pmd) {return !!(pmd_raw (pmd) &cpu_to_be64 (_PAGE_PTE));
@@ -1449,7 +1448,6 @@ static inline bool pmd_is_leaf(pmd_t pmd)#define pud_is_leaf pud_is_leaf#define pud_leaf pud_is_leaf -#define pud_large pud_leafstatic inline bool pud_is_leaf (pud_t pud) {return !!(pud_raw (pud) &cpu_to_be64 (_PAGE_PTE));
arch/powerpc/include/asm/pgtable.h +0 -4
@@ -101,10 +101,6 @@ void poking_init(void);extern unsigned long ioremap_bot;extern const pgprot_t protection_map[16 ]; -#ifndef pmd_large -#define pmd_large (pmd) 0 -#endif -/* can we use this in kvm */ unsigned long vmalloc_to_phys (void *vmalloc_addr);
arch/s390/include/asm/pgtable.h +4 -4
@@ -705,16 +705,16 @@ static inline int pud_none(pud_t pud)return pud_val (pud) == _REGION3_ENTRY_EMPTY; } -#define pud_leaf pud_large -static inline int pud_large (pud_t pud) +#define pud_leaf pud_leaf +static inline int pud_leaf (pud_t pud) {if ((pud_val (pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)return 0 ;return !!(pud_val (pud) & _REGION3_ENTRY_LARGE); } -#define pmd_leaf pmd_large -static inline int pmd_large (pmd_t pmd) +#define pmd_leaf pmd_leaf +static inline int pmd_leaf (pmd_t pmd) {return (pmd_val (pmd) & _SEGMENT_ENTRY_LARGE) !=0 ; }
arch/sparc/include/asm/pgtable_64.h +4 -4
@@ -680,8 +680,8 @@ static inline unsigned long pte_special(pte_t pte)return pte_val (pte) & _PAGE_SPECIAL; } -#define pmd_leaf pmd_large -static inline unsigned long pmd_large (pmd_t pmd) +#define pmd_leaf pmd_leaf +static inline unsigned long pmd_leaf (pmd_t pmd) {pte_t pte =__pte (pmd_val (pmd));
@@ -867,8 +867,8 @@ static inline pmd_t *pud_pgtable(pud_t pud)/* only used by the stubbed out hugetlb gup code, should never be called */ #define p4d_page (p4d) NULL -#define pud_leaf pud_large -static inline unsigned long pud_large (pud_t pud) +#define pud_leaf pud_leaf +static inline unsigned long pud_leaf (pud_t pud) {pte_t pte =__pte (pud_val (pud));
arch/x86/include/asm/pgtable.h +7 -8
@@ -251,8 +251,8 @@ static inline unsigned long pgd_pfn(pgd_t pgd)return (pgd_val (pgd) &PTE_PFN_MASK ) >>PAGE_SHIFT ; } -#define p4d_leaf p4d_large -static inline int p4d_large (p4d_t p4d) +#define p4d_leaf p4d_leaf +static inline int p4d_leaf (p4d_t p4d) {/* No 512 GiB pages yet */ return 0 ;
@@ -260,8 +260,8 @@ static inline int p4d_large(p4d_t p4d)#define pte_page (pte) pfn_to_page(pte_pfn(pte)) -#define pmd_leaf pmd_large -static inline int pmd_large (pmd_t pte) +#define pmd_leaf pmd_leaf +static inline int pmd_leaf (pmd_t pte) {return pmd_flags (pte) & _PAGE_PSE; }
@@ -1085,8 +1085,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)*/ #define pud_page (pud) pfn_to_page(pud_pfn(pud)) -#define pud_leaf pud_large -static inline int pud_large (pud_t pud) +static inline int pud_leaf (pud_t pud) {return (pud_val (pud) & (_PAGE_PSE | _PAGE_PRESENT)) == (_PAGE_PSE | _PAGE_PRESENT);
@@ -1097,12 +1096,12 @@ static inline int pud_bad(pud_t pud) return (pud_flags(pud) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0; }#else -#define pud_leaf pud_large -static inline int pud_large (pud_t pud) +static inline int pud_leaf (pud_t pud) {return 0 ; }#endif /* CONFIG_PGTABLE_LEVELS > 2 */ +#define pud_leaf pud_leaf#if CONFIG_PGTABLE_LEVELS >3 static inline int p4d_none (p4d_t p4d)
Signature · 1 line
2.43.0
PATCH 3/5 mm/treewide: Replace pmd_large() with pmd_leaf()
In reply to [email protected]From: Peter Xu <[email protected]>
pmd_large() is always defined as pmd_leaf(). Merge their usages. Chose pmd_leaf() because pmd_leaf() is a global API, while pmd_large() is not.
--- arch/arm/mm/dump.c | 4 ++-- arch/powerpc/mm/book3s64/pgtable.c | 2 +- arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +- arch/powerpc/mm/pgtable_64.c | 2 +- arch/s390/boot/vmem.c | 2 +- arch/s390/include/asm/pgtable.h | 8 ++++---- arch/s390/mm/gmap.c | 12 ++++++------ arch/s390/mm/hugetlbpage.c | 2 +- arch/s390/mm/pageattr.c | 2 +- arch/s390/mm/pgtable.c | 6 +++--- arch/s390/mm/vmem.c | 6 +++--- arch/sparc/mm/init_64.c | 4 ++-- arch/x86/boot/compressed/ident_map_64.c | 2 +- arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/mm/fault.c | 8 ++++---- arch/x86/mm/init_32.c | 2 +- arch/x86/mm/init_64.c | 8 ++++---- arch/x86/mm/kasan_init_64.c | 2 +- arch/x86/mm/mem_encrypt_identity.c | 4 ++-- arch/x86/mm/pat/set_memory.c | 4 ++-- arch/x86/mm/pgtable.c | 2 +- arch/x86/mm/pti.c | 4 ++-- arch/x86/power/hibernate.c | 2 +- arch/x86/xen/mmu_pv.c | 4 ++-- drivers/misc/sgi-gru/grufault.c | 2 +- 25 files changed, 49 insertions(+), 49 deletions(-)
arch/arm/mm/dump.c +2 -2
@@ -349,12 +349,12 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)for (i =0 ; i <PTRS_PER_PMD ; i++, pmd++) { addr = start + i *PMD_SIZE ; domain =get_domain_name (pmd); -if (pmd_none (*pmd) ||pmd_large (*pmd) || !pmd_present (*pmd)) +if (pmd_none (*pmd) ||pmd_leaf (*pmd) || !pmd_present (*pmd))note_page (st, addr,4 ,pmd_val (*pmd), domain);else walk_pte (st, pmd, addr, domain); -if (SECTION_SIZE <PMD_SIZE &&pmd_large (pmd[1 ])) { +if (SECTION_SIZE <PMD_SIZE &&pmd_leaf (pmd[1 ])) { addr +=SECTION_SIZE ; pmd++; domain =get_domain_name (pmd);
arch/powerpc/mm/book3s64/pgtable.c +1 -1
@@ -113,7 +113,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,WARN_ON (pte_hw_valid (pmd_pte (*pmdp)) && !pte_protnone (pmd_pte (*pmdp)));assert_spin_locked (pmd_lockptr (mm, pmdp)); -WARN_ON (!(pmd_large (pmd))); +WARN_ON (!(pmd_leaf (pmd)));#endif trace_hugepage_set_pmd (addr,pmd_val (pmd));return set_pte_at (mm, addr,pmdp_ptep (pmdp),pmd_pte (pmd));
arch/powerpc/mm/book3s64/radix_pgtable.c +1 -1
@@ -924,7 +924,7 @@ bool vmemmap_can_optimize(struct vmem_altmap *altmap, struct dev_pagemap *pgmap)int __meminit vmemmap_check_pmd (pmd_t *pmdp,int node,unsigned long addr,unsigned long next) { -int large =pmd_large (*pmdp); +int large =pmd_leaf (*pmdp);if (large)vmemmap_verify (pmdp_ptep (pmdp), node, addr, next);
arch/powerpc/mm/pgtable_64.c +1 -1
@@ -132,7 +132,7 @@ struct page *pmd_page(pmd_t pmd)* enabled so these checks can't be used. */ if (!IS_ENABLED (CONFIG_HAVE_ARCH_HUGE_VMAP )) -VM_WARN_ON (!(pmd_large (pmd) ||pmd_huge (pmd))); +VM_WARN_ON (!(pmd_leaf (pmd) ||pmd_huge (pmd)));return pte_page (pmd_pte (pmd)); }return virt_to_page (pmd_page_vaddr (pmd));
arch/s390/boot/vmem.c +1 -1
@@ -333,7 +333,7 @@ static void pgtable_pmd_populate(pud_t *pud, unsigned long addr, unsigned long e } pte =boot_pte_alloc ();pmd_populate (&init_mm, pmd, pte); - }else if (pmd_large (*pmd)) { + }else if (pmd_leaf (*pmd)) {continue ; }pgtable_pte_populate (pmd, addr, next, mode);
arch/s390/include/asm/pgtable.h +4 -4
@@ -721,7 +721,7 @@ static inline int pmd_large(pmd_t pmd)static inline int pmd_bad (pmd_t pmd) { -if ((pmd_val (pmd) & _SEGMENT_ENTRY_TYPE_MASK) >0 ||pmd_large (pmd)) +if ((pmd_val (pmd) & _SEGMENT_ENTRY_TYPE_MASK) >0 ||pmd_leaf (pmd))return 1 ;return (pmd_val (pmd) & ~_SEGMENT_ENTRY_BITS) !=0 ; }
@@ -820,8 +820,8 @@ static inline int pte_protnone(pte_t pte)static inline int pmd_protnone (pmd_t pmd) { -/* pmd_large(pmd) implies pmd_present(pmd) */ -return pmd_large (pmd) && !(pmd_val (pmd) & _SEGMENT_ENTRY_READ); +/* pmd_leaf(pmd) implies pmd_present(pmd) */ +return pmd_leaf (pmd) && !(pmd_val (pmd) & _SEGMENT_ENTRY_READ); }#endif
@@ -1385,7 +1385,7 @@ static inline unsigned long pmd_deref(pmd_t pmd)unsigned long origin_mask; origin_mask = _SEGMENT_ENTRY_ORIGIN; -if (pmd_large (pmd)) +if (pmd_leaf (pmd)) origin_mask = _SEGMENT_ENTRY_ORIGIN_LARGE;return (unsigned long )__va (pmd_val (pmd) & origin_mask); }
arch/s390/mm/gmap.c +6 -6
@@ -601,7 +601,7 @@ int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr) pmd =pmd_offset (pud, vmaddr);VM_BUG_ON (pmd_none (*pmd));/* Are we allowed to use huge pages? */ -if (pmd_large (*pmd) && !gmap->mm->context.allow_gmap_hpage_1m) +if (pmd_leaf (*pmd) && !gmap->mm->context.allow_gmap_hpage_1m)return -EFAULT ;/* Link gmap segment table entry location to page table. */ rc =radix_tree_preload (GFP_KERNEL_ACCOUNT );
@@ -613,7 +613,7 @@ int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr) rc =radix_tree_insert (&gmap->host_to_guest, vmaddr >>PMD_SHIFT , table);if (!rc) { -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) { *table = (pmd_val (*pmd) & _SEGMENT_ENTRY_HARDWARE_BITS_LARGE) | _SEGMENT_ENTRY_GMAP_UC;
@@ -943,7 +943,7 @@ static inline pmd_t *gmap_pmd_op_walk(struct gmap *gmap, unsigned long gaddr) }/* 4k page table entries are locked via the pte (pte_alloc_map_lock). */ -if (!pmd_large (*pmdp)) +if (!pmd_leaf (*pmdp))spin_unlock (&gmap->guest_table_lock);return pmdp; }
@@ -955,7 +955,7 @@ static inline pmd_t *gmap_pmd_op_walk(struct gmap *gmap, unsigned long gaddr)*/ static inline void gmap_pmd_op_end (struct gmap *gmap,pmd_t *pmdp) { -if (pmd_large (*pmdp)) +if (pmd_leaf (*pmdp))spin_unlock (&gmap->guest_table_lock); }
@@ -1066,7 +1066,7 @@ static int gmap_protect_range(struct gmap *gmap, unsigned long gaddr, rc = -EAGAIN ; pmdp =gmap_pmd_op_walk (gmap, gaddr);if (pmdp) { -if (!pmd_large (*pmdp)) { +if (!pmd_leaf (*pmdp)) { rc =gmap_protect_pte (gmap, gaddr, pmdp, prot, bits);if (!rc) {
@@ -2498,7 +2498,7 @@ void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long bitmap[4],if (!pmdp)return ; -if (pmd_large (*pmdp)) { +if (pmd_leaf (*pmdp)) {if (gmap_test_and_clear_dirty_pmd (gmap, pmdp, gaddr))bitmap_fill (bitmap, _PAGE_ENTRIES); }else {
arch/s390/mm/hugetlbpage.c +1 -1
@@ -235,7 +235,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,int pmd_huge (pmd_t pmd) { -return pmd_large (pmd); +return pmd_leaf (pmd); }int pud_huge (pud_t pud)
arch/s390/mm/pageattr.c +1 -1
@@ -185,7 +185,7 @@ static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,if (pmd_none (*pmdp))return -EINVAL ; next =pmd_addr_end (addr, end); -if (pmd_large (*pmdp)) { +if (pmd_leaf (*pmdp)) { need_split = !!(flags &SET_MEMORY_4K ); need_split |= !!(addr & ~PMD_MASK ); need_split |= !!(addr +PMD_SIZE > next);
arch/s390/mm/pgtable.c +3 -3
@@ -827,7 +827,7 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,return key ? -EFAULT :0 ; } -if (pmd_large (*pmdp)) { +if (pmd_leaf (*pmdp)) { paddr =pmd_val (*pmdp) &HPAGE_MASK ; paddr |= addr & ~HPAGE_MASK ;/*
@@ -938,7 +938,7 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr)return 0 ; } -if (pmd_large (*pmdp)) { +if (pmd_leaf (*pmdp)) { paddr =pmd_val (*pmdp) &HPAGE_MASK ; paddr |= addr & ~HPAGE_MASK ; cc =page_reset_referenced (paddr);
@@ -1002,7 +1002,7 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,return 0 ; } -if (pmd_large (*pmdp)) { +if (pmd_leaf (*pmdp)) { paddr =pmd_val (*pmdp) &HPAGE_MASK ; paddr |= addr & ~HPAGE_MASK ; *key =page_get_storage_key (paddr);
arch/s390/mm/vmem.c +3 -3
@@ -236,7 +236,7 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,if (!add) {if (pmd_none (*pmd))continue ; -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {if (IS_ALIGNED (addr,PMD_SIZE ) &&IS_ALIGNED (next,PMD_SIZE )) {if (!direct)
@@ -281,7 +281,7 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,if (!pte) goto out;pmd_populate (&init_mm, pmd, pte); - }else if (pmd_large (*pmd)) { + }else if (pmd_leaf (*pmd)) {if (!direct)vmemmap_use_sub_pmd (addr, next);continue ;
@@ -610,7 +610,7 @@ pte_t *vmem_get_alloc_pte(unsigned long addr, bool alloc)if (!pte) goto out;pmd_populate (&init_mm, pmd, pte); - }else if (WARN_ON_ONCE (pmd_large (*pmd))) { + }else if (WARN_ON_ONCE (pmd_leaf (*pmd))) { goto out; } ptep =pte_offset_kernel (pmd, addr);
arch/sparc/mm/init_64.c +2 -2
@@ -1672,7 +1672,7 @@ bool kern_addr_valid(unsigned long addr)if (pmd_none (*pmd))return false; -if (pmd_large (*pmd)) +if (pmd_leaf (*pmd))return pfn_valid (pmd_pfn (*pmd)); pte =pte_offset_kernel (pmd, addr);
@@ -2968,7 +2968,7 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,struct mm_struct *mm;pmd_t entry = *pmd; -if (!pmd_large (entry) || !pmd_young (entry)) +if (!pmd_leaf (entry) || !pmd_young (entry))return ; pte =pmd_val (entry);
arch/x86/boot/compressed/ident_map_64.c +1 -1
@@ -284,7 +284,7 @@ static int set_clr_page_flags(struct x86_mapping_info *info, pudp =pud_offset (p4dp, address); pmdp =pmd_offset (pudp, address); -if (pmd_large (*pmdp)) +if (pmd_leaf (*pmdp)) ptep =split_large_pmd (info, pmdp, address);else ptep =pte_offset_kernel (pmdp, address);
arch/x86/kvm/mmu/mmu.c +1 -1
@@ -3135,7 +3135,7 @@ static int host_pfn_mapping_level(struct kvm *kvm, gfn_t gfn,if (pmd_none (pmd) || !pmd_present (pmd)) goto out; -if (pmd_large (pmd)) +if (pmd_leaf (pmd)) level =PG_LEVEL_2M ; out:
arch/x86/mm/fault.c +4 -4
@@ -250,7 +250,7 @@ static noinline int vmalloc_fault(unsigned long address)if (!pmd_k)return -1 ; -if (pmd_large (*pmd_k)) +if (pmd_leaf (*pmd_k))return 0 ; pte_k =pte_offset_kernel (pmd_k, address);
@@ -319,7 +319,7 @@ static void dump_pagetable(unsigned long address)* And let's rather not kmap-atomic the pte, just in case * it's allocated already: */ -if (!low_pfn (pmd_pfn (*pmd)) || !pmd_present (*pmd) ||pmd_large (*pmd)) +if (!low_pfn (pmd_pfn (*pmd)) || !pmd_present (*pmd) ||pmd_leaf (*pmd)) goto out; pte =pte_offset_kernel (pmd, address);
@@ -384,7 +384,7 @@ static void dump_pagetable(unsigned long address) goto bad;pr_cont ("PMD %lx " ,pmd_val (*pmd)); -if (!pmd_present (*pmd) ||pmd_large (*pmd)) +if (!pmd_present (*pmd) ||pmd_leaf (*pmd)) goto out; pte =pte_offset_kernel (pmd, address);
@@ -1053,7 +1053,7 @@ spurious_kernel_fault(unsigned long error_code, unsigned long address)if (!pmd_present (*pmd))return 0 ; -if (pmd_large (*pmd)) +if (pmd_leaf (*pmd))return spurious_kernel_fault_check (error_code, (pte_t *) pmd); pte =pte_offset_kernel (pmd, address);
arch/x86/mm/init_32.c +1 -1
@@ -463,7 +463,7 @@ void __init native_pagetable_init(void)break ;/* should not be large page here */ -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {pr_warn ("try to clear pte for ram above max_low_pfn: pfn: %lx pmd: %p pmd phys: %lx, but pmd is big page and is not using pte !\n" , pfn, pmd,__pa (pmd));BUG_ON (1 );
arch/x86/mm/init_64.c +4 -4
@@ -530,7 +530,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, unsigned long paddr_end, }if (!pmd_none (*pmd)) { -if (!pmd_large (*pmd)) { +if (!pmd_leaf (*pmd)) {spin_lock (&init_mm.page_table_lock); pte = (pte_t *)pmd_page_vaddr (*pmd); paddr_last = phys_pte_init(pte, paddr,
@@ -1114,7 +1114,7 @@ remove_pmd_table(pmd_t *pmd_start, unsigned long addr, unsigned long end,if (!pmd_present (*pmd))continue ; -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {if (IS_ALIGNED (addr,PMD_SIZE ) &&IS_ALIGNED (next,PMD_SIZE )) {if (!direct)
@@ -1520,9 +1520,9 @@ void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,int __meminit vmemmap_check_pmd (pmd_t *pmd,int node,unsigned long addr,unsigned long next) { -int large =pmd_large (*pmd); +int large =pmd_leaf (*pmd); -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {vmemmap_verify ((pte_t *)pmd, node, addr, next);vmemmap_use_sub_pmd (addr, next); }
arch/x86/mm/kasan_init_64.c +1 -1
@@ -95,7 +95,7 @@ static void __init kasan_populate_pud(pud_t *pud, unsigned long addr, pmd =pmd_offset (pud, addr);do { next =pmd_addr_end (addr, end); -if (!pmd_large (*pmd)) +if (!pmd_leaf (*pmd))kasan_populate_pmd (pmd, addr, next, nid); }while (pmd++, addr = next, addr != end); }
arch/x86/mm/mem_encrypt_identity.c +2 -2
@@ -161,7 +161,7 @@ static void __init sme_populate_pgd_large(struct sme_populate_pgd_data *ppd)return ; pmd =pmd_offset (pud, ppd->vaddr); -if (pmd_large (*pmd)) +if (pmd_leaf (*pmd))return ;set_pmd (pmd,__pmd (ppd->paddr | ppd->pmd_flags));
@@ -185,7 +185,7 @@ static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd)set_pmd (pmd,__pmd (PMD_FLAGS |__pa (pte))); } -if (pmd_large (*pmd)) +if (pmd_leaf (*pmd))return ; pte =pte_offset_kernel (pmd, ppd->vaddr);
arch/x86/mm/pat/set_memory.c +2 -2
@@ -692,7 +692,7 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address,return NULL ; *level =PG_LEVEL_2M ; -if (pmd_large (*pmd) || !pmd_present (*pmd)) +if (pmd_leaf (*pmd) || !pmd_present (*pmd))return (pte_t *)pmd; *level =PG_LEVEL_4K ;
@@ -1229,7 +1229,7 @@ static void unmap_pmd_range(pud_t *pud, unsigned long start, unsigned long end)* Try to unmap in 2M chunks. */ while (end - start >=PMD_SIZE ) { -if (pmd_large (*pmd)) +if (pmd_leaf (*pmd))pmd_clear (pmd);else __unmap_pmd_range (pud, pmd, start, start +PMD_SIZE );
arch/x86/mm/pgtable.c +1 -1
@@ -792,7 +792,7 @@ int pud_clear_huge(pud_t *pud)*/ int pmd_clear_huge (pmd_t *pmd) { -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {pmd_clear (pmd);return 1 ; }
arch/x86/mm/pti.c +2 -2
@@ -252,7 +252,7 @@ static pte_t *pti_user_pagetable_walk_pte(unsigned long address)return NULL ;/* We can't do anything sensible if we hit a large mapping. */ -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {WARN_ON (1 );return NULL ; }
@@ -341,7 +341,7 @@ pti_clone_pgtable(unsigned long start, unsigned long end,continue ; } -if (pmd_large (*pmd) || level ==PTI_CLONE_PMD ) { +if (pmd_leaf (*pmd) || level ==PTI_CLONE_PMD ) { target_pmd =pti_user_pagetable_walk_pmd (addr);if (WARN_ON (!target_pmd))return ;
arch/x86/power/hibernate.c +1 -1
@@ -175,7 +175,7 @@ int relocate_restore_code(void) goto out; } pmd =pmd_offset (pud, relocated_restore_code); -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) {set_pmd (pmd,__pmd (pmd_val (*pmd) & ~_PAGE_NX)); goto out; }
arch/x86/xen/mmu_pv.c +2 -2
@@ -1059,7 +1059,7 @@ static void __init xen_cleanmfnmap_pmd(pmd_t *pmd, bool unpin)pte_t *pte_tbl;int i; -if (pmd_large (*pmd)) { +if (pmd_leaf (*pmd)) { pa =pmd_val (*pmd) &PHYSICAL_PAGE_MASK ;xen_free_ro_pages (pa,PMD_SIZE );return ;
@@ -1871,7 +1871,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)if (!pmd_present (pmd))return 0 ; pa =pmd_val (pmd) &PTE_PFN_MASK ; -if (pmd_large (pmd)) +if (pmd_leaf (pmd))return pa + (vaddr & ~PMD_MASK ); pte = native_make_pte(xen_read_phys_ulong(pa + pte_index(vaddr) *
drivers/misc/sgi-gru/grufault.c +1 -1
@@ -227,7 +227,7 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,if (unlikely (pmd_none (*pmdp))) goto err;#ifdef CONFIG_X86_64 -if (unlikely (pmd_large (*pmdp))) +if (unlikely (pmd_leaf (*pmdp))) pte =ptep_get ((pte_t *)pmdp); else#endif
Signature · 1 line
2.43.0
Le 28/02/2024 à 09:53, [email protected] a écrit :
Quoted 8 lines
From: Peter Xu <[email protected]>
[based on latest akpm/mm-unstable, commit
1274e7646240]These two APIs are mostly always the same. It's confusing to have both of them. Merge them into one. Here I used
pXd_leaf()only becausepXd_leaf()is a global API which is always defined, whilepXd_large()is not.
Quoted 7 lines
We have yet one more API that is similar which is
pXd_huge(), but that's even trickier, so let's do it step by step.Some cautions are needed on either x86 or ppc: x86 is currently the only user of
p4d_large(), while ppc used to definepXd_large()only with THP, while it is not the case forpXd_leaf(). For the rest archs, afaict they're 100% identical.
Maybe would also be a good opportunity to replace pmd_is_leaf() by pmd_leaf() and the same for pud_is_leaf()
Christophe
Quoted 46 lines
Only lightly tested on x86.
Please have a look, thanks.
Peter Xu (5):
mm/ppc: DefinepXd_large()withpXd_leaf()mm/x86: Replacep4d_large()withp4d_leaf()mm/treewide: Replacepmd_large()withpmd_leaf()mm/treewide: Replacepud_large()withpud_leaf()mm/treewide: DroppXd_large()arch/arm/include/asm/pgtable-2level.h | 1 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/arm/mm/dump.c | 4 ++-- arch/powerpc/include/asm/book3s/64/pgtable.h | 14 -------------- arch/powerpc/include/asm/pgtable.h | 4 ---- arch/powerpc/mm/book3s64/pgtable.c | 4 ++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +- arch/powerpc/mm/pgtable_64.c | 2 +- arch/s390/boot/vmem.c | 4 ++-- arch/s390/include/asm/pgtable.h | 20 ++++++++++---------- arch/s390/mm/gmap.c | 14 +++++++------- arch/s390/mm/hugetlbpage.c | 6 +++--- arch/s390/mm/pageattr.c | 4 ++-- arch/s390/mm/pgtable.c | 8 ++++---- arch/s390/mm/vmem.c | 12 ++++++------ arch/sparc/include/asm/pgtable_64.h | 8 ++++---- arch/sparc/mm/init_64.c | 6 +++--- arch/x86/boot/compressed/ident_map_64.c | 2 +- arch/x86/include/asm/pgtable.h | 15 +++++++-------- arch/x86/kvm/mmu/mmu.c | 4 ++-- arch/x86/mm/fault.c | 16 ++++++++-------- arch/x86/mm/ident_map.c | 2 +- arch/x86/mm/init_32.c | 2 +- arch/x86/mm/init_64.c | 14 +++++++------- arch/x86/mm/kasan_init_64.c | 4 ++-- arch/x86/mm/mem_encrypt_identity.c | 6 +++--- arch/x86/mm/pat/set_memory.c | 14 +++++++------- arch/x86/mm/pgtable.c | 4 ++-- arch/x86/mm/pti.c | 8 ++++---- arch/x86/power/hibernate.c | 6 +++--- arch/x86/xen/mmu_pv.c | 10 +++++----- drivers/misc/sgi-gru/grufault.c | 2 +- 32 files changed, 101 insertions(+), 122 deletions(-)
Quoted 12 lines · Christophe Leroy
Le 28/02/2024 à 09:53, [email protected] a écrit :
Quoted 11 lines
From: Peter Xu <[email protected]>
[based on latest akpm/mm-unstable, commit
1274e7646240]These two APIs are mostly always the same. It's confusing to have both of them. Merge them into one. Here I used
pXd_leaf()only becausepXd_leaf()is a global API which is always defined, whilepXd_large()is not.We have yet one more API that is similar which is
pXd_huge(), but that's even trickier, so let's do it step by step.
Quoted 7 lines
Quoted 4 lines
Some cautions are needed on either x86 or ppc: x86 is currently the only user of
p4d_large(), while ppc used to definepXd_large()only with THP, while it is not the case forpXd_leaf(). For the rest archs, afaict they're 100% identical.Maybe would also be a good opportunity to replace
pmd_is_leaf()bypmd_leaf()and the same forpud_is_leaf()
Sure, while I'll wait for some more comments, I can add one on top when repost. Thanks,
Signature · 1 line
Peter Xu
kernel test robot
build botRe: [PATCH 5/5] mm/treewide: Drop pXd_large()
In reply to [email protected]kernel test robot noticed the following build errors:
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/peterx-redhat-com/mm-ppc-Define-pXd_large-with-pXd_leaf/20240228-170049 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20240228085350.520953-6-peterx%40redhat.com patch subject: [PATCH 5/5] mm/treewide: Drop pXd_large() config: i386-buildonly-randconfig-001-20240228 (https://download.01.org/0day-ci/archive/20240229/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240229/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/x86/kernel/asm-offsets.c:14:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:9:
In file included from include/linux/sched/task.h:13:
In file included from include/linux/uaccess.h:11:
In file included from arch/x86/include/asm/uaccess.h:17:
In file included from arch/x86/include/asm/tlbflush.h:16:
>> arch/x86/include/asm/pgtable.h:1099:19: error: redefinition of 'pud_leaf'
1099 | static inline int pud_leaf(pud_t pud)
| ^
include/asm-generic/pgtable-nopmd.h:34:19: note: previous definition is here
34 | static inline int pud_leaf(pud_t pud) { return 0; }
| ^ 1 error generated.
make[3]: *** [scripts/Makefile.build:116: arch/x86/kernel/asm-offsets.s] Error 1 shuffle=298844285 make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1191: prepare0] Error 2 shuffle=298844285
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:240: __sub-make] Error 2 shuffle=298844285
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:240: __sub-make] Error 2 shuffle=298844285
make: Target 'prepare' not remade because of errors.
vim +/pud_leaf +1099 arch/x86/include/asm/pgtable.h
1093
1094 static inline int pud_bad(pud_t pud)
1095 {
1096 return (pud_flags(pud) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0;
1097 }
1098 #else
> 1099 static inline int pud_leaf(pud_t pud)
1100 {
1101 return 0;
1102 }
1103 #endif /* CONFIG_PGTABLE_LEVELS > 2 */
1104 #define pud_leaf pud_leaf
1105
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 5/5] mm/treewide: Drop pXd_large()
Quoted 6 lines · kernel test robot
Quoted 1 line
Quoted 1 line
arch/x86/include/asm/pgtable.h:1099:19: error: redefinition of 'pud_leaf'1099 | static inline int
pud_leaf(pud_t pud)
| ^
include/asm-generic/pgtable-nopmd.h:34:19: note: previous definition is here34 | static inline int pud_leaf(pud_t pud) { return 0; } | ^
This is CONFIG_PGTABLE_LEVELS=2. IIUC patch 5 didn't do anything wrong, but when renaming pud_large() it caused this confliction, while in the past it was a silent confliction between the old pud_leaf() macro and pud_leaf() defintion, the macro could have silently overwrote the function.
IIUC such pud_leaf() is not needed as we have a global fallback. I'll add a pre-requisite patch to remove such pXd_leaf() definitions.
Signature · 1 line
Peter Xu