Re: [PATCH v2 6/6] mm: pgtable: remove tlb_remove_page_ptdesc()

2025-02-26 Thread Kevin Brodsky
rs and should not be used for page table pages. > > Signed-off-by: Qi Zheng > Suggested-by: Peter Zijlstra (Intel) Reviewed-by: Kevin Brodsky

Re: [PATCH v2 3/6] mm: pgtable: convert some architectures to use tlb_remove_ptdesc()

2025-02-26 Thread Kevin Brodsky
le pages. > > Signed-off-by: Qi Zheng > Suggested-by: Peter Zijlstra (Intel) Reviewed-by: Kevin Brodsky

Re: [PATCH v2 1/6] mm: pgtable: make generic tlb_remove_table() use struct ptdesc

2025-02-26 Thread Kevin Brodsky
able() use struct ptdesc by default when > CONFIG_MMU_GATHER_TABLE_FREE is disabled. > > Signed-off-by: Qi Zheng Reviewed-by: Kevin Brodsky

Re: [PATCH v2 2/6] mm: pgtable: change pt parameter of tlb_remove_ptdesc() to struct ptdesc *

2025-02-26 Thread Kevin Brodsky
a (Intel) Reviewed-by: Kevin Brodsky

Re: [PATCH v5 11/17] x86: pgtable: convert __tlb_remove_table() to use struct ptdesc

2025-01-08 Thread Kevin Brodsky
ree page table pages. > > Signed-off-by: Qi Zheng Definitely a good idea to have split patch 11 from v4. Reviewed-by: Kevin Brodsky - Kevin

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Kevin Brodsky
On 07/01/2025 13:31, Qi Zheng wrote: > 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: c

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Kevin Brodsky
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 > following two >     forms: > >    

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Kevin Brodsky
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 >> Peter suggested on v3 [2]. > > Si

Re: [PATCH v4 07/15] mm: pgtable: introduce pagetable_dtor()

2025-01-07 Thread Kevin Brodsky
On 06/01/2025 14:23, Qi Zheng wrote: > 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_f

Re: [PATCH v2 0/6] Account page tables at all levels

2025-01-07 Thread Kevin Brodsky
On 06/01/2025 09:38, Qi Zheng wrote: > For this series: > > Acked-by: Qi Zheng Thank you for the review, appreciated! - Kevin

[PATCH v2 4/6] ARM: mm: Rename PGD helpers

2025-01-03 Thread Kevin Brodsky
ansen Signed-off-by: Kevin Brodsky --- arch/arm/mm/pgd.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c index f8e9bc58a84f..2a1077747758 100644 --- a/arch/arm/mm/pgd.c +++ b/arch/arm/mm/pgd.c @@ -17,11 +17,11 @@ #include

[PATCH v2 6/6] mm: Introduce ctor/dtor at PGD level

2025-01-03 Thread Kevin Brodsky
page table pages. This patch should cover all architectures and all configurations where PGDs are one or more regular pages. This excludes any configuration where PGDs are allocated from a kmem_cache object. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- arch/m68k/include/asm/mcf_pgalloc.

[PATCH v2 5/6] asm-generic: pgalloc: Provide generic __pgd_{alloc,free}

2025-01-03 Thread Kevin Brodsky
s by using GFP_PGTABLE_{USER,KERNEL} as appropriate. Not all PGD allocations can be handled by the generic helpers. In particular, multiple architectures allocate PGDs from a kmem_cache, and those PGDs may not be page-sized. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- arch/alpha

[PATCH v2 3/6] m68k: mm: Add calls to pagetable_pmd_[cd]tor

2025-01-03 Thread Kevin Brodsky
ating ptable_list for PMD/PGD levels. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- arch/m68k/include/asm/motorola_pgalloc.h | 6 +++--- arch/m68k/mm/motorola.c | 17 - 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/m68k/includ

[PATCH v2 2/6] parisc: mm: Ensure pagetable_pmd_[cd]tor are called

2025-01-03 Thread Kevin Brodsky
) can handle higher allocation orders so we don't need to define our own. These changes ensure that pagetable_pmd_[cd]tor are called, improving the accounting of page table pages. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- arch/parisc/include/asm/pgalloc.h | 23

[PATCH v2 1/6] mm: Move common part of pagetable_*_ctor to helper

2025-01-03 Thread Kevin Brodsky
pagetable_*_ctor all have the same basic implementation. Move the common part to a helper to reduce duplication. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- include/linux/mm.h | 28 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/include

[PATCH v2 0/6] Account page tables at all levels

2025-01-03 Thread Kevin Brodsky
nps-...@lists.infradead.org Cc: linux-um@lists.infradead.org Cc: loonga...@lists.linux.dev Cc: x...@kernel.org --- Kevin Brodsky (6): mm: Move common part of pagetable_*_ctor to helper parisc: mm: Ensure pagetable_pmd_[cd]tor are called m68k: mm: Add calls to pagetable_pmd_[cd]tor ARM: mm: Rename PGD

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-03 Thread Kevin Brodsky
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 PageT

Re: [PATCH 05/10] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one

2025-01-03 Thread Kevin Brodsky
+Qi On 03/01/2025 11:31, Alexandre Ghiti wrote: > Hi Kevin, > > On 19/12/2024 17:44, Kevin Brodsky wrote: >> {pmd,pud,p4d}_alloc_one() is never called if the corresponding page >> table level is folded, as {pmd,pud,p4d}_alloc() already does the >> required check.

Re: [PATCH 00/10] Account page tables at all levels

2025-01-03 Thread Kevin Brodsky
On 20/12/2024 20:31, Dave Hansen wrote: > On 12/20/24 02:58, Kevin Brodsky wrote: >>> One super tiny nit is that the PAE pgd _can_ be allocated using >>> __get_free_pages(). It was originally there for Xen, but I think it's >>> being used for PTI only at this p

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-03 Thread Kevin Brodsky
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) >>>   { >>&g

Re: [PATCH v4 04/15] mm: pgtable: add statistics for P4D level page table

2025-01-02 Thread Kevin Brodsky
On 03/01/2025 04:53, Qi Zheng wrote: > On 2025/1/3 00:53, Kevin Brodsky wrote: >> On 30/12/2024 10:07, Qi Zheng wrote: >>> diff --git a/arch/riscv/include/asm/pgalloc.h >>> b/arch/riscv/include/asm/pgalloc.h >>> index 551d614d3369c..3466fbe2e508d 100644 >&g

Re: [PATCH v4 00/15] move pagetable_*_dtor() to __tlb_remove_table()

2025-01-02 Thread Kevin Brodsky
ic pagetable_dtor_free() Aside from the nit on patch 4 and the request for clarification on patch 10, this is looking good to me, so for the whole series (aside from my own patches of course): Reviewed-by: Kevin Brodsky And happy new year! Cheers, - Kevin

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-02 Thread Kevin Brodsky
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); > - else > + } else { > + paget

Re: [PATCH v4 04/15] mm: pgtable: add statistics for P4D level page table

2025-01-02 Thread Kevin Brodsky
On 30/12/2024 10:07, Qi Zheng wrote: > diff --git a/arch/riscv/include/asm/pgalloc.h > b/arch/riscv/include/asm/pgalloc.h > index 551d614d3369c..3466fbe2e508d 100644 > --- a/arch/riscv/include/asm/pgalloc.h > +++ b/arch/riscv/include/asm/pgalloc.h > @@ -108,8 +108,12 @@ static inline void __pud_fr

Re: [PATCH 01/10] mm: Move common parts of pagetable_*_[cd]tor to helpers

2024-12-20 Thread Kevin Brodsky
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 first then. The issue is

Re: [PATCH 01/10] mm: Move common parts of pagetable_*_[cd]tor to helpers

2024-12-20 Thread Kevin Brodsky
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 >> co

Re: [PATCH 00/10] Account page tables at all levels

2024-12-20 Thread Kevin Brodsky
On 19/12/2024 18:13, Dave Hansen wrote: > On 12/19/24 08:44, Kevin Brodsky wrote: >> >> +---+-+---+--++ >> | x86 | Y | Y

Re: [PATCH 01/10] mm: Move common parts of pagetable_*_[cd]tor to helpers

2024-12-20 Thread Kevin Brodsky
Hi Peter, Qi, On 19/12/2024 18:19, Peter Zijlstra wrote: > On Thu, Dec 19, 2024 at 04:44:16PM +0000, Kevin Brodsky wrote: >> Besides the ptlock management at PTE/PMD level, all the >> pagetable_*_[cd]tor have the same implementation. Introduce common >> helpers for all

[PATCH 10/10] mm: Introduce ctor/dtor at PGD level

2024-12-19 Thread Kevin Brodsky
page table pages. This patch should cover all architectures and all configurations where PGDs are one or more regular pages. This excludes any configuration where PGDs are allocated from a kmem_cache object. Signed-off-by: Kevin Brodsky --- arch/m68k/include/asm/mcf_pgalloc.h | 2 ++ arch/m6

[PATCH 02/10] parisc: mm: Ensure pagetable_pmd_[cd]tor are called

2024-12-19 Thread Kevin Brodsky
) can handle higher allocation orders so we don't need to define our own. These changes ensure that pagetable_pmd_[cd]tor are called, improving the accounting of page table pages. Signed-off-by: Kevin Brodsky --- arch/parisc/include/asm/pgalloc.h | 23 --- 1 file c

[PATCH 04/10] s390/mm: Add calls to pagetable_pud_[cd]tor

2024-12-19 Thread Kevin Brodsky
o the ctor/dtor helpers in pud_alloc_one/pud_free to match the other architectures. Signed-off-by: Kevin Brodsky --- arch/s390/include/asm/pgalloc.h | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h ind

[PATCH 09/10] asm-generic: pgalloc: Provide generic __pgd_{alloc,free}

2024-12-19 Thread Kevin Brodsky
PGD pages by using GFP_PGTABLE_{USER,KERNEL} as appropriate. Not all PGD allocations can be handled by the generic helpers. In particular, multiple architectures allocate PGDs from a kmem_cache, and those PGDs may not be page-sized. Signed-off-by: Kevin Brodsky --- arch/alpha

[PATCH 08/10] ARM: mm: Rename PGD helpers

2024-12-19 Thread Kevin Brodsky
Generic implementations of __pgd_alloc and __pgd_free are about to be introduced. Rename the macros in arch/arm/mm/pgd.c to avoid clashes. While we're at it, also pass down the mm as argument to those helpers, as it will be needed to call the generic __pgd_{alloc,free}. Signed-off-by:

[PATCH 07/10] mm: Introduce ctor/dtor at P4D level

2024-12-19 Thread Kevin Brodsky
alloc/free paths. Besides the small improvement in accounting accuracy, this also enables adding construction/destruction hooks in just one generic place for page tables at P4D level (like lower levels). Signed-off-by: Kevin Brodsky --- arch/riscv/include/asm/pgalloc.h | 8 ++-- arch/s390/i

[PATCH 06/10] asm-generic: pgalloc: Provide generic p4d_{alloc_one,free}

2024-12-19 Thread Kevin Brodsky
ht 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 --- arch/arm64/include/asm/pgalloc.h | 17 arch/riscv/include/asm/pgalloc.h

[PATCH 05/10] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one

2024-12-19 Thread Kevin Brodsky
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 --- arch/riscv/include/asm/pgalloc.h | 22 -- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/arch/riscv

[PATCH 03/10] m68k: mm: Add calls to pagetable_pmd_[cd]tor

2024-12-19 Thread Kevin Brodsky
ating ptable_list for PMD/PGD levels. Signed-off-by: Kevin Brodsky --- arch/m68k/include/asm/motorola_pgalloc.h | 6 +++--- arch/m68k/mm/motorola.c | 25 +++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/arch/m68k/include/asm/motorola_pgal

[PATCH 01/10] mm: Move common parts of pagetable_*_[cd]tor to helpers

2024-12-19 Thread Kevin Brodsky
Besides the ptlock management at PTE/PMD level, all the pagetable_*_[cd]tor have the same implementation. Introduce common helpers for all levels to reduce the duplication. Signed-off-by: Kevin Brodsky --- include/linux/mm.h | 46 ++ 1 file changed

[PATCH 00/10] Account page tables at all levels

2024-12-19 Thread Kevin Brodsky
nel.org Cc: linux-ri...@lists.infradead.org Cc: linux-s...@vger.kernel.org Cc: linux-snps-...@lists.infradead.org Cc: linux-um@lists.infradead.org Cc: loonga...@lists.linux.dev Cc: x...@kernel.org --- Kevin Brodsky (10): mm: Move common parts of pagetable_*_[cd]tor to helpers parisc: