Message ID | 00bf7935d65826eee547ac195d7854b1c946dbc5.1737637631.git.zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | remove tlb_remove_page_ptdesc() | expand |
Context | Check | Description |
---|---|---|
conchuod/vmtest-fixes-PR | fail | merge-conflict |
bjorn/build-rv32-defconfig | success | build-rv32-defconfig |
bjorn/build-rv64-clang-allmodconfig | success | build-rv64-clang-allmodconfig |
bjorn/build-rv64-gcc-allmodconfig | success | build-rv64-gcc-allmodconfig |
bjorn/build-rv64-nommu-k210-defconfig | success | build-rv64-nommu-k210-defconfig |
bjorn/build-rv64-nommu-k210-virt | success | build-rv64-nommu-k210-virt |
bjorn/checkpatch | success | checkpatch |
bjorn/dtb-warn-rv64 | success | dtb-warn-rv64 |
bjorn/header-inline | success | header-inline |
bjorn/kdoc | success | kdoc |
bjorn/module-param | success | module-param |
bjorn/verify-fixes | success | verify-fixes |
bjorn/verify-signedoff | success | verify-signedoff |
On Thu, Jan 23, 2025 at 09:26:17PM +0800, Qi Zheng wrote: > If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table() > will fall back to pagetable_dtor() + tlb_remove_page(). So let's use > tlb_remove_table() unconditionally to free page table pages. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> I think we can clean up more :-) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index cc8c3bd0e7c2..1f7c3082a36d 100644 --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -239,5 +239,4 @@ void hyperv_setup_mmu_ops(void) pr_info("Using hypercall for remote TLB flush\n"); pv_ops.mmu.flush_tlb_multi = hyperv_flush_tlb_multi; - pv_ops.mmu.tlb_remove_table = tlb_remove_table; } diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index 041aff51eb50..38a632a282d4 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -91,11 +91,6 @@ static inline void __flush_tlb_multi(const struct cpumask *cpumask, PVOP_VCALL2(mmu.flush_tlb_multi, cpumask, info); } -static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - PVOP_VCALL2(mmu.tlb_remove_table, tlb, table); -} - static inline void paravirt_arch_exit_mmap(struct mm_struct *mm) { PVOP_VCALL1(mmu.exit_mmap, mm); diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index fea56b04f436..e26633c00455 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -134,8 +134,6 @@ struct pv_mmu_ops { void (*flush_tlb_multi)(const struct cpumask *cpus, const struct flush_tlb_info *info); - void (*tlb_remove_table)(struct mmu_gather *tlb, void *table); - /* Hook for intercepting the destruction of an mm_struct. */ void (*exit_mmap)(struct mm_struct *mm); void (*notify_page_enc_status_changed)(unsigned long pfn, int npages, bool enc); diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 7a422a6c5983..3be9b3342c67 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -838,7 +838,6 @@ static void __init kvm_guest_init(void) #ifdef CONFIG_SMP if (pv_tlb_flush_supported()) { pv_ops.mmu.flush_tlb_multi = kvm_flush_tlb_multi; - pv_ops.mmu.tlb_remove_table = tlb_remove_table; pr_info("KVM setup pv remote TLB flush\n"); } diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 527f5605aa3e..2aa251d0b308 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -180,7 +180,6 @@ struct paravirt_patch_template pv_ops = { .mmu.flush_tlb_kernel = native_flush_tlb_global, .mmu.flush_tlb_one_user = native_flush_tlb_one_user, .mmu.flush_tlb_multi = native_flush_tlb_multi, - .mmu.tlb_remove_table = tlb_remove_table, .mmu.exit_mmap = paravirt_nop, .mmu.notify_page_enc_status_changed = paravirt_nop, diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 3bc8ad282b27..b1c1f72c1fd1 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -18,14 +18,6 @@ EXPORT_SYMBOL(physical_mask); #define PGTABLE_HIGHMEM 0 #endif -#ifndef CONFIG_PARAVIRT -static inline -void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - tlb_remove_table(tlb, table); -} -#endif /* !CONFIG_PARAVIRT */ - gfp_t __userpte_alloc_gfp = GFP_PGTABLE_USER | PGTABLE_HIGHMEM; pgtable_t pte_alloc_one(struct mm_struct *mm) @@ -53,7 +45,7 @@ early_param("userpte", setup_userpte); void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) { paravirt_release_pte(page_to_pfn(pte)); - paravirt_tlb_remove_table(tlb, page_ptdesc(pte)); + tlb_remove_table(tlb, page_ptdesc(pte)); } #if CONFIG_PGTABLE_LEVELS > 2 @@ -67,21 +59,21 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) #ifdef CONFIG_X86_PAE tlb->need_flush_all = 1; #endif - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(pmd)); + tlb_remove_table(tlb, virt_to_ptdesc(pmd)); } #if CONFIG_PGTABLE_LEVELS > 3 void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) { paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(pud)); + tlb_remove_table(tlb, virt_to_ptdesc(pud)); } #if CONFIG_PGTABLE_LEVELS > 4 void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) { paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(p4d)); + tlb_remove_table(tlb, virt_to_ptdesc(p4d)); } #endif /* CONFIG_PGTABLE_LEVELS > 4 */ #endif /* CONFIG_PGTABLE_LEVELS > 3 */ diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 2c70cd35e72c..a0b371557125 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -2141,7 +2141,6 @@ static const typeof(pv_ops) xen_mmu_ops __initconst = { .flush_tlb_kernel = xen_flush_tlb, .flush_tlb_one_user = xen_flush_tlb_one_user, .flush_tlb_multi = xen_flush_tlb_multi, - .tlb_remove_table = tlb_remove_table, .pgd_alloc = xen_pgd_alloc, .pgd_free = xen_pgd_free,
On 2025/1/24 19:38, Peter Zijlstra wrote: > On Thu, Jan 23, 2025 at 09:26:17PM +0800, Qi Zheng wrote: >> If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table() >> will fall back to pagetable_dtor() + tlb_remove_page(). So let's use >> tlb_remove_table() unconditionally to free page table pages. >> >> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> >> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> > > I think we can clean up more :-) Yes, but Rik van Riel has already done the same thing in his patch series [1], so I was originally planning to wait for his patch to be merged into the linux-next branch, and then rebase this series onto his patch. [1]. https://lore.kernel.org/lkml/20250120024104.1924753-1-riel@surriel.com/ Thanks! > > > diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c > index cc8c3bd0e7c2..1f7c3082a36d 100644 > --- a/arch/x86/hyperv/mmu.c > +++ b/arch/x86/hyperv/mmu.c > @@ -239,5 +239,4 @@ void hyperv_setup_mmu_ops(void) > > pr_info("Using hypercall for remote TLB flush\n"); > pv_ops.mmu.flush_tlb_multi = hyperv_flush_tlb_multi; > - pv_ops.mmu.tlb_remove_table = tlb_remove_table; > } > diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h > index 041aff51eb50..38a632a282d4 100644 > --- a/arch/x86/include/asm/paravirt.h > +++ b/arch/x86/include/asm/paravirt.h > @@ -91,11 +91,6 @@ static inline void __flush_tlb_multi(const struct cpumask *cpumask, > PVOP_VCALL2(mmu.flush_tlb_multi, cpumask, info); > } > > -static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) > -{ > - PVOP_VCALL2(mmu.tlb_remove_table, tlb, table); > -} > - > static inline void paravirt_arch_exit_mmap(struct mm_struct *mm) > { > PVOP_VCALL1(mmu.exit_mmap, mm); > diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h > index fea56b04f436..e26633c00455 100644 > --- a/arch/x86/include/asm/paravirt_types.h > +++ b/arch/x86/include/asm/paravirt_types.h > @@ -134,8 +134,6 @@ struct pv_mmu_ops { > void (*flush_tlb_multi)(const struct cpumask *cpus, > const struct flush_tlb_info *info); > > - void (*tlb_remove_table)(struct mmu_gather *tlb, void *table); > - > /* Hook for intercepting the destruction of an mm_struct. */ > void (*exit_mmap)(struct mm_struct *mm); > void (*notify_page_enc_status_changed)(unsigned long pfn, int npages, bool enc); > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 7a422a6c5983..3be9b3342c67 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -838,7 +838,6 @@ static void __init kvm_guest_init(void) > #ifdef CONFIG_SMP > if (pv_tlb_flush_supported()) { > pv_ops.mmu.flush_tlb_multi = kvm_flush_tlb_multi; > - pv_ops.mmu.tlb_remove_table = tlb_remove_table; > pr_info("KVM setup pv remote TLB flush\n"); > } > > diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c > index 527f5605aa3e..2aa251d0b308 100644 > --- a/arch/x86/kernel/paravirt.c > +++ b/arch/x86/kernel/paravirt.c > @@ -180,7 +180,6 @@ struct paravirt_patch_template pv_ops = { > .mmu.flush_tlb_kernel = native_flush_tlb_global, > .mmu.flush_tlb_one_user = native_flush_tlb_one_user, > .mmu.flush_tlb_multi = native_flush_tlb_multi, > - .mmu.tlb_remove_table = tlb_remove_table, > > .mmu.exit_mmap = paravirt_nop, > .mmu.notify_page_enc_status_changed = paravirt_nop, > diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c > index 3bc8ad282b27..b1c1f72c1fd1 100644 > --- a/arch/x86/mm/pgtable.c > +++ b/arch/x86/mm/pgtable.c > @@ -18,14 +18,6 @@ EXPORT_SYMBOL(physical_mask); > #define PGTABLE_HIGHMEM 0 > #endif > > -#ifndef CONFIG_PARAVIRT > -static inline > -void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) > -{ > - tlb_remove_table(tlb, table); > -} > -#endif /* !CONFIG_PARAVIRT */ > - > gfp_t __userpte_alloc_gfp = GFP_PGTABLE_USER | PGTABLE_HIGHMEM; > > pgtable_t pte_alloc_one(struct mm_struct *mm) > @@ -53,7 +45,7 @@ early_param("userpte", setup_userpte); > void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) > { > paravirt_release_pte(page_to_pfn(pte)); > - paravirt_tlb_remove_table(tlb, page_ptdesc(pte)); > + tlb_remove_table(tlb, page_ptdesc(pte)); > } > > #if CONFIG_PGTABLE_LEVELS > 2 > @@ -67,21 +59,21 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) > #ifdef CONFIG_X86_PAE > tlb->need_flush_all = 1; > #endif > - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(pmd)); > + tlb_remove_table(tlb, virt_to_ptdesc(pmd)); > } > > #if CONFIG_PGTABLE_LEVELS > 3 > void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) > { > paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); > - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(pud)); > + tlb_remove_table(tlb, virt_to_ptdesc(pud)); > } > > #if CONFIG_PGTABLE_LEVELS > 4 > void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) > { > paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); > - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(p4d)); > + tlb_remove_table(tlb, virt_to_ptdesc(p4d)); > } > #endif /* CONFIG_PGTABLE_LEVELS > 4 */ > #endif /* CONFIG_PGTABLE_LEVELS > 3 */ > diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c > index 2c70cd35e72c..a0b371557125 100644 > --- a/arch/x86/xen/mmu_pv.c > +++ b/arch/x86/xen/mmu_pv.c > @@ -2141,7 +2141,6 @@ static const typeof(pv_ops) xen_mmu_ops __initconst = { > .flush_tlb_kernel = xen_flush_tlb, > .flush_tlb_one_user = xen_flush_tlb_one_user, > .flush_tlb_multi = xen_flush_tlb_multi, > - .tlb_remove_table = tlb_remove_table, > > .pgd_alloc = xen_pgd_alloc, > .pgd_free = xen_pgd_free,
On Fri, Jan 24, 2025 at 09:00:58PM +0800, Qi Zheng wrote: > > > On 2025/1/24 19:38, Peter Zijlstra wrote: > > On Thu, Jan 23, 2025 at 09:26:17PM +0800, Qi Zheng wrote: > > > If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table() > > > will fall back to pagetable_dtor() + tlb_remove_page(). So let's use > > > tlb_remove_table() unconditionally to free page table pages. > > > > > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > > > Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> > > > > I think we can clean up more :-) > > Yes, but Rik van Riel has already done the same thing in his patch series > [1], so I was originally planning to wait for his patch to be > merged into the linux-next branch, and then rebase this series onto his > patch. Duh, yeah, I've actually seen those patches and totally forgot he did that... -ETOOMUCHEMAIL :/
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 1ccaa3397a670..527f5605aa3e5 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -59,21 +59,6 @@ void __init native_pv_lock_init(void) static_branch_enable(&virt_spin_lock_key); } -#ifndef CONFIG_PT_RECLAIM -static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - struct ptdesc *ptdesc = (struct ptdesc *)table; - - pagetable_dtor(ptdesc); - tlb_remove_page(tlb, ptdesc_page(ptdesc)); -} -#else -static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - tlb_remove_table(tlb, table); -} -#endif - struct static_key paravirt_steal_enabled; struct static_key paravirt_steal_rq_enabled; @@ -195,7 +180,7 @@ struct paravirt_patch_template pv_ops = { .mmu.flush_tlb_kernel = native_flush_tlb_global, .mmu.flush_tlb_one_user = native_flush_tlb_one_user, .mmu.flush_tlb_multi = native_flush_tlb_multi, - .mmu.tlb_remove_table = native_tlb_remove_table, + .mmu.tlb_remove_table = tlb_remove_table, .mmu.exit_mmap = paravirt_nop, .mmu.notify_page_enc_status_changed = paravirt_nop, diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 1fef5ad32d5a8..3bc8ad282b272 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -19,22 +19,11 @@ EXPORT_SYMBOL(physical_mask); #endif #ifndef CONFIG_PARAVIRT -#ifndef CONFIG_PT_RECLAIM -static inline -void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - struct ptdesc *ptdesc = (struct ptdesc *)table; - - pagetable_dtor(ptdesc); - tlb_remove_page(tlb, ptdesc_page(ptdesc)); -} -#else static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) { tlb_remove_table(tlb, table); } -#endif /* !CONFIG_PT_RECLAIM */ #endif /* !CONFIG_PARAVIRT */ gfp_t __userpte_alloc_gfp = GFP_PGTABLE_USER | PGTABLE_HIGHMEM;
If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table() will fall back to pagetable_dtor() + tlb_remove_page(). So let's use tlb_remove_table() unconditionally to free page table pages. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- arch/x86/kernel/paravirt.c | 17 +---------------- arch/x86/mm/pgtable.c | 11 ----------- 2 files changed, 1 insertion(+), 27 deletions(-)