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: add statistics for P4D level page table

Like other levels of page tables, add statistics for P4D level page table.

Link: https://lkml.kernel.org/r/d55fe3c286305aae84457da9e1066df99b3de125.1736317725.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Originally-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
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
5fcf5fa6 98a7e47f

+26 -1
+5 -1
arch/riscv/include/asm/pgalloc.h
··· 108 108 static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, 109 109 unsigned long addr) 110 110 { 111 - if (pgtable_l5_enabled) 111 + if (pgtable_l5_enabled) { 112 + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); 113 + 114 + pagetable_p4d_dtor(ptdesc); 112 115 riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); 116 + } 113 117 } 114 118 #endif /* __PAGETABLE_PMD_FOLDED */ 115 119
+3
arch/x86/mm/pgtable.c
··· 94 94 #if CONFIG_PGTABLE_LEVELS > 4 95 95 void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) 96 96 { 97 + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); 98 + 99 + pagetable_p4d_dtor(ptdesc); 97 100 paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); 98 101 paravirt_tlb_remove_table(tlb, virt_to_page(p4d)); 99 102 }
+2
include/asm-generic/pgalloc.h
··· 230 230 if (!ptdesc) 231 231 return NULL; 232 232 233 + pagetable_p4d_ctor(ptdesc); 233 234 return ptdesc_address(ptdesc); 234 235 } 235 236 #define __p4d_alloc_one(...) alloc_hooks(__p4d_alloc_one_noprof(__VA_ARGS__)) ··· 248 247 struct ptdesc *ptdesc = virt_to_ptdesc(p4d); 249 248 250 249 BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); 250 + pagetable_p4d_dtor(ptdesc); 251 251 pagetable_free(ptdesc); 252 252 } 253 253
+16
include/linux/mm.h
··· 3175 3175 lruvec_stat_sub_folio(folio, NR_PAGETABLE); 3176 3176 } 3177 3177 3178 + static inline void pagetable_p4d_ctor(struct ptdesc *ptdesc) 3179 + { 3180 + struct folio *folio = ptdesc_folio(ptdesc); 3181 + 3182 + __folio_set_pgtable(folio); 3183 + lruvec_stat_add_folio(folio, NR_PAGETABLE); 3184 + } 3185 + 3186 + static inline void pagetable_p4d_dtor(struct ptdesc *ptdesc) 3187 + { 3188 + struct folio *folio = ptdesc_folio(ptdesc); 3189 + 3190 + __folio_clear_pgtable(folio); 3191 + lruvec_stat_sub_folio(folio, NR_PAGETABLE); 3192 + } 3193 + 3178 3194 extern void __init pagecache_init(void); 3179 3195 extern void free_initmem(void); 3180 3196