hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10479 ---------------------------------------- x86 and riscv have identical pudp_invalidate() implementations. Move it to mm/pgtable-generic.c with the __HAVE_ARCH_PUDP_INVALIDATE override guard. PowerPC keeps its own implementation. In the later patch, arm64 will use the generic implementation too. No functional change intended. Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com> --- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 + arch/x86/include/asm/pgtable.h | 3 --- arch/x86/mm/pgtable.c | 12 ------------ include/linux/pgtable.h | 7 +++++++ mm/pgtable-generic.c | 14 ++++++++++++++ 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 7d5042250d50..f90dea4a80eb 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1400,6 +1400,7 @@ static inline pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, #define __HAVE_ARCH_PMDP_INVALIDATE extern pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp); +#define __HAVE_ARCH_PUDP_INVALIDATE extern pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, pud_t *pudp); diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index eab7e5f9b317..cbc04229fd26 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1458,9 +1458,6 @@ static inline pud_t pudp_establish(struct vm_area_struct *vma, extern pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp); -pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, - pud_t *pudp); - /* * Page table pages are page-aligned. The lower half of the top * level is used for userspace and the top half for the kernel. diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 269c995ceec5..7c8696f7c466 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -636,18 +636,6 @@ pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma, unsigned long address, } #endif -#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && \ - defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) -pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, - pud_t *pudp) -{ - VM_WARN_ON_ONCE(!pud_present(*pudp)); - pud_t old = pudp_establish(vma, address, pudp, pud_mkinvalid(*pudp)); - flush_pud_tlb_range(vma, address, address + HPAGE_PUD_SIZE); - return old; -} -#endif - /** * reserve_top_address - reserves a hole in the top of kernel address space * @reserve - size of hole to reserve diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 23206bf399ed..6d1033062f12 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -997,6 +997,13 @@ extern pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp); #endif +#ifndef __HAVE_ARCH_PUDP_INVALIDATE +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD +extern pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, + pud_t *pudp); +#endif +#endif + #ifndef __HAVE_ARCH_PTE_SAME static inline int pte_same(pte_t pte_a, pte_t pte_b) { diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index 4fcd959dcc4d..b424a0d14464 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -212,6 +212,20 @@ pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma, unsigned long address, } #endif +#ifndef __HAVE_ARCH_PUDP_INVALIDATE +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD +pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, + pud_t *pudp) +{ + VM_WARN_ON_ONCE(!pud_present(*pudp)); + pud_t old = pudp_establish(vma, address, pudp, pud_mkinvalid(*pudp)); + + flush_pud_tlb_range(vma, address, address + HPAGE_PUD_SIZE); + return old; +} +#endif +#endif + #ifndef pmdp_collapse_flush pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) -- 2.43.0