Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: pgtable: introduce generic pagetable_dtor_free()

The pte_free(), pmd_free(), __pud_free() and __p4d_free() in
asm-generic/pgalloc.h and the generic __tlb_remove_table() are basically
the same, so let's introduce pagetable_dtor_free() to deduplicate them.

In addition, the pagetable_dtor_free() in s390 does the same thing, so
let's s390 also calls generic pagetable_dtor_free().

Link: https://lkml.kernel.org/r/1663a0565aca881d1338ceb7d1db4aa9c333abd6.1736317725.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> [s390]
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
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: 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: Andrew Morton <akpm@linux-foundation.org>

authored by

Qi Zheng and committed by
Andrew Morton
553e7752 e74e1731

+11 -16
-6
arch/s390/mm/pgalloc.c
··· 180 180 return table; 181 181 } 182 182 183 - static void pagetable_dtor_free(struct ptdesc *ptdesc) 184 - { 185 - pagetable_dtor(ptdesc); 186 - pagetable_free(ptdesc); 187 - } 188 - 189 183 void page_table_free(struct mm_struct *mm, unsigned long *table) 190 184 { 191 185 struct ptdesc *ptdesc = virt_to_ptdesc(table);
+4 -8
include/asm-generic/pgalloc.h
··· 109 109 { 110 110 struct ptdesc *ptdesc = page_ptdesc(pte_page); 111 111 112 - pagetable_dtor(ptdesc); 113 - pagetable_free(ptdesc); 112 + pagetable_dtor_free(ptdesc); 114 113 } 115 114 116 115 ··· 152 153 struct ptdesc *ptdesc = virt_to_ptdesc(pmd); 153 154 154 155 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); 155 - pagetable_dtor(ptdesc); 156 - pagetable_free(ptdesc); 156 + pagetable_dtor_free(ptdesc); 157 157 } 158 158 #endif 159 159 ··· 200 202 struct ptdesc *ptdesc = virt_to_ptdesc(pud); 201 203 202 204 BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); 203 - pagetable_dtor(ptdesc); 204 - pagetable_free(ptdesc); 205 + pagetable_dtor_free(ptdesc); 205 206 } 206 207 207 208 #ifndef __HAVE_ARCH_PUD_FREE ··· 245 248 struct ptdesc *ptdesc = virt_to_ptdesc(p4d); 246 249 247 250 BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); 248 - pagetable_dtor(ptdesc); 249 - pagetable_free(ptdesc); 251 + pagetable_dtor_free(ptdesc); 250 252 } 251 253 252 254 #ifndef __HAVE_ARCH_P4D_FREE
+1 -2
include/asm-generic/tlb.h
··· 213 213 { 214 214 struct ptdesc *ptdesc = (struct ptdesc *)table; 215 215 216 - pagetable_dtor(ptdesc); 217 - pagetable_free(ptdesc); 216 + pagetable_dtor_free(ptdesc); 218 217 } 219 218 #endif 220 219
+6
include/linux/mm.h
··· 3001 3001 lruvec_stat_sub_folio(folio, NR_PAGETABLE); 3002 3002 } 3003 3003 3004 + static inline void pagetable_dtor_free(struct ptdesc *ptdesc) 3005 + { 3006 + pagetable_dtor(ptdesc); 3007 + pagetable_free(ptdesc); 3008 + } 3009 + 3004 3010 static inline bool pagetable_pte_ctor(struct ptdesc *ptdesc) 3005 3011 { 3006 3012 struct folio *folio = ptdesc_folio(ptdesc);