Commit 2dccdf70 authored by Qi Zheng's avatar Qi Zheng Committed by Andrew Morton
Browse files

mm: pgtable: introduce generic __tlb_remove_table()

Several architectures (arm, arm64, riscv and x86) define exactly the same
__tlb_remove_table(), just introduce generic __tlb_remove_table() to
eliminate these duplications.

The s390 __tlb_remove_table() is nearly the same, so also make s390
__tlb_remove_table() version generic.

Link: https://lkml.kernel.org/r/ea372633d94f4d3f9f56a7ec5994bf050bf77e39.1736317725.git.zhengqi.arch@bytedance.com


Signed-off-by: default avatarQi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: default avatarKevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Andreas Larsson <andreas@gaisler.com>		[sparc]
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>	[s390]
Acked-by: Arnd Bergmann <arnd@arndb.de>			[asm-generic]
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 5550b3c5
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -27,15 +27,6 @@
#else /* !CONFIG_MMU */

#include <asm/tlbflush.h>

static inline void __tlb_remove_table(void *_table)
{
	struct ptdesc *ptdesc = (struct ptdesc *)_table;

	pagetable_dtor(ptdesc);
	pagetable_free(ptdesc);
}

#include <asm-generic/tlb.h>

static inline void
+0 −7
Original line number Diff line number Diff line
@@ -10,13 +10,6 @@

#include <linux/pagemap.h>

static inline void __tlb_remove_table(void *_table)
{
	struct ptdesc *ptdesc = (struct ptdesc *)_table;

	pagetable_dtor(ptdesc);
	pagetable_free(ptdesc);
}

#define tlb_flush tlb_flush
static void tlb_flush(struct mmu_gather *tlb);
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ extern void tlb_flush(struct mmu_gather *tlb);
 */
#define tlb_needs_table_invalidate()	radix_enabled()

#define __HAVE_ARCH_TLB_REMOVE_TABLE
/* Get the generic bits... */
#include <asm-generic/tlb.h>

+0 −12
Original line number Diff line number Diff line
@@ -10,18 +10,6 @@ struct mmu_gather;

static void tlb_flush(struct mmu_gather *tlb);

#ifdef CONFIG_MMU

static inline void __tlb_remove_table(void *table)
{
	struct ptdesc *ptdesc = (struct ptdesc *)table;

	pagetable_dtor(ptdesc);
	pagetable_free(ptdesc);
}

#endif /* CONFIG_MMU */

#define tlb_flush tlb_flush
#include <asm-generic/tlb.h>

+4 −5
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
 * Pages used for the page tables is a different story. FIXME: more
 */

void __tlb_remove_table(void *_table);
static inline void tlb_flush(struct mmu_gather *tlb);
static inline bool __tlb_remove_page_size(struct mmu_gather *tlb,
		struct page *page, bool delay_rmap, int page_size);
@@ -87,7 +86,7 @@ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
	tlb->cleared_pmds = 1;
	if (mm_alloc_pgste(tlb->mm))
		gmap_unlink(tlb->mm, (unsigned long *)pte, address);
	tlb_remove_ptdesc(tlb, pte);
	tlb_remove_ptdesc(tlb, virt_to_ptdesc(pte));
}

/*
@@ -106,7 +105,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
	tlb->mm->context.flush_mm = 1;
	tlb->freed_tables = 1;
	tlb->cleared_puds = 1;
	tlb_remove_ptdesc(tlb, pmd);
	tlb_remove_ptdesc(tlb, virt_to_ptdesc(pmd));
}

/*
@@ -124,7 +123,7 @@ static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d,
	__tlb_adjust_range(tlb, address, PAGE_SIZE);
	tlb->mm->context.flush_mm = 1;
	tlb->freed_tables = 1;
	tlb_remove_ptdesc(tlb, p4d);
	tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d));
}

/*
@@ -142,7 +141,7 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
	tlb->mm->context.flush_mm = 1;
	tlb->freed_tables = 1;
	tlb->cleared_p4ds = 1;
	tlb_remove_ptdesc(tlb, pud);
	tlb_remove_ptdesc(tlb, virt_to_ptdesc(pud));
}


Loading