Message ID | 2fa644e37ab917292f5c342e40fa805aa91afbbd.1735549103.git.zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | move pagetable_*_dtor() to __tlb_remove_table() | expand |
Context | Check | Description |
---|---|---|
conchuod/vmtest-fixes-PR | fail | merge-conflict |
On 30/12/2024 10:07, Qi Zheng wrote: > diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h > index 551d614d3369c..3466fbe2e508d 100644 > --- a/arch/riscv/include/asm/pgalloc.h > +++ b/arch/riscv/include/asm/pgalloc.h > @@ -108,8 +108,12 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, > static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, > unsigned long addr) > { > - if (pgtable_l5_enabled) > + if (pgtable_l5_enabled) { > + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); > + > + pagetable_p4d_dtor(ptdesc); > riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); Nit: could use the new ptdesc variable here instead of calling virt_to_ptdesc(). - Kevin
On 2025/1/3 00:53, Kevin Brodsky wrote: > On 30/12/2024 10:07, Qi Zheng wrote: >> diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h >> index 551d614d3369c..3466fbe2e508d 100644 >> --- a/arch/riscv/include/asm/pgalloc.h >> +++ b/arch/riscv/include/asm/pgalloc.h >> @@ -108,8 +108,12 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, >> static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, >> unsigned long addr) >> { >> - if (pgtable_l5_enabled) >> + if (pgtable_l5_enabled) { >> + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); >> + >> + pagetable_p4d_dtor(ptdesc); >> riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); > > Nit: could use the new ptdesc variable here instead of calling > virt_to_ptdesc(). Right, but we will remove pagetable_p4d_dtor() in patch #10, so this may not matter. Thanks! > > - Kevin
On 03/01/2025 04:53, Qi Zheng wrote: > On 2025/1/3 00:53, Kevin Brodsky wrote: >> On 30/12/2024 10:07, Qi Zheng wrote: >>> diff --git a/arch/riscv/include/asm/pgalloc.h >>> b/arch/riscv/include/asm/pgalloc.h >>> index 551d614d3369c..3466fbe2e508d 100644 >>> --- a/arch/riscv/include/asm/pgalloc.h >>> +++ b/arch/riscv/include/asm/pgalloc.h >>> @@ -108,8 +108,12 @@ static inline void __pud_free_tlb(struct >>> mmu_gather *tlb, pud_t *pud, >>> static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, >>> unsigned long addr) >>> { >>> - if (pgtable_l5_enabled) >>> + if (pgtable_l5_enabled) { >>> + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); >>> + >>> + pagetable_p4d_dtor(ptdesc); >>> riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); >> >> Nit: could use the new ptdesc variable here instead of calling >> virt_to_ptdesc(). > > Right, but we will remove pagetable_p4d_dtor() in patch #10, so this > may not matter. You're right, I missed that. Makes sense not to create a diff that's reverted later then :) - Kevin
diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index 551d614d3369c..3466fbe2e508d 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -108,8 +108,12 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, unsigned long addr) { - if (pgtable_l5_enabled) + if (pgtable_l5_enabled) { + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); + + pagetable_p4d_dtor(ptdesc); riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); + } } #endif /* __PAGETABLE_PMD_FOLDED */ diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 69a357b15974a..3d6e84da45b24 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -94,6 +94,9 @@ void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) #if CONFIG_PGTABLE_LEVELS > 4 void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) { + struct ptdesc *ptdesc = virt_to_ptdesc(p4d); + + pagetable_p4d_dtor(ptdesc); paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); paravirt_tlb_remove_table(tlb, virt_to_page(p4d)); } diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h index 59131629ac9cc..bb482eeca0c3e 100644 --- a/include/asm-generic/pgalloc.h +++ b/include/asm-generic/pgalloc.h @@ -230,6 +230,7 @@ static inline p4d_t *__p4d_alloc_one_noprof(struct mm_struct *mm, unsigned long if (!ptdesc) return NULL; + pagetable_p4d_ctor(ptdesc); return ptdesc_address(ptdesc); } #define __p4d_alloc_one(...) alloc_hooks(__p4d_alloc_one_noprof(__VA_ARGS__)) @@ -247,6 +248,7 @@ static inline void __p4d_free(struct mm_struct *mm, p4d_t *p4d) struct ptdesc *ptdesc = virt_to_ptdesc(p4d); BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); + pagetable_p4d_dtor(ptdesc); pagetable_free(ptdesc); } diff --git a/include/linux/mm.h b/include/linux/mm.h index c49bc7b764535..5d82f42ddd5cc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3175,6 +3175,22 @@ static inline void pagetable_pud_dtor(struct ptdesc *ptdesc) lruvec_stat_sub_folio(folio, NR_PAGETABLE); } +static inline void pagetable_p4d_ctor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); +} + +static inline void pagetable_p4d_dtor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); +} + extern void __init pagecache_init(void); extern void free_initmem(void);
Like other levels of page tables, add statistics for P4D level page table. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Originally-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- arch/riscv/include/asm/pgalloc.h | 6 +++++- arch/x86/mm/pgtable.c | 3 +++ include/asm-generic/pgalloc.h | 2 ++ include/linux/mm.h | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-)