remove tlb_remove_page_ptdesc()
Subsystems (16)
v2 cover remove tlb_remove_page_ptdesc()
Changes in v2:
- add [PATCH v2 2/6] (Peter Zijlstra)
- remove [PATCH 4/5] and add [PATCH v2 5/6]
- rebase onto the next-20250224
Hi all,
As suggested by Peter Zijlstra below [1], this series aims to remove tlb_remove_page_ptdesc().
: Fundamentally tlb_remove_page() is about removing *pages* as from a PTE, : there should not be a page-table anywhere near here *ever*. :
: Yes, some architectures use tlb_remove_page() for page-tables too, but : that is more or less an implementation detail that can be fixed.
After this series, all architectures use tlb_remove_table() or tlb_remove_ptdesc() to remove the page table pages. In the future, once all architectures using tlb_remove_table() have also converted to using struct ptdesc (eg. powerpc), it may be possible to use only tlb_remove_ptdesc().
This series is based on next-20250224.
Comments and suggestions are welcome!
Thanks,
Qi
[1]. https://lore.kernel.org/linux-mm/[email protected]/
Qi Zheng (6):
mm: pgtable: make generic tlb_remove_table() use struct ptdesc
mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct
ptdesc *
mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
riscv: pgtable: unconditionally use tlb_remove_ptdesc()
x86: pgtable: convert to use tlb_remove_ptdesc()
mm: pgtable: remove tlb_remove_page_ptdesc()
arch/csky/include/asm/pgalloc.h | 3 +-- arch/hexagon/include/asm/pgalloc.h | 3 +-- arch/loongarch/include/asm/pgalloc.h | 3 +-- arch/m68k/include/asm/sun3_pgalloc.h | 3 +-- arch/mips/include/asm/pgalloc.h | 3 +-- arch/nios2/include/asm/pgalloc.h | 9 ++++----- arch/openrisc/include/asm/pgalloc.h | 3 +-- arch/riscv/include/asm/pgalloc.h | 26 ++++---------------------- arch/sh/include/asm/pgalloc.h | 3 +-- arch/um/include/asm/pgalloc.h | 9 +++------ arch/x86/mm/pgtable.c | 8 ++++---- include/asm-generic/tlb.h | 14 ++++---------- 12 files changed, 26 insertions(+), 61 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/6 mm: pgtable: make generic tlb_remove_table() use struct ptdesc
Now only arm will call tlb_remove_ptdesc()/tlb_remove_table() when CONFIG_MMU_GATHER_TABLE_FREE is disabled. In this case, the type of the table parameter is actually struct ptdesc * instead of struct page *.
Since struct ptdesc still overlaps with struct page and has not been separated from it, forcing the table parameter to struct page * will not cause any problems at this time. But this is definitely incorrect and needs to be fixed. So just like the generic __tlb_remove_table(), let generic tlb_remove_table() use struct ptdesc by default when CONFIG_MMU_GATHER_TABLE_FREE is disabled.
--- include/asm-generic/tlb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/asm-generic/tlb.h +3 -3
@@ -232,10 +232,10 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page);*/ static inline void tlb_remove_table (struct mmu_gather *tlb,void *table) { -struct page *page = (struct page *)table; +struct ptdesc *ptdesc = (struct ptdesc *)table; -pagetable_dtor (page_ptdesc (page)); -tlb_remove_page (tlb, page); +pagetable_dtor (ptdesc); +tlb_remove_page (tlb,ptdesc_page (ptdesc)); }#endif /* CONFIG_MMU_GATHER_TABLE_FREE */
Signature · 1 line
2.20.1
PATCH v2 2/6 mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc *
In reply to Qi ZhengAll callers of tlb_remove_ptdesc() pass it a pointer of struct ptdesc, so let's change the pt parameter from void * to struct ptdesc * to perform a type safety check.
--- include/asm-generic/tlb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/tlb.h +1 -1
@@ -506,7 +506,7 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)return tlb_remove_page_size (tlb, page,PAGE_SIZE ); } -static inline void tlb_remove_ptdesc (struct mmu_gather *tlb,void *pt) +static inline void tlb_remove_ptdesc (struct mmu_gather *tlb,struct ptdesc *pt) {tlb_remove_table (tlb, pt); }
Signature · 1 line
2.20.1
PATCH v2 3/6 mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
In reply to Qi ZhengNow, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just call pagetable_dtor() + tlb_remove_page_ptdesc() (the wrapper of tlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to use tlb_remove_ptdesc().
The ultimate goal is to make the architecture only use tlb_remove_ptdesc() or tlb_remove_table() for page table pages.
--- arch/csky/include/asm/pgalloc.h | 3 +-- arch/hexagon/include/asm/pgalloc.h | 3 +-- arch/loongarch/include/asm/pgalloc.h | 3 +-- arch/m68k/include/asm/sun3_pgalloc.h | 3 +-- arch/mips/include/asm/pgalloc.h | 3 +-- arch/nios2/include/asm/pgalloc.h | 9 ++++----- arch/openrisc/include/asm/pgalloc.h | 3 +-- arch/sh/include/asm/pgalloc.h | 3 +-- arch/um/include/asm/pgalloc.h | 9 +++------ 9 files changed, 14 insertions(+), 25 deletions(-)
arch/csky/include/asm/pgalloc.h +1 -2
@@ -63,8 +63,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)#define __pte_free_tlb (tlb, pte, address) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc(tlb, page_ptdesc(pte)); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)extern void pagetable_init (void );
arch/hexagon/include/asm/pgalloc.h +1 -2
@@ -89,8 +89,7 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,#define __pte_free_tlb (tlb, pte, addr) \ do { \ - pagetable_dtor((page_ptdesc(pte))); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)#endif
arch/loongarch/include/asm/pgalloc.h +1 -2
@@ -57,8 +57,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)#define __pte_free_tlb (tlb, pte, address) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)#ifndef __PAGETABLE_PMD_FOLDED
arch/m68k/include/asm/sun3_pgalloc.h +1 -2
@@ -19,8 +19,7 @@ extern const char bad_pmd_string[];#define __pte_free_tlb (tlb, pte, addr) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte)
arch/mips/include/asm/pgalloc.h +1 -2
@@ -50,8 +50,7 @@ extern pgd_t *pgd_alloc(struct mm_struct *mm);#define __pte_free_tlb (tlb, pte, address) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)#ifndef __PAGETABLE_PMD_FOLDED
arch/nios2/include/asm/pgalloc.h +4 -5
@@ -28,10 +28,9 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,extern pgd_t *pgd_alloc (struct mm_struct *mm); -#define __pte_free_tlb (tlb, pte, addr) \ - do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ - } while (0) +#define __pte_free_tlb (tlb, pte, addr) \ +do { \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ +} while (0)#endif /* _ASM_NIOS2_PGALLOC_H */
arch/openrisc/include/asm/pgalloc.h +1 -2
@@ -66,8 +66,7 @@ extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);#define __pte_free_tlb (tlb, pte, addr) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)#endif
arch/sh/include/asm/pgalloc.h +1 -2
@@ -34,8 +34,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,#define __pte_free_tlb (tlb, pte, addr) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)#endif /* __ASM_SH_PGALLOC_H */
arch/um/include/asm/pgalloc.h +3 -6
@@ -27,24 +27,21 @@ extern pgd_t *pgd_alloc(struct mm_struct *);#define __pte_free_tlb (tlb, pte, address) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)#if CONFIG_PGTABLE_LEVELS >2 #define __pmd_free_tlb (tlb, pmd, address) \ do { \ - pagetable_dtor(virt_to_ptdesc(pmd)); \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pmd)); \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd)); \ } while (0)#if CONFIG_PGTABLE_LEVELS >3 #define __pud_free_tlb (tlb, pud, address) \ do { \ - pagetable_dtor(virt_to_ptdesc(pud)); \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pud)); \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pud)); \ } while (0)#endif
Signature · 1 line
2.20.1
PATCH v2 4/6 riscv: pgtable: unconditionally use tlb_remove_ptdesc()
In reply to Qi ZhengTo support fast gup, the commit 69be3fb111e7 ("riscv: enable MMU_GATHER_RCU_TABLE_FREE for SMP && MMU") did the following:
1) use tlb_remove_page_ptdesc() for those platforms which use IPI to perform TLB shootdown
2) use tlb_remove_ptdesc() for those platforms which use SBI to perform TLB shootdown
The tlb_remove_page_ptdesc() is the wrapper of the tlb_remove_page(). By design, the tlb_remove_page() should be used to remove a normal page from a page table entry, and should not be used for page table pages.
The tlb_remove_ptdesc() is the wrapper of the tlb_remove_table(), which is designed specifically for freeing page table pages. If the CONFIG_MMU_GATHER_TABLE_FREE is enabled, the tlb_remove_table() will use semi RCU to free page table pages, that is:
- batch table freeing: asynchronous free by RCU
- single table freeing: IPI + synchronous free
If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table() will fall back to pagetable_dtor() + tlb_remove_page().
For case 1), since we need to perform TLB shootdown before freeing the page table page, the local_irq_save() in fast gup can block the freeing and protect the fast gup page walker. Therefore we can ensure safety by just using tlb_remove_page_ptdesc(). In addition, we can also the tlb_remove_ptdesc()/tlb_remove_table() to achieve it, and it doesn't matter whether CONFIG_MMU_GATHER_RCU_TABLE_FREE is selected. And in theory, the performance of freeing pages asynchronously via RCU will not be lower than synchronous free.
For case 2), since local_irq_save() only disable S-privilege IPI irq but not M-privilege's, which is used by the SBI implementation to perform TLB shootdown, so we must select CONFIG_MMU_GATHER_RCU_TABLE_FREE and use tlb_remove_ptdesc() to ensure safety. The riscv selects this config for SMP && MMU, the CONFIG_RISCV_SBI is dependent on MMU. Therefore, only the UP system may have the situation where CONFIG_MMU_GATHER_RCU_TABLE_FREE is disabled but CONFIG_RISCV_SBI is enabled. But there is no freeing vs fast gup race in the UP system.
So, in summary, we can use tlb_remove_ptdesc() to support fast gup in all cases, and this interface is specifically designed for page table pages. So let's use it unconditionally.
--- arch/riscv/include/asm/pgalloc.h | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
arch/riscv/include/asm/pgalloc.h +4 -22
@@ -15,24 +15,6 @@#define __HAVE_ARCH_PUD_FREE#include <asm-generic/pgalloc.h> -/* -* While riscv platforms with riscv_ipi_for_rfence as true require an IPI to -* perform TLB shootdown, some platforms with riscv_ipi_for_rfence as false use -* SBI to perform TLB shootdown. To keep software pagetable walkers safe in this -* case we switch to RCU based table free (MMU_GATHER_RCU_TABLE_FREE). See the -* comment below 'ifdef CONFIG_MMU_GATHER_RCU_TABLE_FREE' in include/asm-generic/tlb.h -* for more details. -*/ -static inline void riscv_tlb_remove_ptdesc (struct mmu_gather *tlb,void *pt) -{ -if (riscv_use_sbi_for_rfence ()) { -tlb_remove_ptdesc (tlb, pt); - }else { -pagetable_dtor (pt); -tlb_remove_page_ptdesc (tlb, pt); - } -} -static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte) {
@@ -108,14 +90,14 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, unsigned long addr) {if (pgtable_l4_enabled) -riscv_tlb_remove_ptdesc (tlb,virt_to_ptdesc (pud)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (pud)); }static inline void __p4d_free_tlb (struct mmu_gather *tlb,p4d_t *p4d,unsigned long addr) {if (pgtable_l5_enabled) -riscv_tlb_remove_ptdesc (tlb,virt_to_ptdesc (p4d)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (p4d)); }#endif /* __PAGETABLE_PMD_FOLDED */
@@ -143,7 +125,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)static inline void __pmd_free_tlb (struct mmu_gather *tlb,pmd_t *pmd,unsigned long addr) { -riscv_tlb_remove_ptdesc (tlb,virt_to_ptdesc (pmd)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (pmd)); }#endif /* __PAGETABLE_PMD_FOLDED */
@@ -151,7 +133,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t pte,unsigned long addr) { -riscv_tlb_remove_ptdesc (tlb,page_ptdesc (pte)); +tlb_remove_ptdesc (tlb,page_ptdesc (pte)); }#endif /* CONFIG_MMU */
Signature · 1 line
2.20.1
PATCH v2 5/6 x86: pgtable: convert to use tlb_remove_ptdesc()
In reply to Qi ZhengThe x86 has already been converted to use struct ptdesc, so convert it to use tlb_remove_ptdesc() instead of tlb_remove_table().
--- arch/x86/mm/pgtable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/pgtable.c +4 -4
@@ -45,7 +45,7 @@ early_param("userpte", setup_userpte);void ___pte_free_tlb (struct mmu_gather *tlb,struct page *pte) {paravirt_release_pte (page_to_pfn (pte)); -tlb_remove_table (tlb,page_ptdesc (pte)); +tlb_remove_ptdesc (tlb,page_ptdesc (pte)); }#if CONFIG_PGTABLE_LEVELS >2
@@ -59,21 +59,21 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)#ifdef CONFIG_X86_PAE tlb->need_flush_all =1 ;#endif -tlb_remove_table (tlb,virt_to_ptdesc (pmd)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (pmd)); }#if CONFIG_PGTABLE_LEVELS >3 void ___pud_free_tlb (struct mmu_gather *tlb,pud_t *pud) {paravirt_release_pud (__pa (pud) >>PAGE_SHIFT ); -tlb_remove_table (tlb,virt_to_ptdesc (pud)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (pud)); }#if CONFIG_PGTABLE_LEVELS >4 void ___p4d_free_tlb (struct mmu_gather *tlb,p4d_t *p4d) {paravirt_release_p4d (__pa (p4d) >>PAGE_SHIFT ); -tlb_remove_table (tlb,virt_to_ptdesc (p4d)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (p4d)); }#endif /* CONFIG_PGTABLE_LEVELS > 4 */ #endif /* CONFIG_PGTABLE_LEVELS > 3 */
Signature · 1 line
2.20.1
PATCH v2 6/6 mm: pgtable: remove tlb_remove_page_ptdesc()
In reply to Qi ZhengThe tlb_remove_ptdesc()/tlb_remove_table() is specially designed for page table pages, and now all architectures have been converted to use it to remove page table pages. So let's remove tlb_remove_page_ptdesc(), it currently has no users and should not be used for page table pages.
--- include/asm-generic/tlb.h | 6 ------ 1 file changed, 6 deletions(-)
include/asm-generic/tlb.h +0 -6
@@ -511,12 +511,6 @@ static inline void tlb_remove_ptdesc(struct mmu_gather *tlb, struct ptdesc *pt)tlb_remove_table (tlb, pt); } -/* Like tlb_remove_ptdesc, but for page-like page directories. */ -static inline void tlb_remove_page_ptdesc (struct mmu_gather *tlb,struct ptdesc *pt) -{ -tlb_remove_page (tlb,ptdesc_page (pt)); -} -static inline void tlb_change_page_size (struct mmu_gather *tlb,unsigned int page_size) {
Signature · 1 line
2.20.1
Andrew Morton
maintainerRe: [PATCH v2 5/6] x86: pgtable: convert to use tlb_remove_ptdesc()
In reply to Qi ZhengQuoted 3 lines · On Tue, 25 Feb 2025 11:45:55 +0800 Qi Zheng <[email protected]> wrote:
The x86 has already been converted to use struct ptdesc, so convert it to use
tlb_remove_ptdesc()instead oftlb_remove_table().
This is dependent upon Rik's a37259732a7dc ("x86/mm: Make MMU_GATHER_RCU_TABLE_FREE unconditional") from the x86 tree. I'll add Rik's patch to mm-unstable also and shall figure it out during the merge window.
Re: [PATCH v2 5/6] x86: pgtable: convert to use tlb_remove_ptdesc()
Quoted 8 lines · Andrew Morton
Quoted 3 lines · On Tue, 25 Feb 2025 11:45:55 +0800 Qi Zheng <[email protected]> wrote:
The x86 has already been converted to use struct ptdesc, so convert it to use
tlb_remove_ptdesc()instead oftlb_remove_table().This is dependent upon Rik's
a37259732a7dc("x86/mm: MakeMMU_GATHER_RCU_TABLE_FREEunconditional") from the x86 tree. I'll add
Yes.
Quoted 2 lines
Rik's patch to mm-unstable also and shall figure it out during the merge window.
Thanks!
Re: [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc
In reply to Qi ZhengQuoted 4 lines · Qi Zheng
Now only arm will call tlb_remove_ptdesc()/tlb_remove_table() when
CONFIG_MMU_GATHER_TABLE_FREEis disabled. In this case, the type of the table parameter is actually struct ptdesc * instead of struct page *.
Quoted 8 lines
Since struct ptdesc still overlaps with struct page and has not been separated from it, forcing the table parameter to struct page * will not cause any problems at this time. But this is definitely incorrect and needs to be fixed. So just like the generic
__tlb_remove_table(), let generictlb_remove_table()use struct ptdesc by default whenCONFIG_MMU_GATHER_TABLE_FREEis disabled.Signed-off-by Qi Zheng <[email protected]>
Re: [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc *
In reply to Qi ZhengQuoted 6 lines · Qi Zheng
All callers of
tlb_remove_ptdesc()pass it a pointer of struct ptdesc, so let's change the pt parameter from void * to struct ptdesc * to perform a type safety check.Signed-off-by Qi Zheng <[email protected]>Originally-by Peter Zijlstra (Intel) <[email protected]>
Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
In reply to Qi ZhengQuoted 7 lines · Qi Zheng
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().
Quoted 5 lines
The ultimate goal is to make the architecture only use
tlb_remove_ptdesc()ortlb_remove_table()for page table pages.Signed-off-by Qi Zheng <[email protected]>Suggested-by Peter Zijlstra (Intel) <[email protected]>
Re: [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc()
In reply to Qi ZhengQuoted 7 lines · Qi Zheng
The tlb_remove_ptdesc()/tlb_remove_table() is specially designed for page table pages, and now all architectures have been converted to use it to remove page table pages. So let's remove
tlb_remove_page_ptdesc(), it currently has no users and should not be used for page table pages.Signed-off-by Qi Zheng <[email protected]>Suggested-by Peter Zijlstra (Intel) <[email protected]>
Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
In reply to Qi ZhengHi Qi,
Quoted 7 lines · Qi Zheng
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().
Quoted 5 lines
The ultimate goal is to make the architecture only use
tlb_remove_ptdesc()ortlb_remove_table()for page table pages.Signed-off-by Qi Zheng <[email protected]>Suggested-by Peter Zijlstra (Intel) <[email protected]>
Thanks for your patch!
Quoted 1 line
arch/m68k/include/asm/sun3_pgalloc.h | 3 +--
arch/m68k/include/asm/sun3_pgalloc.h extern const char bad_pmd_string[]; · line 24
Quoted 11 lines
arch/m68k/include/asm/sun3_pgalloc.h +1
-2@@ -19,8 +19,7 @@ extern const char bad_pmd_string[];#define __pte_free_tlb (tlb, pte, addr) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)
With only a single statement remaining, you can remove the do { ... } while construct, too.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
Quoted 13 lines · Geert Uytterhoeven
Hi Qi,
Quoted 10 lines · Qi Zheng
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().The ultimate goal is to make the architecture only use
tlb_remove_ptdesc()ortlb_remove_table()for page table pages.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Qi Zheng <[email protected]>Suggested-by Peter Zijlstra (Intel) <[email protected]>Thanks for your patch!
Quoted 1 line
arch/m68k/include/asm/sun3_pgalloc.h | 3 +--
Thanks for your review.
Quoted 5 lines
Quoted 5 lines
arch/m68k/include/asm/sun3_pgalloc.h +0
-0@@ -19,8 +19,7 @@ extern const char bad_pmd_string[];
Quoted 10 lines
arch/m68k/include/asm/sun3_pgalloc.h extern const char bad_pmd_string[]; · line 24
Quoted 7 lines
arch/m68k/include/asm/sun3_pgalloc.h +1
-2#define __pte_free_tlb (tlb, pte, addr) \ do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)); \ } while (0)With only a single statement remaining, you can remove the do { ... } while construct, too.
Ah, right. Will do in the next version.
Thanks!
Quoted 5 lines
Gr{oetje,eeting}s,
Geert
Re: [External] [PATCH v2 4/6] riscv: pgtable: unconditionally use tlb_remove_ptdesc()
In reply to Qi ZhengHi Qi,
Quoted 118 lines · Qi Zheng
To support fast gup, the commit
69be3fb111e7("riscv: enableMMU_GATHER_RCU_TABLE_FREEfor SMP && MMU") did the following:1) use
tlb_remove_page_ptdesc()for those platforms which use IPI to perform TLB shootdown2) use
tlb_remove_ptdesc()for those platforms which use SBI to perform TLB shootdownThe
tlb_remove_page_ptdesc()is the wrapper of thetlb_remove_page(). By design, thetlb_remove_page()should be used to remove a normal page from a page table entry, and should not be used for page table pages.The
tlb_remove_ptdesc()is the wrapper of thetlb_remove_table(), which is designed specifically for freeing page table pages. If theCONFIG_MMU_GATHER_TABLE_FREEis enabled, thetlb_remove_table()will use semi RCU to free page table pages, that is:- batch table freeing: asynchronous free by RCU
- single table freeing: IPI + synchronous freeIf the
CONFIG_MMU_GATHER_TABLE_FREEis disabled, thetlb_remove_table()will fall back topagetable_dtor()+tlb_remove_page().For case 1), since we need to perform TLB shootdown before freeing the page table page, the
local_irq_save()in fast gup can block the freeing and protect the fast gup page walker. Therefore we can ensure safety by just usingtlb_remove_page_ptdesc(). In addition, we can also the tlb_remove_ptdesc()/tlb_remove_table() to achieve it, and it doesn't matter whetherCONFIG_MMU_GATHER_RCU_TABLE_FREEis selected. And in theory, the performance of freeing pages asynchronously via RCU will not be lower than synchronous free.For case 2), since
local_irq_save()only disable S-privilege IPI irq but not M-privilege's, which is used by the SBI implementation to perform TLB shootdown, so we must selectCONFIG_MMU_GATHER_RCU_TABLE_FREEand usetlb_remove_ptdesc()to ensure safety. The riscv selects this config for SMP && MMU, theCONFIG_RISCV_SBIis dependent on MMU. Therefore, only the UP system may have the situation whereCONFIG_MMU_GATHER_RCU_TABLE_FREEis disabled butCONFIG_RISCV_SBIis enabled. But there is no freeing vs fast gup race in the UP system.So, in summary, we can use
tlb_remove_ptdesc()to support fast gup in all cases, and this interface is specifically designed for page table pages. So let's use it unconditionally.Signed-off-by Qi Zheng <[email protected]>Suggested-by Peter Zijlstra (Intel) <[email protected]>--- arch/riscv/include/asm/pgalloc.h | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)arch/riscv/include/asm/pgalloc.h +4
-23@@ -15,24 +15,6 @@#define __HAVE_ARCH_PUD_FREE#include <asm-generic/pgalloc.h> -/* -* While riscv platforms with riscv_ipi_for_rfence as true require an IPI to -* perform TLB shootdown, some platforms with riscv_ipi_for_rfence as false use -* SBI to perform TLB shootdown. To keep software pagetable walkers safe in this -* case we switch to RCU based table free (MMU_GATHER_RCU_TABLE_FREE). See the -* comment below 'ifdef CONFIG_MMU_GATHER_RCU_TABLE_FREE' in include/asm-generic/tlb.h -* for more details. -*/ -static inline void riscv_tlb_remove_ptdesc (struct mmu_gather *tlb,void *pt) -{ -if (riscv_use_sbi_for_rfence ()) { -tlb_remove_ptdesc (tlb, pt); - }else { -pagetable_dtor (pt); -tlb_remove_page_ptdesc (tlb, pt); - } -} -static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte) {@@ -108,14 +90,14 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, unsigned long addr) {if (pgtable_l4_enabled) -riscv_tlb_remove_ptdesc (tlb,virt_to_ptdesc (pud)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (pud)); }static inline void __p4d_free_tlb (struct mmu_gather *tlb,p4d_t *p4d,unsigned long addr) {if (pgtable_l5_enabled) -riscv_tlb_remove_ptdesc (tlb,virt_to_ptdesc (p4d)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (p4d)); }#endif /* __PAGETABLE_PMD_FOLDED */ @@ -143,7 +125,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)static inline void __pmd_free_tlb (struct mmu_gather *tlb,pmd_t *pmd,unsigned long addr) { -riscv_tlb_remove_ptdesc (tlb,virt_to_ptdesc (pmd)); +tlb_remove_ptdesc (tlb,virt_to_ptdesc (pmd)); }#endif /* __PAGETABLE_PMD_FOLDED */ @@ -151,7 +133,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t pte,unsigned long addr) { -riscv_tlb_remove_ptdesc (tlb,page_ptdesc (pte)); +tlb_remove_ptdesc (tlb,page_ptdesc (pte)); }#endif /* CONFIG_MMU */ --
Quoted 3 lines
2.20.1
This set of patches mainly refactors the remove page table function interfaces. The comment "riscv_ipi_for_rfence" has been removed, as it was no longer needed, and this patch handles that.
Additionally, whether riscv_use_sbi_for_rfence is true or false, page tables can now be released using RCU. This patch changes the previous synchronous release logic (for !riscv_use_sbi_for_rfence) to an RCU-based release.
So, Reviewed-by: Yunhui Cui <[email protected]>
Based on qemu-system-riscv64, I tested this patch. The log is as follows:
./gup_test
TAP version 13
1..1
# GUP_FAST_BENCHMARK: Time: get:663365 put:117 us
# ok 1 ioctl status 0 # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
So, Tested-by: Yunhui Cui <[email protected]>
Thanks,
Yunhui
Re: [PATCH v2 4/6] riscv: pgtable: unconditionally use tlb_remove_ptdesc()
Quoted 2 lines · yunhui cui
Hi Qi,
[...]
Quoted 14 lines
Quoted 2 lines
This set of patches mainly refactors the remove page table function interfaces. The comment "
riscv_ipi_for_rfence" has been removed, as it was no longer needed, and this patch handles that.Additionally, whether
riscv_use_sbi_for_rfenceis true or false, page tables can now be released using RCU. This patch changes the previous synchronous release logic (for !riscv_use_sbi_for_rfence) to an RCU-based release.So, Reviewed-by: Yunhui Cui <[email protected]>
Quoted 7 lines
Based on qemu-system-riscv64, I tested this patch. The log is as follows:
./gup_test
TAP version 13
1..1
#GUP_FAST_BENCHMARK: Time: get:663365 put:117 us# ok 1 ioctl status 0 # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
Nice.
Quoted 2 lines
So, Tested-by: Yunhui Cui <[email protected]>
Thank you very much for your review and testing!
Quoted 3 lines
Thanks,
Yunhui
PATCH v2 3/6 mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
In reply to Qi ZhengNow, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just call pagetable_dtor() + tlb_remove_page_ptdesc() (the wrapper of tlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to use tlb_remove_ptdesc().
The ultimate goal is to make the architecture only use tlb_remove_ptdesc() or tlb_remove_table() for page table pages.
---
Changes in v2 update:
- remove the do { ... } while construct. (Geert Uytterhoeven)
- collect the Reviewed-by and Acked-by.
arch/csky/include/asm/pgalloc.h | 7 ++----- arch/hexagon/include/asm/pgalloc.h | 7 ++----- arch/loongarch/include/asm/pgalloc.h | 7 ++----- arch/m68k/include/asm/sun3_pgalloc.h | 7 ++----- arch/mips/include/asm/pgalloc.h | 7 ++----- arch/nios2/include/asm/pgalloc.h | 7 ++----- arch/openrisc/include/asm/pgalloc.h | 7 ++----- arch/sh/include/asm/pgalloc.h | 7 ++----- arch/um/include/asm/pgalloc.h | 21 ++++++--------------- 9 files changed, 22 insertions(+), 55 deletions(-)
arch/csky/include/asm/pgalloc.h +2 -5
@@ -61,11 +61,8 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)return ret; } -#define __pte_free_tlb (tlb, pte, address) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc(tlb, page_ptdesc(pte)); \ -} while (0) +#define __pte_free_tlb (tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))extern void pagetable_init (void );extern void mmu_init (unsigned long min_pfn,unsigned long max_pfn);
arch/hexagon/include/asm/pgalloc.h +2 -5
@@ -87,10 +87,7 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, max_kernel_seg = pmdindex; } -#define __pte_free_tlb (tlb, pte, addr) \ -do { \ - pagetable_dtor((page_ptdesc(pte))); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ -} while (0) +#define __pte_free_tlb (tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))#endif
arch/loongarch/include/asm/pgalloc.h +2 -5
@@ -55,11 +55,8 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)return pte; } -#define __pte_free_tlb (tlb, pte, address) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ -} while (0) +#define __pte_free_tlb (tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte));#ifndef __PAGETABLE_PMD_FOLDED
arch/m68k/include/asm/sun3_pgalloc.h +2 -5
@@ -17,11 +17,8 @@extern const char bad_pmd_string[]; -#define __pte_free_tlb (tlb, pte, addr) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ -} while (0) +#define __pte_free_tlb (tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte) {
arch/mips/include/asm/pgalloc.h +2 -5
@@ -48,11 +48,8 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)extern void pgd_init (void *addr);extern pgd_t *pgd_alloc (struct mm_struct *mm); -#define __pte_free_tlb (tlb, pte, address) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ -} while (0) +#define __pte_free_tlb (tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))#ifndef __PAGETABLE_PMD_FOLDED
arch/nios2/include/asm/pgalloc.h +2 -5
@@ -28,10 +28,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,extern pgd_t *pgd_alloc (struct mm_struct *mm); -#define __pte_free_tlb (tlb, pte, addr) \ - do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ - } while (0) +#define __pte_free_tlb (tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))#endif /* _ASM_NIOS2_PGALLOC_H */
arch/openrisc/include/asm/pgalloc.h +2 -5
@@ -64,10 +64,7 @@ extern inline pgd_t *pgd_alloc(struct mm_struct *mm)extern pte_t *pte_alloc_one_kernel (struct mm_struct *mm); -#define __pte_free_tlb (tlb, pte, addr) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ -} while (0) +#define __pte_free_tlb (tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))#endif
arch/sh/include/asm/pgalloc.h +2 -5
@@ -32,10 +32,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, set_pmd(pmd, __pmd((unsigned long)page_address(pte))); } -#define __pte_free_tlb (tlb, pte, addr) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ -} while (0) +#define __pte_free_tlb (tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))#endif /* __ASM_SH_PGALLOC_H */
arch/um/include/asm/pgalloc.h +6 -15
@@ -25,27 +25,18 @@*/ extern pgd_t *pgd_alloc (struct mm_struct *); -#define __pte_free_tlb (tlb, pte, address) \ -do { \ - pagetable_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ -} while (0) +#define __pte_free_tlb (tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))#if CONFIG_PGTABLE_LEVELS >2 -#define __pmd_free_tlb (tlb, pmd, address) \ -do { \ - pagetable_dtor(virt_to_ptdesc(pmd)); \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pmd)); \ -} while (0) +#define __pmd_free_tlb (tlb, pmd, address) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd))#if CONFIG_PGTABLE_LEVELS >3 -#define __pud_free_tlb (tlb, pud, address) \ -do { \ - pagetable_dtor(virt_to_ptdesc(pud)); \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pud)); \ -} while (0) +#define __pud_free_tlb (tlb, pud, address) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pud))#endif #endif
Signature · 1 line
2.20.1
Andrew Morton
maintainerRe: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
Quoted 7 lines · On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <[email protected]> wrote:
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().
checkpatch warns.
Do these things have to be macros? Switching to static inline fixes the unused-arg warning in a nice fashion.
I'll fix the trailing-semicolon issue locally.
WARNING: Argument 'address' is not used in function-like macro #51: FILE: arch/csky/include/asm/pgalloc.h:64:
+#define __pte_free_tlb(tlb, pte, address) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'addr' is not used in function-like macro #66: FILE: arch/hexagon/include/asm/pgalloc.h:90:
+#define __pte_free_tlb(tlb, pte, addr) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'address' is not used in function-like macro #80: FILE: arch/loongarch/include/asm/pgalloc.h:58:
+#define __pte_free_tlb(tlb, pte, address) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte));
WARNING: macros should not use a trailing semicolon #80: FILE: arch/loongarch/include/asm/pgalloc.h:58:
+#define __pte_free_tlb(tlb, pte, address) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte));
WARNING: Argument 'addr' is not used in function-like macro #95: FILE: arch/m68k/include/asm/sun3_pgalloc.h:20:
+#define __pte_free_tlb(tlb, pte, addr) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'address' is not used in function-like macro #110: FILE: arch/mips/include/asm/pgalloc.h:51:
+#define __pte_free_tlb(tlb, pte, address) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'addr' is not used in function-like macro #125: FILE: arch/nios2/include/asm/pgalloc.h:31:
+#define __pte_free_tlb(tlb, pte, addr) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'addr' is not used in function-like macro #139: FILE: arch/openrisc/include/asm/pgalloc.h:67:
+#define __pte_free_tlb(tlb, pte, addr) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'addr' is not used in function-like macro #153: FILE: arch/sh/include/asm/pgalloc.h:35:
+#define __pte_free_tlb(tlb, pte, addr) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'address' is not used in function-like macro #167: FILE: arch/um/include/asm/pgalloc.h:28:
+#define __pte_free_tlb(tlb, pte, address) \
+ tlb_remove_ptdesc((tlb), page_ptdesc(pte))
WARNING: Argument 'address' is not used in function-like macro #176: FILE: arch/um/include/asm/pgalloc.h:33:
+#define __pmd_free_tlb(tlb, pmd, address) \
+ tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd))
WARNING: Argument 'address' is not used in function-like macro #185: FILE: arch/um/include/asm/pgalloc.h:38:
+#define __pud_free_tlb(tlb, pud, address) \
+ tlb_remove_ptdesc((tlb), virt_to_ptdesc(pud))
total: 0 errors, 12 warnings, 122 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
./patches/mm-pgtable-convert-some-architectures-to-use-tlb_remove_ptdesc-v2.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
Re: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <[email protected]> wrote:
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().
Quoted 4 lines
checkpatch warns.
Do these things have to be macros? Switching to static inline fixes the unused-arg warning in a nice fashion.
This can be switched to static inline. In addition, I found that alpha, arc, microblaze, parisc, sparc32 and xtensa also have the unused-arg issue. Do I need to add a new patch to fix all of them, or just fix the newly added 11 warnings?
Quoted 2 lines
I'll fix the trailing-semicolon issue locally.
Thanks!
Quoted 71 lines
WARNING: Argument 'address' is not used in function-like macro #51: FILE:
arch/csky/include/asm/pgalloc.h:64:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'addr' is not used in function-like macro #66: FILE:
arch/hexagon/include/asm/pgalloc.h:90:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'address' is not used in function-like macro #80: FILE:
arch/loongarch/include/asm/pgalloc.h:58:arch/loongarch/include/asm/pgalloc.h +2
-0+#define __pte_free_tlb (tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte));WARNING: macros should not use a trailing semicolon #80: FILE:
arch/loongarch/include/asm/pgalloc.h:58:arch/loongarch/include/asm/pgalloc.h +2
-0+#define __pte_free_tlb (tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte));WARNING: Argument 'addr' is not used in function-like macro #95: FILE:
arch/m68k/include/asm/sun3_pgalloc.h:20:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'address' is not used in function-like macro #110: FILE:
arch/mips/include/asm/pgalloc.h:51:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'addr' is not used in function-like macro #125: FILE:
arch/nios2/include/asm/pgalloc.h:31:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'addr' is not used in function-like macro #139: FILE:
arch/openrisc/include/asm/pgalloc.h:67:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'addr' is not used in function-like macro #153: FILE:
arch/sh/include/asm/pgalloc.h:35:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'address' is not used in function-like macro #167: FILE:
arch/um/include/asm/pgalloc.h:28:(quoted diff) +2
-0+#define __pte_free_tlb(tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte))WARNING: Argument 'address' is not used in function-like macro #176: FILE:
arch/um/include/asm/pgalloc.h:33:arch/um/include/asm/pgalloc.h +2
-0+#define __pmd_free_tlb (tlb, pmd, address) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd))WARNING: Argument 'address' is not used in function-like macro #185: FILE:
arch/um/include/asm/pgalloc.h:38:arch/um/include/asm/pgalloc.h +2
-0+#define __pud_free_tlb (tlb, pud, address) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pud))total: 0 errors, 12 warnings, 122 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
./patches/mm-pgtable-convert-some-architectures-to-use-tlb_remove_ptdesc-v2.patchhas style problems, please review.NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH inMAINTAINERS.
Andrew Morton
maintainerRe: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
Quoted 15 lines · On Tue, 4 Mar 2025 10:31:07 +0800 Qi Zheng <[email protected]> wrote:
Quoted 12 lines · Andrew Morton
Quoted 7 lines · On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <[email protected]> wrote:
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().checkpatch warns.
Quoted 7 lines
Quoted 2 lines
Do these things have to be macros? Switching to static inline fixes the unused-arg warning in a nice fashion.
This can be switched to static inline. In addition, I found that alpha, arc, microblaze, parisc, sparc32 and xtensa also have the unused-arg issue. Do I need to add a new patch to fix all of them, or just fix the newly added 11 warnings?
I guess leave things as they are now. Switching all these to C functions can be addressed at a later time?
Re: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
Quoted 20 lines · Andrew Morton
Quoted 18 lines · On Tue, 4 Mar 2025 10:31:07 +0800 Qi Zheng <[email protected]> wrote:
Quoted 14 lines · Andrew Morton
Quoted 7 lines · On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <[email protected]> wrote:
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips, nios2, openrisc, sh and um do not select
CONFIG_MMU_GATHER_RCU_TABLE_FREE, and just callpagetable_dtor()+tlb_remove_page_ptdesc()(the wrapper oftlb_remove_page()). This is the same as the implementation of tlb_remove_{ptdesc|table}() under !CONFIG_MMU_GATHER_TABLE_FREE, so convert these architectures to usetlb_remove_ptdesc().checkpatch warns.
Do these things have to be macros? Switching to static inline fixes the unused-arg warning in a nice fashion.
Quoted 7 lines
Quoted 4 lines
This can be switched to static inline. In addition, I found that alpha, arc, microblaze, parisc, sparc32 and xtensa also have the unused-arg issue. Do I need to add a new patch to fix all of them, or just fix the newly added 11 warnings?
I guess leave things as they are now. Switching all these to C functions can be addressed at a later time?
Okay, let's leave it for later.