Re: [PATCH v7] mm/memblock: Add memblock_alloc_or_panic interface

2025-01-07 Thread Alexander Gordeev
On Sun, Dec 22, 2024 at 07:15:37PM +0800, Guo Weikang wrote: Hi Guo, > Before SLUB initialization, various subsystems used memblock_alloc to > allocate memory. In most cases, when memory allocation fails, an immediate > panic is required. To simplify this behavior and reduce repetitive checks, >

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] powerpc: Transliterate author name and remove FIXME

2025-01-07 Thread Thorsten Blum
On 23. Nov 2024, at 11:19, Christophe Leroy wrote: > Isn't our file just a copy of the one from binutils ? Shouldn't we adjust it > based on commit https://github.com/bminor/binutils-gdb/commit/2ce18a16268a ? It looks like it's a copy and the name is spelled the same as in my patch: "Mimi Phuo

[PATCH v3 3/6] powwerpc: Use note name macros

2025-01-07 Thread Akihiko Odaki
Use note name macros to match with the userspace's expectation. Acked-by: Baoquan He Signed-off-by: Akihiko Odaki --- arch/powerpc/kernel/fadump.c | 2 +- arch/powerpc/platforms/powernv/opal-core.c | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/p

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: completely move pagetable_dtor() to generic >>> tlb_remove_table() >>> >>>

Re: [PATCH v4 13/15] mm: pgtable: introduce generic __tlb_remove_table()

2025-01-07 Thread Alexander Gordeev
On Mon, Dec 30, 2024 at 05:07:48PM +0800, Qi Zheng wrote: > 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

Re: [PATCH v3 5/6] s390/crash: Use note name macros

2025-01-07 Thread Dave Martin
Hi, On Tue, Jan 07, 2025 at 09:45:56PM +0900, Akihiko Odaki wrote: > Use note name macros to match with the userspace's expectation. > > Signed-off-by: Akihiko Odaki > --- > arch/s390/kernel/crash_dump.c | 62 > --- > 1 file changed, 23 insertions(+), 39

Re: [PATCH v3 2/6] binfmt_elf: Use note name macros

2025-01-07 Thread Dave Martin
On Tue, Jan 07, 2025 at 09:45:53PM +0900, Akihiko Odaki wrote: > Use note name macros to match with the userspace's expectation. Also (and more importantly) get rid of duplicated knowledge about the mapping of note types to note names, so that elf.h is the authoritative source of this information?

Re: [PATCH 06/14] cpumask: re-introduce cpumask_next{,_and}_wrap()

2025-01-07 Thread Alexander Gordeev
On Sat, Dec 28, 2024 at 10:49:38AM -0800, Yury Norov wrote: Hi Yury, > cpumask_next_wrap_old() has two additional parameters, comparing to it's > analogue in linux/find.h find_next_bit_wrap(). The reason for that is > historical. > > Before 4fe49b3b97c262 ("lib/bitmap: introduce for_each_set_bit

Re: [PATCH] libperf: Add back guard on MAX_NR_CPUS

2025-01-07 Thread Ian Rogers
On Tue, Jan 7, 2025 at 12:50 AM Christophe Leroy wrote: > > Le 06/01/2025 à 21:05, Ian Rogers a écrit : > > On Mon, Jan 6, 2025 at 11:38 AM Christophe Leroy > > wrote: > >> > >> Building perf with EXTRA_CFLAGS="-DMAX_NR_CPUS=1" fails: > >> > >>CC /home/chleroy/linux-powerpc/tools

Re: [PATCH v4 15/15] mm: pgtable: introduce generic pagetable_dtor_free()

2025-01-07 Thread Alexander Gordeev
On Mon, Dec 30, 2024 at 05:07:50PM +0800, Qi Zheng wrote: > The pte_free(), pmd_free(), __pud_free() and __p4d_free() in > asm-generic/pgalloc.h and the generic __tlb_remove_table() are basically > the same, so let's introduce pagetable_dtor_free() to deduplicate them. > > In addition, the pagetab

Re: [PATCH v3 3/6] powwerpc: Use note name macros

2025-01-07 Thread LEROY Christophe
Le 07/01/2025 à 13:45, Akihiko Odaki a écrit : > Use note name macros to match with the userspace's expectation. In the subject: s/powwerpc/powerpc Christophe > > Acked-by: Baoquan He > Signed-off-by: Akihiko Odaki > --- > arch/powerpc/kernel/fadump.c | 2 +- > arch/powerp

Re: [PATCH 03/14] ibmvnic: simplify ibmvnic_set_queue_affinity()

2025-01-07 Thread Nick Child
On Sat, Dec 28, 2024 at 10:49:35AM -0800, Yury Norov wrote: > A loop based on cpumask_next_wrap() opencodes the dedicated macro > for_each_online_cpu_wrap(). Using the macro allows to avoid setting > bits affinity mask more than once when stride >= num_online_cpus. > > This also helps to drop cpum

Re: [PATCH 03/14] ibmvnic: simplify ibmvnic_set_queue_affinity()

2025-01-07 Thread Yury Norov
On Tue, Jan 07, 2025 at 04:37:17PM -0600, Nick Child wrote: > On Sat, Dec 28, 2024 at 10:49:35AM -0800, Yury Norov wrote: > > A loop based on cpumask_next_wrap() opencodes the dedicated macro > > for_each_online_cpu_wrap(). Using the macro allows to avoid setting > > bits affinity mask more than on

Re: [PATCH 01/19] powerpc: Generalize MPC831x platform support

2025-01-07 Thread J . Neuschäfer
On Mon, Jan 06, 2025 at 02:50:31PM +0100, Christophe Leroy wrote: > > > Le 02/01/2025 à 19:31, J. Neuschäfer via B4 Relay a écrit : > > [Vous ne recevez pas souvent de courriers de > > devnull+j.ne.posteo@kernel.org. Découvrez pourquoi ceci est important à > > https://aka.ms/LearnAboutSende

Re: [PATCH 08/19] powerpc: boot: Enable FIT image generation

2025-01-07 Thread J . Neuschäfer
On Mon, Jan 06, 2025 at 02:52:59PM +0100, Christophe Leroy wrote: > > > Le 02/01/2025 à 19:31, J. Neuschäfer via B4 Relay a écrit : > > [Vous ne recevez pas souvent de courriers de > > devnull+j.ne.posteo@kernel.org. Découvrez pourquoi ceci est important à > > https://aka.ms/LearnAboutSende

Re: [PATCH 03/14] ibmvnic: simplify ibmvnic_set_queue_affinity()

2025-01-07 Thread Yury Norov
On Tue, Jan 07, 2025 at 02:43:01PM -0800, Yury Norov wrote: > On Tue, Jan 07, 2025 at 04:37:17PM -0600, Nick Child wrote: > > On Sat, Dec 28, 2024 at 10:49:35AM -0800, Yury Norov wrote: > > > A loop based on cpumask_next_wrap() opencodes the dedicated macro > > > for_each_online_cpu_wrap(). Using t

[PATCH 3/6] syscall.h: introduce syscall_set_nr()

2025-01-07 Thread Dmitry V. Levin
Similar to syscall_set_arguments() that complements syscall_get_arguments(), introduce syscall_set_nr() that complements syscall_get_nr(). syscall_set_nr() is going to be needed along with syscall_set_arguments() on all HAVE_ARCH_TRACEHOOK architectures to implement PTRACE_SET_SYSCALL_INFO API. S

[PATCH 1/6] Revert "arch: remove unused function syscall_set_arguments()"

2025-01-07 Thread Dmitry V. Levin
syscall_set_arguments() is going to be needed to implement PTRACE_SET_SYSCALL_INFO API. This is a partial revert: on a few architectures syscall_set_arguments() implementations were buggy, so instead of adding them here and applying fixes on top, cleaner implementations are coming in follow-up com

Re: [PATCH 09/19] powerpc: boot: Build devicetrees when CONFIG_MPC831x=y

2025-01-07 Thread J . Neuschäfer
On Mon, Jan 06, 2025 at 02:55:22PM +0100, Christophe Leroy wrote: > Le 02/01/2025 à 19:31, J. Neuschäfer via B4 Relay a écrit : > > [Vous ne recevez pas souvent de courriers de > > devnull+j.ne.posteo@kernel.org. Découvrez pourquoi ceci est important à > > https://aka.ms/LearnAboutSenderIdent

[PATCH 0/6] ptrace: introduce PTRACE_SET_SYSCALL_INFO API

2025-01-07 Thread Dmitry V. Levin
PTRACE_SET_SYSCALL_INFO is a generic ptrace API that complements PTRACE_GET_SYSCALL_INFO by letting the ptracer modify details of system calls the tracee is blocked in. This API allows ptracers to obtain and modify system call details in a straightforward and architecture-agnostic way. Current im

Re: [PATCH v4 12/25] mm/memory: Enhance insert_page_into_pte_locked() to create writable mappings

2025-01-07 Thread David Hildenbrand
On 06.01.25 03:07, Alistair Popple wrote: On Fri, Dec 20, 2024 at 08:06:48PM +0100, David Hildenbrand wrote: On 20.12.24 20:01, David Hildenbrand wrote: On 17.12.24 06:12, Alistair Popple wrote: In preparation for using insert_page() for DAX, enhance insert_page_into_pte_locked() to handle est

Re: [PATCH v5 14/25] rmap: Add support for PUD sized mappings to rmap

2025-01-07 Thread David Hildenbrand
On 07.01.25 04:42, Alistair Popple wrote: The rmap doesn't currently support adding a PUD mapping of a folio. This patch adds support for entire PUD mappings of folios, primarily to allow for more standard refcounting of device DAX folios. Currently DAX is the only user of this and it doesn't req

Re: [PATCH] libperf: Add back guard on MAX_NR_CPUS

2025-01-07 Thread Christophe Leroy
Le 06/01/2025 à 21:05, Ian Rogers a écrit : On Mon, Jan 6, 2025 at 11:38 AM Christophe Leroy wrote: Building perf with EXTRA_CFLAGS="-DMAX_NR_CPUS=1" fails: CC /home/chleroy/linux-powerpc/tools/perf/libperf/cpumap.o cpumap.c:16: error: "MAX_NR_CPUS" redefined [-Wer

Re: Raptor Engineering dedicating resources to KVM on PowerNV + KVM CI/CD

2025-01-07 Thread Alex Williamson
On Mon, 6 Jan 2025 13:47:50 -0600 Shawn Anastasio wrote: > Hi all, > > Just wanted to check in and let the community know that Raptor > Engineering will be officially dedicating development resources towards > maintaining, developing, and testing the existing Linux KVM facilities > for PowerNV m

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

2025-01-07 Thread Qi Zheng
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 P

Re: [PATCH v2 01/28] module: Extend the preempt disabled section in dereference_symbol_descriptor().

2025-01-07 Thread Sergey Senozhatsky
On (24/12/20 18:41), Sebastian Andrzej Siewior wrote: > dereference_symbol_descriptor() needs to obtain the module pointer > belonging to pointer in order to resolve that pointer. > The returned mod pointer is obtained under RCU-sched/ preempt_disable() > guarantees and needs to be used within this

Re: [PATCH 1/2] powerpc/vpa_dtl: Add interface to expose vpa dtl counters via perf

2025-01-07 Thread Madhavan Srinivasan
On 12/16/24 12:45 PM, Kajol Jain wrote: > The pseries Shared Processor Logical Partition(SPLPAR) machines > can retrieve a log of dispatch and preempt events from the > hypervisor using data from Disptach Trace Log(DTL) buffer. > With this information, user can retrieve when and why each dispatc

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 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 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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 fol

Re: [PATCH v4 13/15] mm: pgtable: introduce generic __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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 @@

Re: [PATCH v4 13/15] mm: pgtable: introduce generic __tlb_remove_table()

2025-01-07 Thread Andreas Larsson
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 @@ > #ifndef _SPARC_TLB_H > #define _SPA

[PATCH v3 1/6] elf: Define note name macros

2025-01-07 Thread Akihiko Odaki
elf.h had a comment saying: > Notes used in ET_CORE. Architectures export some of the arch register > sets using the corresponding note types via the PTRACE_GETREGSET and > PTRACE_SETREGSET requests. > The note name for these types is "LINUX", except NT_PRFPREG that is > named "CORE". However, NT_

[PATCH v3 2/6] binfmt_elf: Use note name macros

2025-01-07 Thread Akihiko Odaki
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki Acked-by: Baoquan He --- fs/binfmt_elf.c | 21 ++--- fs/binfmt_elf_fdpic.c | 8 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binf

[PATCH v3 0/6] elf: Define note name macros

2025-01-07 Thread Akihiko Odaki
elf.h had a comment saying: > Notes used in ET_CORE. Architectures export some of the arch register > sets using the corresponding note types via the PTRACE_GETREGSET and > PTRACE_SETREGSET requests. > The note name for these types is "LINUX", except NT_PRFPREG that is > named "CORE". However, NT_

[PATCH v3 4/6] crash: Use note name macros

2025-01-07 Thread Akihiko Odaki
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki Acked-by: Baoquan He --- fs/proc/kcore.c | 12 ++-- include/linux/vmcore_info.h | 2 +- kernel/crash_core.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff -

[PATCH v3 6/6] crash: Remove KEXEC_CORE_NOTE_NAME

2025-01-07 Thread Akihiko Odaki
KEXEC_CORE_NOTE_NAME is no longer used. Signed-off-by: Akihiko Odaki Acked-by: Baoquan He --- include/linux/kexec.h | 2 -- include/linux/vmcore_info.h | 1 - 2 files changed, 3 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index f0e9f8eda7a3..c840431eadda 10064

[PATCH v3 5/6] s390/crash: Use note name macros

2025-01-07 Thread Akihiko Odaki
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki --- arch/s390/kernel/crash_dump.c | 62 --- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_

Re: [PATCH v5 00/25] fs/dax: Fix ZONE_DEVICE page reference counts

2025-01-07 Thread Andrew Morton
On Tue, 7 Jan 2025 14:42:16 +1100 Alistair Popple wrote: > Device and FS DAX pages have always maintained their own page > reference counts without following the normal rules for page reference > counting. In particular pages are considered free when the refcount > hits one rather than zero and

Re: [PATCH v5 15/25] huge_memory: Add vmf_insert_folio_pud()

2025-01-07 Thread kernel test robot
Hi Alistair, kernel test robot noticed the following build warnings: [auto build test WARNING on e25c8d66f6786300b680866c0e0139981273feba] url: https://github.com/intel-lab-lkp/linux/commits/Alistair-Popple/fuse-Fix-dax-truncate-punch_hole-fault-path/20250107-114726 base

Re: [PATCH v3 5/6] s390/crash: Use note name macros

2025-01-07 Thread Akihiko Odaki
On 2025/01/08 1:17, Dave Martin wrote: Hi, On Tue, Jan 07, 2025 at 09:45:56PM +0900, Akihiko Odaki wrote: Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki --- arch/s390/kernel/crash_dump.c | 62 --- 1 file

Re: [PATCH v3 2/6] binfmt_elf: Use note name macros

2025-01-07 Thread Akihiko Odaki
On 2025/01/08 1:18, Dave Martin wrote: On Tue, Jan 07, 2025 at 09:45:53PM +0900, Akihiko Odaki wrote: Use note name macros to match with the userspace's expectation. Also (and more importantly) get rid of duplicated knowledge about the mapping of note types to note names, so that elf.h is the

Re: [PATCH 01/19] powerpc: Generalize MPC831x platform support

2025-01-07 Thread Christophe Leroy
Le 07/01/2025 à 23:45, J. Neuschäfer a écrit : [Vous ne recevez pas souvent de courriers de j...@posteo.net. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] On Mon, Jan 06, 2025 at 02:50:31PM +0100, Christophe Leroy wrote: Le 02/01/2025 à 19:31, J.

[PATCH v5 00/17] move pagetable_*_dtor() to __tlb_remove_table()

2025-01-07 Thread Qi Zheng
Changes in v5: - cancel the move of p4d_free_tlb()'s location in [PATCH v4 06/15] (Alexander Gordeev) - fix the missing pagetable_dtor() in [PATCH v4 08/15] (Kevin Brodsky) - change the subject and description in [PATCH v4 12/15] (Alexander Gordeev) - remove the redundant __HAVE_ARCH_TLB_

[PATCH v5 01/17] Revert "mm: pgtable: make ptlock be freed by RCU"

2025-01-07 Thread Qi Zheng
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(-)

[PATCH v5 03/17] asm-generic: pgalloc: Provide generic p4d_{alloc_one,free}

2025-01-07 Thread Qi Zheng
From: Kevin Brodsky Four architectures currently implement 5-level pgtables: arm64, riscv, x86 and s390. The first three have essentially the same implementation for p4d_alloc_one() and p4d_free(), so we've got an opportunity to reduce duplication like at the lower levels. Provide a generic vers

[PATCH v5 04/17] mm: pgtable: add statistics for P4D level page table

2025-01-07 Thread Qi Zheng
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| 2

[PATCH v5 02/17] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one

2025-01-07 Thread Qi Zheng
From: Kevin Brodsky {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. We can therefore remove the runtime page table level checks in {pud,p4d}_alloc_one. The PUD helper becomes equivalent to the gen

[PATCH v5 07/17] mm: pgtable: introduce pagetable_dtor()

2025-01-07 Thread Qi Zheng
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() from pmd_ptlock_free(), we can unify pagetable_p*_dtor() into one function. Let's introduce pagetable_dtor() to do this. La

[PATCH v5 05/17] arm64: pgtable: use mmu gather to free p4d level page table

2025-01-07 Thread Qi Zheng
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/tl

[PATCH v5 06/17] s390: pgtable: add statistics for PUD and P4D level page table

2025-01-07 Thread Qi Zheng
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/as

[PATCH v5 08/17] arm: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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. Page tables shouldn't have s

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

2025-01-07 Thread Qi Zheng
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/include/as

[PATCH v5 10/17] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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. Page tables shouldn't have s

[PATCH v5 09/17] arm64: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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. Page tables shouldn't have s

[PATCH v5 12/17] x86: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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 Sug

[PATCH v5 14/17] mm: pgtable: introduce generic __tlb_remove_table()

2025-01-07 Thread Qi Zheng
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

[PATCH v5 15/17] mm: pgtable: completely move pagetable_dtor() to generic tlb_remove_table()

2025-01-07 Thread Qi Zheng
For the generic tlb_remove_table(), it is implemented in the following two forms: 1) CONFIG_MMU_GATHER_TABLE_FREE is enabled tlb_remove_table --> generic __tlb_remove_table() 2) CONFIG_MMU_GATHER_TABLE_FREE is disabled tlb_remove_table --> tlb_remove_page For case 1), the pagetable_dtor() has

[PATCH v5 13/17] s390: pgtable: consolidate PxD and PTE TLB free paths

2025-01-07 Thread Qi Zheng
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 ---

[PATCH v5 17/17] mm: pgtable: introduce generic pagetable_dtor_free()

2025-01-07 Thread Qi Zheng
The pte_free(), pmd_free(), __pud_free() and __p4d_free() in asm-generic/pgalloc.h and the generic __tlb_remove_table() are basically the same, so let's introduce pagetable_dtor_free() to deduplicate them. In addition, the pagetable_dtor_free() in s390 does the same thing, so let's s390 also calls

[PATCH v5 16/17] mm: pgtable: move __tlb_remove_table_one() in x86 to generic file

2025-01-07 Thread Qi Zheng
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,