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.

x86: pgtable: convert __tlb_remove_table() to use struct ptdesc

Convert __tlb_remove_table() to use struct ptdesc, which will help to move
pagetable_dtor() to __tlb_remove_table().

And page tables shouldn't have swap cache, so use pagetable_free() instead
of free_page_and_swap_cache() to free page table pages.

Link: https://lkml.kernel.org/r/39f60f93143ff77cf5d6b3c3e75af0ffc1480adb.1736317725.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
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: 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: Andrew Morton <akpm@linux-foundation.org>

authored by

Qi Zheng and committed by
Andrew Morton
0b6476f9 deab5a35

+19 -13
+9 -7
arch/x86/include/asm/tlb.h
··· 31 31 */ 32 32 static inline void __tlb_remove_table(void *table) 33 33 { 34 - free_page_and_swap_cache(table); 34 + struct ptdesc *ptdesc = (struct ptdesc *)table; 35 + 36 + pagetable_free(ptdesc); 35 37 } 36 38 37 39 #ifdef CONFIG_PT_RECLAIM 38 40 static inline void __tlb_remove_table_one_rcu(struct rcu_head *head) 39 41 { 40 - struct page *page; 42 + struct ptdesc *ptdesc; 41 43 42 - page = container_of(head, struct page, rcu_head); 43 - put_page(page); 44 + ptdesc = container_of(head, struct ptdesc, pt_rcu_head); 45 + __tlb_remove_table(ptdesc); 44 46 } 45 47 46 48 static inline void __tlb_remove_table_one(void *table) 47 49 { 48 - struct page *page; 50 + struct ptdesc *ptdesc; 49 51 50 - page = table; 51 - call_rcu(&page->rcu_head, __tlb_remove_table_one_rcu); 52 + ptdesc = table; 53 + call_rcu(&ptdesc->pt_rcu_head, __tlb_remove_table_one_rcu); 52 54 } 53 55 #define __tlb_remove_table_one __tlb_remove_table_one 54 56 #endif /* CONFIG_PT_RECLAIM */
+3 -1
arch/x86/kernel/paravirt.c
··· 62 62 #ifndef CONFIG_PT_RECLAIM 63 63 static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) 64 64 { 65 - tlb_remove_page(tlb, table); 65 + struct ptdesc *ptdesc = (struct ptdesc *)table; 66 + 67 + tlb_remove_page(tlb, ptdesc_page(ptdesc)); 66 68 } 67 69 #else 68 70 static void native_tlb_remove_table(struct mmu_gather *tlb, void *table)
+7 -5
arch/x86/mm/pgtable.c
··· 23 23 static inline 24 24 void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) 25 25 { 26 - tlb_remove_page(tlb, table); 26 + struct ptdesc *ptdesc = (struct ptdesc *)table; 27 + 28 + tlb_remove_page(tlb, ptdesc_page(ptdesc)); 27 29 } 28 30 #else 29 31 static inline ··· 64 62 { 65 63 pagetable_dtor(page_ptdesc(pte)); 66 64 paravirt_release_pte(page_to_pfn(pte)); 67 - paravirt_tlb_remove_table(tlb, pte); 65 + paravirt_tlb_remove_table(tlb, page_ptdesc(pte)); 68 66 } 69 67 70 68 #if CONFIG_PGTABLE_LEVELS > 2 ··· 80 78 tlb->need_flush_all = 1; 81 79 #endif 82 80 pagetable_dtor(ptdesc); 83 - paravirt_tlb_remove_table(tlb, ptdesc_page(ptdesc)); 81 + paravirt_tlb_remove_table(tlb, ptdesc); 84 82 } 85 83 86 84 #if CONFIG_PGTABLE_LEVELS > 3 ··· 90 88 91 89 pagetable_dtor(ptdesc); 92 90 paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); 93 - paravirt_tlb_remove_table(tlb, virt_to_page(pud)); 91 + paravirt_tlb_remove_table(tlb, ptdesc); 94 92 } 95 93 96 94 #if CONFIG_PGTABLE_LEVELS > 4 ··· 100 98 101 99 pagetable_dtor(ptdesc); 102 100 paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); 103 - paravirt_tlb_remove_table(tlb, virt_to_page(p4d)); 101 + paravirt_tlb_remove_table(tlb, ptdesc); 104 102 } 105 103 #endif /* CONFIG_PGTABLE_LEVELS > 4 */ 106 104 #endif /* CONFIG_PGTABLE_LEVELS > 3 */