* [PATCH v2 0/6] remove tlb_remove_page_ptdesc()
@ 2025-02-25 3:45 Qi Zheng
2025-02-25 3:45 ` [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc Qi Zheng
` (5 more replies)
0 siblings, 6 replies; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, Qi Zheng
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/20250103111457.GC22934@noisy.programming.kicks-ass.net/
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(-)
--
2.20.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
@ 2025-02-25 3:45 ` Qi Zheng
2025-02-26 8:30 ` Kevin Brodsky
2025-02-25 3:45 ` [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc * Qi Zheng
` (4 subsequent siblings)
5 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, Qi Zheng
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.
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
---
include/asm-generic/tlb.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index b35b36fa7aabf..54f579750c8e5 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -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 */
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc *
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
2025-02-25 3:45 ` [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc Qi Zheng
@ 2025-02-25 3:45 ` Qi Zheng
2025-02-26 8:31 ` Kevin Brodsky
2025-02-25 3:45 ` [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc() Qi Zheng
` (3 subsequent siblings)
5 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, 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 <zhengqi.arch@bytedance.com>
Originally-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/asm-generic/tlb.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 54f579750c8e5..18bf499ef8801 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -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);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
2025-02-25 3:45 ` [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc Qi Zheng
2025-02-25 3:45 ` [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc * Qi Zheng
@ 2025-02-25 3:45 ` Qi Zheng
2025-02-26 8:31 ` Kevin Brodsky
` (2 more replies)
2025-02-25 3:45 ` [PATCH v2 4/6] riscv: pgtable: unconditionally " Qi Zheng
` (2 subsequent siblings)
5 siblings, 3 replies; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, 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 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.
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
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(-)
diff --git a/arch/csky/include/asm/pgalloc.h b/arch/csky/include/asm/pgalloc.h
index bf8400c28b5a3..9d2b50265a8d8 100644
--- a/arch/csky/include/asm/pgalloc.h
+++ b/arch/csky/include/asm/pgalloc.h
@@ -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);
diff --git a/arch/hexagon/include/asm/pgalloc.h b/arch/hexagon/include/asm/pgalloc.h
index 1ee5f5f157ca7..3d35d2bc42534 100644
--- a/arch/hexagon/include/asm/pgalloc.h
+++ b/arch/hexagon/include/asm/pgalloc.h
@@ -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
diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h
index 7211dff8c969e..ac026146e7e95 100644
--- a/arch/loongarch/include/asm/pgalloc.h
+++ b/arch/loongarch/include/asm/pgalloc.h
@@ -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
diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h
index 80afc3a187249..ddc24812f1832 100644
--- a/arch/m68k/include/asm/sun3_pgalloc.h
+++ b/arch/m68k/include/asm/sun3_pgalloc.h
@@ -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)
diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 26c7a6ede983c..7e73d2f913dd4 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -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
diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h
index 12a536b7bfbd4..4b4a1766e2cc7 100644
--- a/arch/nios2/include/asm/pgalloc.h
+++ b/arch/nios2/include/asm/pgalloc.h
@@ -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 */
diff --git a/arch/openrisc/include/asm/pgalloc.h b/arch/openrisc/include/asm/pgalloc.h
index 3372f4e6ab4b5..2964e26980a18 100644
--- a/arch/openrisc/include/asm/pgalloc.h
+++ b/arch/openrisc/include/asm/pgalloc.h
@@ -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
diff --git a/arch/sh/include/asm/pgalloc.h b/arch/sh/include/asm/pgalloc.h
index 96d938fdf2244..c376d4b708fda 100644
--- a/arch/sh/include/asm/pgalloc.h
+++ b/arch/sh/include/asm/pgalloc.h
@@ -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 */
diff --git a/arch/um/include/asm/pgalloc.h b/arch/um/include/asm/pgalloc.h
index f0af23c3aeb2b..a70151cfd11c9 100644
--- a/arch/um/include/asm/pgalloc.h
+++ b/arch/um/include/asm/pgalloc.h
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 4/6] riscv: pgtable: unconditionally use tlb_remove_ptdesc()
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
` (2 preceding siblings ...)
2025-02-25 3:45 ` [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc() Qi Zheng
@ 2025-02-25 3:45 ` Qi Zheng
2025-03-03 1:45 ` [External] " yunhui cui
2025-02-25 3:45 ` [PATCH v2 5/6] x86: pgtable: convert to " Qi Zheng
2025-02-25 3:45 ` [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc() Qi Zheng
5 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, Qi Zheng
To 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.
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/riscv/include/asm/pgalloc.h | 26 ++++----------------------
1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h
index 3e2aebea6312d..770ce18a7328b 100644
--- a/arch/riscv/include/asm/pgalloc.h
+++ b/arch/riscv/include/asm/pgalloc.h
@@ -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 */
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 5/6] x86: pgtable: convert to use tlb_remove_ptdesc()
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
` (3 preceding siblings ...)
2025-02-25 3:45 ` [PATCH v2 4/6] riscv: pgtable: unconditionally " Qi Zheng
@ 2025-02-25 3:45 ` Qi Zheng
2025-02-26 2:35 ` Andrew Morton
2025-02-25 3:45 ` [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc() Qi Zheng
5 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, Qi Zheng
The x86 has already been converted to use struct ptdesc, so convert it to
use tlb_remove_ptdesc() instead of tlb_remove_table().
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
---
arch/x86/mm/pgtable.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index b1c1f72c1fd1b..f28ddac0f734a 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -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 */
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc()
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
` (4 preceding siblings ...)
2025-02-25 3:45 ` [PATCH v2 5/6] x86: pgtable: convert to " Qi Zheng
@ 2025-02-25 3:45 ` Qi Zheng
2025-02-26 8:32 ` Kevin Brodsky
5 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-02-25 3:45 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv, 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 <zhengqi.arch@bytedance.com>
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/asm-generic/tlb.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 18bf499ef8801..dd292c6d3ce88 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -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)
{
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v2 5/6] x86: pgtable: convert to use tlb_remove_ptdesc()
2025-02-25 3:45 ` [PATCH v2 5/6] x86: pgtable: convert to " Qi Zheng
@ 2025-02-26 2:35 ` Andrew Morton
2025-02-26 2:40 ` Qi Zheng
0 siblings, 1 reply; 22+ messages in thread
From: Andrew Morton @ 2025-02-26 2:35 UTC (permalink / raw)
To: Qi Zheng
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti, linux-mm, linux-kernel, linux-csky,
linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
linux-sh, linux-um, x86, linux-riscv
On Tue, 25 Feb 2025 11:45:55 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
> The x86 has already been converted to use struct ptdesc, so convert it to
> use tlb_remove_ptdesc() instead of tlb_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.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 5/6] x86: pgtable: convert to use tlb_remove_ptdesc()
2025-02-26 2:35 ` Andrew Morton
@ 2025-02-26 2:40 ` Qi Zheng
0 siblings, 0 replies; 22+ messages in thread
From: Qi Zheng @ 2025-02-26 2:40 UTC (permalink / raw)
To: Andrew Morton
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti, linux-mm, linux-kernel, linux-csky,
linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
linux-sh, linux-um, x86, linux-riscv
On 2/26/25 上午10:35, Andrew Morton wrote:
> On Tue, 25 Feb 2025 11:45:55 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
>
>> The x86 has already been converted to use struct ptdesc, so convert it to
>> use tlb_remove_ptdesc() instead of tlb_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
Yes.
> Rik's patch to mm-unstable also and shall figure it out during the
> merge window.
Thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc
2025-02-25 3:45 ` [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc Qi Zheng
@ 2025-02-26 8:30 ` Kevin Brodsky
0 siblings, 0 replies; 22+ messages in thread
From: Kevin Brodsky @ 2025-02-26 8:30 UTC (permalink / raw)
To: Qi Zheng, peterz, riel, vishal.moola, david, jannh, hughd, willy,
yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv
On 25/02/2025 04:45, Qi Zheng wrote:
> 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.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc *
2025-02-25 3:45 ` [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc * Qi Zheng
@ 2025-02-26 8:31 ` Kevin Brodsky
0 siblings, 0 replies; 22+ messages in thread
From: Kevin Brodsky @ 2025-02-26 8:31 UTC (permalink / raw)
To: Qi Zheng, peterz, riel, vishal.moola, david, jannh, hughd, willy,
yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv
On 25/02/2025 04:45, Qi Zheng wrote:
> 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 <zhengqi.arch@bytedance.com>
> Originally-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-02-25 3:45 ` [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc() Qi Zheng
@ 2025-02-26 8:31 ` Kevin Brodsky
2025-02-27 13:21 ` Geert Uytterhoeven
2025-03-03 7:26 ` [PATCH v2 3/6 update] " Qi Zheng
2 siblings, 0 replies; 22+ messages in thread
From: Kevin Brodsky @ 2025-02-26 8:31 UTC (permalink / raw)
To: Qi Zheng, peterz, riel, vishal.moola, david, jannh, hughd, willy,
yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv
On 25/02/2025 04:45, Qi Zheng 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 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.
>
> 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>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc()
2025-02-25 3:45 ` [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc() Qi Zheng
@ 2025-02-26 8:32 ` Kevin Brodsky
0 siblings, 0 replies; 22+ messages in thread
From: Kevin Brodsky @ 2025-02-26 8:32 UTC (permalink / raw)
To: Qi Zheng, peterz, riel, vishal.moola, david, jannh, hughd, willy,
yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um, x86,
linux-riscv
On 25/02/2025 04:45, Qi Zheng wrote:
> 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 <zhengqi.arch@bytedance.com>
> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-02-25 3:45 ` [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc() Qi Zheng
2025-02-26 8:31 ` Kevin Brodsky
@ 2025-02-27 13:21 ` Geert Uytterhoeven
2025-02-28 2:44 ` Qi Zheng
2025-03-03 7:26 ` [PATCH v2 3/6 update] " Qi Zheng
2 siblings, 1 reply; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-02-27 13:21 UTC (permalink / raw)
To: Qi Zheng
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti, linux-mm, linux-kernel,
linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
linux-openrisc, linux-sh, linux-um, x86, linux-riscv
Hi Qi,
On Tue, 25 Feb 2025 at 04:46, Qi Zheng <zhengqi.arch@bytedance.com> 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 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.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Thanks for your patch!
> arch/m68k/include/asm/sun3_pgalloc.h | 3 +--
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
> --- a/arch/m68k/include/asm/sun3_pgalloc.h
> +++ b/arch/m68k/include/asm/sun3_pgalloc.h
> @@ -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
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-02-27 13:21 ` Geert Uytterhoeven
@ 2025-02-28 2:44 ` Qi Zheng
0 siblings, 0 replies; 22+ messages in thread
From: Qi Zheng @ 2025-02-28 2:44 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti, linux-mm, linux-kernel,
linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
linux-openrisc, linux-sh, linux-um, x86, linux-riscv
On 2/27/25 9:21 PM, Geert Uytterhoeven wrote:
> Hi Qi,
>
> On Tue, 25 Feb 2025 at 04:46, Qi Zheng <zhengqi.arch@bytedance.com> 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 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.
>>
>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>
> Thanks for your patch!
>
>> arch/m68k/include/asm/sun3_pgalloc.h | 3 +--
>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
Thanks for your review.
>
>> --- a/arch/m68k/include/asm/sun3_pgalloc.h
>> +++ b/arch/m68k/include/asm/sun3_pgalloc.h
>> @@ -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.
Ah, right. Will do in the next version.
Thanks!
>
> Gr{oetje,eeting}s,
>
> Geert
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [External] [PATCH v2 4/6] riscv: pgtable: unconditionally use tlb_remove_ptdesc()
2025-02-25 3:45 ` [PATCH v2 4/6] riscv: pgtable: unconditionally " Qi Zheng
@ 2025-03-03 1:45 ` yunhui cui
2025-03-03 7:15 ` Qi Zheng
0 siblings, 1 reply; 22+ messages in thread
From: yunhui cui @ 2025-03-03 1:45 UTC (permalink / raw)
To: Qi Zheng
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti, linux-mm, linux-kernel,
linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
linux-openrisc, linux-sh, linux-um, x86, linux-riscv
Hi Qi,
On Tue, Feb 25, 2025 at 11:48 AM Qi Zheng <zhengqi.arch@bytedance.com> wrote:
>
> To 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.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/riscv/include/asm/pgalloc.h | 26 ++++----------------------
> 1 file changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h
> index 3e2aebea6312d..770ce18a7328b 100644
> --- a/arch/riscv/include/asm/pgalloc.h
> +++ b/arch/riscv/include/asm/pgalloc.h
> @@ -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 */
>
> --
> 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 <cuiyunhui@bytedance.com>
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 <cuiyunhui@bytedance.com>
Thanks,
Yunhui
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 4/6] riscv: pgtable: unconditionally use tlb_remove_ptdesc()
2025-03-03 1:45 ` [External] " yunhui cui
@ 2025-03-03 7:15 ` Qi Zheng
0 siblings, 0 replies; 22+ messages in thread
From: Qi Zheng @ 2025-03-03 7:15 UTC (permalink / raw)
To: yunhui cui
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti, linux-mm, linux-kernel,
linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
linux-openrisc, linux-sh, linux-um, x86, linux-riscv
On 3/3/25 9:45 AM, yunhui cui wrote:
> Hi Qi,
>
[...]
>>
>>
>
> 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 <cuiyunhui@bytedance.com>
>
> 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.
>
> So, Tested-by: Yunhui Cui <cuiyunhui@bytedance.com>
Thank you very much for your review and testing!
>
> Thanks,
> Yunhui
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-02-25 3:45 ` [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc() Qi Zheng
2025-02-26 8:31 ` Kevin Brodsky
2025-02-27 13:21 ` Geert Uytterhoeven
@ 2025-03-03 7:26 ` Qi Zheng
2025-03-03 23:53 ` Andrew Morton
2 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-03-03 7:26 UTC (permalink / raw)
To: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, akpm, will, aneesh.kumar, npiggin,
arnd, dave.hansen, rppt, alexghiti
Cc: linux-mm, linux-kernel, linux-csky, linux-hexagon, loongarch,
linux-m68k, linux-mips, linux-openrisc, linux-sh, linux-um,
Qi Zheng, Geert Uytterhoeven
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 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.
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: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
---
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(-)
diff --git a/arch/csky/include/asm/pgalloc.h b/arch/csky/include/asm/pgalloc.h
index bf8400c28b5a3..11055c5749686 100644
--- a/arch/csky/include/asm/pgalloc.h
+++ b/arch/csky/include/asm/pgalloc.h
@@ -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);
diff --git a/arch/hexagon/include/asm/pgalloc.h b/arch/hexagon/include/asm/pgalloc.h
index 1ee5f5f157ca7..937a11ef4c33c 100644
--- a/arch/hexagon/include/asm/pgalloc.h
+++ b/arch/hexagon/include/asm/pgalloc.h
@@ -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
diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h
index 7211dff8c969e..73629c1b8328e 100644
--- a/arch/loongarch/include/asm/pgalloc.h
+++ b/arch/loongarch/include/asm/pgalloc.h
@@ -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
diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h
index 80afc3a187249..1e21c758b774e 100644
--- a/arch/m68k/include/asm/sun3_pgalloc.h
+++ b/arch/m68k/include/asm/sun3_pgalloc.h
@@ -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)
{
diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 26c7a6ede983c..bbca420c96d3c 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -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
diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h
index 12a536b7bfbd4..db122b093a8be 100644
--- a/arch/nios2/include/asm/pgalloc.h
+++ b/arch/nios2/include/asm/pgalloc.h
@@ -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 */
diff --git a/arch/openrisc/include/asm/pgalloc.h b/arch/openrisc/include/asm/pgalloc.h
index 3372f4e6ab4b5..3f110931d8f6e 100644
--- a/arch/openrisc/include/asm/pgalloc.h
+++ b/arch/openrisc/include/asm/pgalloc.h
@@ -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
diff --git a/arch/sh/include/asm/pgalloc.h b/arch/sh/include/asm/pgalloc.h
index 96d938fdf2244..6fe7123d38fa9 100644
--- a/arch/sh/include/asm/pgalloc.h
+++ b/arch/sh/include/asm/pgalloc.h
@@ -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 */
diff --git a/arch/um/include/asm/pgalloc.h b/arch/um/include/asm/pgalloc.h
index f0af23c3aeb2b..826ec44b58cdb 100644
--- a/arch/um/include/asm/pgalloc.h
+++ b/arch/um/include/asm/pgalloc.h
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-03-03 7:26 ` [PATCH v2 3/6 update] " Qi Zheng
@ 2025-03-03 23:53 ` Andrew Morton
2025-03-04 2:31 ` Qi Zheng
0 siblings, 1 reply; 22+ messages in thread
From: Andrew Morton @ 2025-03-03 23:53 UTC (permalink / raw)
To: Qi Zheng
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti, linux-mm, linux-kernel, linux-csky,
linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
linux-sh, linux-um, Geert Uytterhoeven
On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <zhengqi.arch@bytedance.com> 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 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().
>
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.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-03-03 23:53 ` Andrew Morton
@ 2025-03-04 2:31 ` Qi Zheng
2025-03-04 4:08 ` Andrew Morton
0 siblings, 1 reply; 22+ messages in thread
From: Qi Zheng @ 2025-03-04 2:31 UTC (permalink / raw)
To: Andrew Morton
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti, linux-mm, linux-kernel, linux-csky,
linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
linux-sh, linux-um, Geert Uytterhoeven
On 3/4/25 7:53 AM, Andrew Morton wrote:
> On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <zhengqi.arch@bytedance.com> 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 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().
>>
>
> 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?
>
> I'll fix the trailing-semicolon issue locally.
Thanks!
>
> 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.
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-03-04 2:31 ` Qi Zheng
@ 2025-03-04 4:08 ` Andrew Morton
2025-03-04 6:11 ` Qi Zheng
0 siblings, 1 reply; 22+ messages in thread
From: Andrew Morton @ 2025-03-04 4:08 UTC (permalink / raw)
To: Qi Zheng
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti, linux-mm, linux-kernel, linux-csky,
linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
linux-sh, linux-um, Geert Uytterhoeven
On Tue, 4 Mar 2025 10:31:07 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
>
>
> On 3/4/25 7:53 AM, Andrew Morton wrote:
> > On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <zhengqi.arch@bytedance.com> 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 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().
> >>
> >
> > 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?
I guess leave things as they are now. Switching all these to C
functions can be addressed at a later time?
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 3/6 update] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
2025-03-04 4:08 ` Andrew Morton
@ 2025-03-04 6:11 ` Qi Zheng
0 siblings, 0 replies; 22+ messages in thread
From: Qi Zheng @ 2025-03-04 6:11 UTC (permalink / raw)
To: Andrew Morton
Cc: peterz, kevin.brodsky, riel, vishal.moola, david, jannh, hughd,
willy, yuzhao, muchun.song, will, aneesh.kumar, npiggin, arnd,
dave.hansen, rppt, alexghiti, linux-mm, linux-kernel, linux-csky,
linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
linux-sh, linux-um, Geert Uytterhoeven
On 3/4/25 12:08 PM, Andrew Morton wrote:
> On Tue, 4 Mar 2025 10:31:07 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
>
>>
>>
>> On 3/4/25 7:53 AM, Andrew Morton wrote:
>>> On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng <zhengqi.arch@bytedance.com> 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 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().
>>>>
>>>
>>> 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?
>
> 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.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2025-03-04 6:11 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 3:45 [PATCH v2 0/6] remove tlb_remove_page_ptdesc() Qi Zheng
2025-02-25 3:45 ` [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc Qi Zheng
2025-02-26 8:30 ` Kevin Brodsky
2025-02-25 3:45 ` [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc * Qi Zheng
2025-02-26 8:31 ` Kevin Brodsky
2025-02-25 3:45 ` [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc() Qi Zheng
2025-02-26 8:31 ` Kevin Brodsky
2025-02-27 13:21 ` Geert Uytterhoeven
2025-02-28 2:44 ` Qi Zheng
2025-03-03 7:26 ` [PATCH v2 3/6 update] " Qi Zheng
2025-03-03 23:53 ` Andrew Morton
2025-03-04 2:31 ` Qi Zheng
2025-03-04 4:08 ` Andrew Morton
2025-03-04 6:11 ` Qi Zheng
2025-02-25 3:45 ` [PATCH v2 4/6] riscv: pgtable: unconditionally " Qi Zheng
2025-03-03 1:45 ` [External] " yunhui cui
2025-03-03 7:15 ` Qi Zheng
2025-02-25 3:45 ` [PATCH v2 5/6] x86: pgtable: convert to " Qi Zheng
2025-02-26 2:35 ` Andrew Morton
2025-02-26 2:40 ` Qi Zheng
2025-02-25 3:45 ` [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc() Qi Zheng
2025-02-26 8:32 ` Kevin Brodsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).