On 3/4/25 12:08 PM, Andrew Morton wrote:
On Tue, 4 Mar 2025 10:31:07 +0800 Qi Zheng wrote:
On 3/4/25 7:53 AM, Andrew Morton wrote:
On Mon, 3 Mar 2025 15:26:03 +0800 Qi Zheng wrote:
Now, the nine architectures of csky, hexagon, loongarch, m68k, mips,
nios2, openrisc, sh and um do not
On 3/4/25 7:53 AM, Andrew Morton wrote:
On Mon, 3 Mar 2025 15:26:03 +0800 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
|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
Suggested-by: Peter Zijlstra (Intel)
Reviewed
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_rfen
On 2/27/25 9:21 PM, Geert Uytterhoeven wrote:
Hi Qi,
On Tue, 25 Feb 2025 at 04:46, 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
On 2/26/25 上午10:35, Andrew Morton wrote:
On Tue, 25 Feb 2025 11:45:55 +0800 Qi Zheng 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 ("x8
ff-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
---
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/
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
---
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
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
Suggested-by: Peter Zijlstra (Intel)
---
arch/riscv/include/asm/pgalloc.h | 26
[1].
https://lore.kernel.org/linux-mm/20250103111457.gc22...@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
|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
Suggested-by: Peter Zijlstra (Intel)
---
arch
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
Originally-by: Peter Zijlstra (Intel)
---
include/asm-generic/tlb.h | 2 +-
1 file changed, 1 inse
.
Signed-off-by: Qi Zheng
---
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
On 2025/1/24 19:47, Peter Zijlstra wrote:
On Thu, Jan 23, 2025 at 09:26:13PM +0800, Qi Zheng wrote:
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
On 2025/1/24 19:38, Peter Zijlstra wrote:
On Thu, Jan 23, 2025 at 09:26:17PM +0800, Qi Zheng wrote:
If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table()
will fall back to pagetable_dtor() + tlb_remove_page(). So let's use
tlb_remove_table() unconditionally to free
ff-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
---
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 10cdbe0e7adfe..dec030cb12108 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/
If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table()
will fall back to pagetable_dtor() + tlb_remove_page(). So let's use
tlb_remove_table() unconditionally to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
---
arch/x86/kernel/parav
/lkml/20250123042447.2259648-2-r...@surriel.com/
Qi Zheng (5):
mm: pgtable: make generic tlb_remove_table() use struct ptdesc
mm: pgtable: convert some architectures to use tlb_remove_ptdesc()
riscv: pgtable: unconditionally use tlb_remove_ptdesc()
x86: pgtable: unconditionally use tlb_remove_
.
Signed-off-by: Qi Zheng
---
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 e402aef79c93e..10cdbe0e7adfe 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -228,10
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
Suggested-by: Peter Zijlstra (Intel)
---
arch/riscv/include/asm/pgalloc.h | 26
|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
Suggested-by: Peter Zijlstra (Intel)
---
arch
Hi Will,
On 2025/1/14 00:26, Will Deacon wrote:
On Wed, Jan 08, 2025 at 02:57:21PM +0800, Qi Zheng wrote:
Like other levels of page tables, also use mmu gather mechanism to free
p4d level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
The __tlb_remove_table_one() in x86 does not contain architecture-specific
content, so move it to the generic file.
Signed-off-by: Qi Zheng
Reviewed-by: Kevin Brodsky
---
arch/x86/include/asm/tlb.h | 19 ---
mm/mmu_gather.c| 20 ++--
2 files changed
Move pagetable_dtor() to __tlb_remove_table(), so that ptlock and page
table pages can be freed together (regardless of whether RCU is used).
This prevents the use-after-free problem where the ptlock is freed
immediately but the page table pages is freed later via RCU.
Signed-off-by: Qi Zheng
s390 also calls generic pagetable_dtor_free().
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
Acked-by: Alexander Gordeev # s390
---
arch/s390/mm/pgalloc.c| 6 --
include/asm-generic/pgalloc.h | 12
include/asm-generic/tlb.
Several architectures (arm, arm64, riscv and x86) define exactly the
same __tlb_remove_table(), just introduce generic __tlb_remove_table() to
eliminate these duplications.
The s390 __tlb_remove_table() is nearly the same, so also make s390
__tlb_remove_table() version generic.
Signed-off-by: Qi
more easily.
Signed-off-by: Qi Zheng
Suggested-by: Kevin Brodsky
Reviewed-by: Kevin Brodsky
---
arch/arm/include/asm/tlb.h | 4
include/asm-generic/tlb.h | 10 --
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/
Call pagetable_dtor() for PMD|PUD|P4D tables just before ptdesc is
freed - same as it is done for PTE tables. That allows consolidating
TLB free paths for all table types.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
Cc: linux-s...@vger.kernel.org
Convert __tlb_remove_table() to use struct ptdesc, which will help to move
pagetable_dtor() to __tlb_remove_table().
And page tables shouldn't have swap cache, so use pagetable_free() instead
of free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
---
arch/x86/in
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
By the way, move the comment above __tlb_remove_table() to
riscv_tlb_remove_ptdesc(), it will be more appropriate.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Reviewed-by:
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm64/include/asm/tlb.h | 10 --
1 file ch
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm/include/asm/tlb.h | 9 ++---
1 file chang
d-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
---
Documentation/mm/split_page_table_lock.rst | 4 +-
arch/arm/include/asm/tlb.h | 4 +-
arch/arm64/include/asm/tlb.h | 8 ++--
arch/csky/include/asm/pgalloc.h| 2
Like PMD and PTE level page table, also add statistics for PUD and P4D
page table.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
Cc: linux-s...@vger.kernel.org
---
arch/s390/include/asm/pgalloc.h | 29 +
arch/s390/include
Like other levels of page tables, also use mmu gather mechanism to free
p4d level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm64/include/asm/pgalloc.h | 1 -
arch/arm64/include/asm
Like other levels of page tables, add statistics for P4D level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
Reviewed-by: Kevin Brodsky
---
arch/riscv/include/asm/pgalloc.h | 6 +-
arch/x86/mm/pgtable.c| 3 +++
include/asm-generic/pgalloc.h
orted architectures, so we might as well include this check
in the generic implementation. No runtime check is required in
p4d_alloc_one() as the top-level p4d_alloc() already does the
required check.
Signed-off-by: Kevin Brodsky
Acked-by: Dave Hansen
Signed-off-by: Qi Zheng
---
arch/arm64/includ
generic version, so we remove it altogether.
This is consistent with the way arm64 and x86 handle this situation
(runtime check in p4d_free() only).
Signed-off-by: Kevin Brodsky
Signed-off-by: Qi Zheng
Acked-by: Dave Hansen
Reviewed-by: Alexandre Ghiti
---
arch/riscv/include/asm/pgalloc.h | 22
This reverts commit 2f3443770437e49abc39af26962d293851cbab6d.
Signed-off-by: Qi Zheng
Reviewed-by: Kevin Brodsky
---
include/linux/mm.h | 2 +-
include/linux/mm_types.h | 9 +
mm/memory.c | 22 ++
3 files changed, 8 insertions(+), 25 deletions
.
Comments and suggestions are welcome!
Thanks,
Qi
[1].
https://lore.kernel.org/all/20241211133433.gc12...@noisy.programming.kicks-ass.net/
[2]. https://lore.kernel.org/all/67548279.050a0220.a30f1.015b@google.com/
Kevin Brodsky (2):
riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one
asm-gen
On 2025/1/7 20:32, Andreas Larsson wrote:
On 2024-12-30 10:07, Qi Zheng wrote:
diff --git a/arch/sparc/include/asm/tlb_32.h b/arch/sparc/include/asm/tlb_32.h
index 5cd28a8793e39..910254867dfbd 100644
--- a/arch/sparc/include/asm/tlb_32.h
+++ b/arch/sparc/include/asm/tlb_32.h
@@ -2,6 +2,7
On 2025/1/7 19:58, Kevin Brodsky wrote:
On 07/01/2025 11:51, Qi Zheng wrote:
[...]
Author: Qi Zheng
Date: Fri Dec 13 17:13:48 2024 +0800
mm: pgtable: completely move pagetable_dtor() to generic
tlb_remove_table()
For the generic tlb_remove_table(), it is implemented in the
On 2025/1/7 17:57, Kevin Brodsky wrote:
On 06/01/2025 04:49, Qi Zheng wrote:
[...]
Once this is done, we should be able to replace all those confusing
calls to tlb_remove_page() on PTPs with tlb_remove_table() and remove
the explicit call to pagetable_dtor(). AIUI this is essentially what
On 2025/1/6 22:35, Alexander Gordeev wrote:
On Mon, Jan 06, 2025 at 09:34:55PM +0800, Qi Zheng wrote:
OK, will change the subject and description to:
s390: pgtable: also move pagetable_dtor() of PxD to pagetable_dtor_free()
To unify the PxD and PTE TLB free path, also move the
On 2025/1/6 21:34, Alexander Gordeev wrote:
On Mon, Jan 06, 2025 at 07:05:16PM +0800, Qi Zheng wrote:
I understand that you want to sort p.._free_tlb() routines, but please
Yes, I thought it was a minor change, so I just did it.
do not move the code around or make a separate follow-up
On 2025/1/6 20:44, Alexander Gordeev wrote:
On Mon, Jan 06, 2025 at 07:02:17PM +0800, Qi Zheng wrote:
On Mon, Dec 30, 2024 at 05:07:47PM +0800, Qi Zheng wrote:
To unify the PxD and PTE TLB free path, also move the pagetable_dtor() of
PMD|PUD|P4D to __tlb_remove_table().
The above and
On 2025/1/6 20:36, Alexander Gordeev wrote:
On Mon, Jan 06, 2025 at 06:55:58PM +0800, Qi Zheng wrote:
+static inline void pagetable_dtor(struct ptdesc *ptdesc)
+{
+ struct folio *folio = ptdesc_folio(ptdesc);
+
+ ptlock_free(ptdesc);
+ __folio_clear_pgtable(folio
On 2025/1/6 18:32, Alexander Gordeev wrote:
On Mon, Dec 30, 2024 at 05:07:41PM +0800, Qi Zheng wrote:
Like PMD and PTE level page table, also add statistics for PUD and P4D
page table.
...
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
index e95b2c8081eb8
On 2025/1/6 18:36, Alexander Gordeev wrote:
On Mon, Dec 30, 2024 at 05:07:47PM +0800, Qi Zheng wrote:
To unify the PxD and PTE TLB free path, also move the pagetable_dtor() of
PMD|PUD|P4D to __tlb_remove_table().
The above and Subject are still incorrect: pagetable_dtor() is
called from
On 2025/1/6 18:34, Alexander Gordeev wrote:
On Mon, Dec 30, 2024 at 05:07:42PM +0800, Qi Zheng wrote:
The pagetable_p*_dtor() are exactly the same except for the handling of
ptlock. If we make ptlock_free() handle the case where ptdesc->ptl is
NULL and remove VM_BUG_ON_PAGE() f
Cc: Catalin Marinas
Cc: Dave Hansen
Cc: Linus Walleij
Cc: Andy Lutomirski
Cc: Peter Zijlstra
Cc: "Mike Rapoport (IBM)"
Cc: Ryan Roberts
Cc: Thomas Gleixner
Cc: Will Deacon
Cc: Matthew Wilcox
Cc: Qi Zheng
Cc: linux-al...@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: linux-ar
On 2025/1/3 19:14, Peter Zijlstra wrote:
On Sat, Dec 28, 2024 at 11:26:22AM +0200, Mike Rapoport wrote:
On Mon, Dec 23, 2024 at 05:41:01PM +0800, Qi Zheng wrote:
Here we are explicitly dealing with struct page, and the following logic
semms strange:
tlb_remove_page_ptdesc((tlb
Hi Kevin,
On 2025/1/3 21:27, Kevin Brodsky wrote:
On 03/01/2025 10:35, Qi Zheng wrote:
On 2025/1/3 17:13, Qi Zheng wrote:
On 2025/1/3 16:02, Kevin Brodsky wrote:
On 03/01/2025 04:48, Qi Zheng wrote:
[...]
In __tlb_batch_free_encoded_pages(), we can indeed detect PageTable()
and call
On 2025/1/3 17:13, Qi Zheng wrote:
On 2025/1/3 16:02, Kevin Brodsky wrote:
On 03/01/2025 04:48, Qi Zheng wrote:
Hi Kevin,
On 2025/1/3 00:53, Kevin Brodsky wrote:
On 30/12/2024 10:07, Qi Zheng wrote:
static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb,
void *pt
On 2025/1/3 16:02, Kevin Brodsky wrote:
On 03/01/2025 04:48, Qi Zheng wrote:
Hi Kevin,
On 2025/1/3 00:53, Kevin Brodsky wrote:
On 30/12/2024 10:07, Qi Zheng wrote:
static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb,
void *pt)
{
- if (riscv_use_sbi_for_rfence
On 2025/1/3 01:00, Kevin Brodsky wrote:
On 30/12/2024 10:07, Qi Zheng wrote:
Qi Zheng (13):
Revert "mm: pgtable: make ptlock be freed by RCU"
mm: pgtable: add statistics for P4D level page table
arm64: pgtable: use mmu gather to free p4d level page table
s390: pg
On 2025/1/3 00:53, Kevin Brodsky wrote:
On 30/12/2024 10:07, Qi Zheng wrote:
diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h
index 551d614d3369c..3466fbe2e508d 100644
--- a/arch/riscv/include/asm/pgalloc.h
+++ b/arch/riscv/include/asm/pgalloc.h
@@ -108,8
Hi Kevin,
On 2025/1/3 00:53, Kevin Brodsky wrote:
On 30/12/2024 10:07, Qi Zheng wrote:
static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb, void *pt)
{
- if (riscv_use_sbi_for_rfence())
+ if (riscv_use_sbi_for_rfence()) {
tlb_remove_ptdesc(tlb, pt
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm64/include/asm/tlb.h | 10 --
1 file changed, 4 insertions(+), 6 dele
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: x...@kernel.org
---
arch/x86/include/asm/tlb.h | 17 ++---
arch/x86/kernel/paravirt.c | 1 +
arch/x86/mm/pgta
To unify the PxD and PTE TLB free path, also move the pagetable_dtor() of
PMD|PUD|P4D to __tlb_remove_table().
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-s...@vger.kernel.org
---
arch/s390/include/asm/tlb.h | 3 ---
arch/s390/mm/pgalloc.c | 14
The __tlb_remove_table_one() in x86 does not contain architecture-specific
content, so move it to the generic file.
Signed-off-by: Qi Zheng
---
arch/x86/include/asm/tlb.h | 19 ---
mm/mmu_gather.c| 20 ++--
2 files changed, 18 insertions(+), 21
s390 also calls generic pagetable_dtor_free().
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
---
arch/s390/mm/pgalloc.c| 6 --
include/asm-generic/pgalloc.h | 12
include/asm-generic/tlb.h | 3 +--
include/linux/mm.h| 6 ++
4 files c
Several architectures (arm, arm64, riscv and x86) define exactly the
same __tlb_remove_table(), just introduce generic __tlb_remove_table() to
eliminate these duplications.
The s390 __tlb_remove_table() is nearly the same, so also make s390
__tlb_remove_table() version generic.
Signed-off-by: Qi
Like PMD and PTE level page table, also add statistics for PUD and P4D
page table.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-s...@vger.kernel.org
---
arch/s390/include/asm/pgalloc.h | 29 +++---
arch/s390/include/asm/tlb.h | 37
orted architectures, so we might as well include this check
in the generic implementation. No runtime check is required in
p4d_alloc_one() as the top-level p4d_alloc() already does the
required check.
Signed-off-by: Kevin Brodsky
Acked-by: Dave Hansen
Signed-off-by: Qi Zheng
---
arch/arm64/includ
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
By the way, move the comment above __tlb_remove_table() to
riscv_tlb_remove_ptdesc(), it will be more appropriate.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: lin
This reverts commit 2f3443770437e49abc39af26962d293851cbab6d.
Signed-off-by: Qi Zheng
---
include/linux/mm.h | 2 +-
include/linux/mm_types.h | 9 +
mm/memory.c | 22 ++
3 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/include
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm/include/asm/tlb.h | 9 -
1 file changed, 4 insertions(+), 5 dele
d-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
---
Documentation/mm/split_page_table_lock.rst | 4 +-
arch/arm/include/asm/tlb.h | 4 +-
arch/arm64/include/asm/tlb.h | 8 ++--
arch/csky/include/asm/pgalloc.h| 2 +-
arch/hexagon/include/asm/p
Like other levels of page tables, also use mmu gather mechanism to free
p4d level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm64/include/asm/pgalloc.h | 1 -
arch/arm64/include/asm/tlb.h | 14
Like other levels of page tables, add statistics for P4D level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
---
arch/riscv/include/asm/pgalloc.h | 6 +-
arch/x86/mm/pgtable.c| 3 +++
include/asm-generic/pgalloc.h| 2 ++
include/linux/mm.h
generic version, so we remove it altogether.
This is consistent with the way arm64 and x86 handle this situation
(runtime check in p4d_free() only).
Signed-off-by: Kevin Brodsky
Acked-by: Dave Hansen
Signed-off-by: Qi Zheng
Acked-by: Palmer Dabbelt
---
arch/riscv/include/asm/pgalloc.h | 22
loc: Provide generic p4d_{alloc_one,free}
Qi Zheng (13):
Revert "mm: pgtable: make ptlock be freed by RCU"
mm: pgtable: add statistics for P4D level page table
arm64: pgtable: use mmu gather to free p4d level page table
s390: pgtable: add statistics for PUD and P4D level page tab
Hi Andrew,
On 2024/12/30 12:55, Andrew Morton wrote:
On Mon, 30 Dec 2024 11:12:00 +0800 Qi Zheng wrote:
For now struct ptdesc overlaps struct page, but the goal is to have them
separate and always operate on struct ptdesc when working with page tables.
OK, so tlb_remove_page_ptdesc() and
Hi Mike,
On 2024/12/28 17:26, Mike Rapoport wrote:
On Mon, Dec 23, 2024 at 05:41:01PM +0800, Qi Zheng wrote:
Here we are explicitly dealing with struct page, and the following logic
semms strange:
tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte)));
tlb_remove_page_ptdesc
--> tlb_remove_p
: Kevin Brodsky
Acked-by: Dave Hansen
Signed-off-by: Qi Zheng
---
arch/riscv/include/asm/pgalloc.h | 22 --
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/arch/riscv/include/asm/pgalloc.h
b/arch/riscv/include/asm/pgalloc.h
index f52264304f772..8ad0bbe838a24
d-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
---
Documentation/mm/split_page_table_lock.rst | 4 +-
arch/arm/include/asm/tlb.h | 4 +-
arch/arm64/include/asm/tlb.h | 8 ++--
arch/csky/include/asm/pgalloc.h| 2 +-
arch/hexagon/include/asm/p
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm/include/asm/tlb.h | 9 -
1 file changed, 4 insertions(+), 5 dele
Like other levels of page tables, add statistics for P4D level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
---
arch/riscv/include/asm/pgalloc.h | 6 +-
arch/x86/mm/pgtable.c| 3 +++
include/asm-generic/pgalloc.h| 2 ++
include/linux/mm.h
orted architectures, so we might as well include this check
in the generic implementation. No runtime check is required in
p4d_alloc_one() as the top-level p4d_alloc() already does the
required check.
Signed-off-by: Kevin Brodsky
Acked-by: Dave Hansen
Signed-off-by: Qi Zheng
---
arch/arm64/includ
x27;s s390 also calls generic pagetable_dtor_free().
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
---
arch/s390/mm/pgalloc.c| 18 ++
include/asm-generic/pgalloc.h | 23 ---
include/asm-generic/tlb.h | 5 +
include/
Just like removing tlb_remove_page_ptdesc(), remove tlb_remove_ptdesc() as
well, and make callers call tlb_remove_table() directly.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
---
arch/arm/include/asm/tlb.h | 8 ++--
arch/arm64/include/asm/tlb.h | 16
tly.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
---
arch/csky/include/asm/pgalloc.h | 2 +-
arch/hexagon/include/asm/pgalloc.h | 2 +-
arch/loongarch/include/asm/pgalloc.h | 2 +-
arch/m68k/include/asm/sun3_pgalloc.h | 2 +-
arch/mips/include/asm/pgalloc.h | 2 +-
arch/ni
The __tlb_remove_table_one() in x86 does not contain architecture-specific
content, so move it to the generic file.
Signed-off-by: Qi Zheng
---
arch/x86/include/asm/tlb.h | 19 ---
mm/mmu_gather.c| 20 ++--
2 files changed, 18 insertions(+), 21
Several architectures (arm, arm64, riscv and x86) define exactly the
same __tlb_remove_table(), just introduce generic __tlb_remove_table() to
eliminate these duplications.
The s390 __tlb_remove_table() is nearly the same, so also make s390
__tlb_remove_table() version generic.
Signed-off-by: Qi
To unify the PxD and PTE TLB free path, also move the pagetable_dtor() of
PMD|PUD|P4D to __tlb_remove_table().
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-s...@vger.kernel.org
---
arch/s390/include/asm/tlb.h | 3 ---
arch/s390/mm/pgalloc.c | 14
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: x...@kernel.org
---
arch/x86/include/asm/tlb.h | 17 ++---
arch/x86/kernel/paravirt.c | 1 +
arch/x86/mm/pgta
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm64/include/asm/tlb.h | 10 --
1 file changed, 4 insertions(+), 6 dele
have swap cache, so use pagetable_free() instead of
free_page_and_swap_cache() to free page table pages.
By the way, move the comment above __tlb_remove_table() to
riscv_tlb_remove_ptdesc(), it will be more appropriate.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: lin
Like PMD and PTE level page table, also add statistics for PUD and P4D
page table.
Signed-off-by: Qi Zheng
Suggested-by: Peter Zijlstra (Intel)
Cc: linux-s...@vger.kernel.org
---
arch/s390/include/asm/pgalloc.h | 29 +++---
arch/s390/include/asm/tlb.h | 37
Like other levels of page tables, also use mmu gather mechanism to free
p4d level page table.
Signed-off-by: Qi Zheng
Originally-by: Peter Zijlstra (Intel)
Cc: linux-arm-ker...@lists.infradead.org
---
arch/arm64/include/asm/pgalloc.h | 1 -
arch/arm64/include/asm/tlb.h | 14
generic version, so we remove it altogether.
This is consistent with the way arm64 and x86 handle this situation
(runtime check in p4d_free() only).
Signed-off-by: Kevin Brodsky
Acked-by: Dave Hansen
Signed-off-by: Qi Zheng
---
arch/riscv/include/asm/pgalloc.h | 22 --
1 file
This reverts commit 2f3443770437e49abc39af26962d293851cbab6d.
Signed-off-by: Qi Zheng
---
include/linux/mm.h | 2 +-
include/linux/mm_types.h | 9 +
mm/memory.c | 22 ++
3 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/include
lloc_one
asm-generic: pgalloc: Provide generic p4d_{alloc_one,free}
Qi Zheng (15):
Revert "mm: pgtable: make ptlock be freed by RCU"
mm: pgtable: add statistics for P4D level page table
arm64: pgtable: use mmu gather to free p4d level page table
s390: pgtable: add statist
On 2024/12/20 22:28, Kevin Brodsky wrote:
On 20/12/2024 15:16, Qi Zheng wrote:
Did I miss something?
My patch series is not only for cleanup, but also for fixes of
UAF issue [1], so is it possible to rebase your patch series onto
mine? I can post v3 ASAP.
I see, yours should be merged
On 2024/12/20 21:50, Kevin Brodsky wrote:
On 20/12/2024 12:46, Qi Zheng wrote:
Hi Kevin,
On 2024/12/20 18:49, Kevin Brodsky wrote:
[...]
Qi, shall we collaborate to make our series complementary? I believe my
series covers patch 2 and 4 of your series, but it goes further by
covering all
Hi Kevin,
On 2024/12/20 18:49, Kevin Brodsky wrote:
Hi Peter, Qi,
On 19/12/2024 18:19, Peter Zijlstra wrote:
On Thu, Dec 19, 2024 at 04:44:16PM +, Kevin Brodsky wrote:
Besides the ptlock management at PTE/PMD level, all the
pagetable_*_[cd]tor have the same implementation. Introduce commo
98 matches
Mail list logo