Re: [PATCH 5/7] powerpc/mm: support nested lazy_mmu sections

2025-09-20 Thread Kevin Brodsky
On 05/09/2025 17:52, Alexander Gordeev wrote: > On Thu, Sep 04, 2025 at 01:57:34PM +0100, Kevin Brodsky wrote: > ... >> static inline lazy_mmu_state_t arch_enter_lazy_mmu_mode(void) >> { >> struct ppc64_tlb_batch *batch; >> +int lazy_mmu_nested;

Re: [PATCH 4/7] x86/xen: support nested lazy_mmu sections (again)

2025-09-20 Thread Kevin Brodsky
On 05/09/2025 17:48, Alexander Gordeev wrote: > On Thu, Sep 04, 2025 at 01:57:33PM +0100, Kevin Brodsky wrote: > ... >> -static void xen_enter_lazy_mmu(void) >> +static lazy_mmu_state_t xen_enter_lazy_mmu(void) >> { >> +if (this_cpu_read(xen_lazy_mode) == XEN_LA

Re: [PATCH v2 0/7] Nesting support for lazy MMU mode

2025-09-20 Thread Kevin Brodsky
On 08/09/2025 18:56, Lorenzo Stoakes wrote: > On Mon, Sep 08, 2025 at 08:39:24AM +0100, Kevin Brodsky wrote: >> When the lazy MMU mode was introduced eons ago, it wasn't made clear >> whether such a sequence was legal: >> >&g

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-20 Thread Kevin Brodsky
On 09/09/2025 15:49, Kevin Brodsky wrote: > On 09/09/2025 13:54, David Hildenbrand wrote: >> On 09.09.25 13:45, Alexander Gordeev wrote: >>> On Tue, Sep 09, 2025 at 12:09:48PM +0200, David Hildenbrand wrote: >>>> On 09.09.25 11:40, Alexander Gordeev wrote: >>&g

[PATCH v2 0/7] Nesting support for lazy MMU mode

2025-09-18 Thread Kevin Brodsky
olas Piggin Cc: Peter Zijlstra Cc: Ryan Roberts Cc: Suren Baghdasaryan Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: Will Deacon Cc: Yeoreum Yun Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org Cc: linuxppc-...@lists.ozlabs.org Cc: sparcli...@vger.kernel.org Cc: xen-de

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-17 Thread Kevin Brodsky
+Mark Rutland On 09/09/2025 16:28, David Hildenbrand wrote: >>> Can't we just use an "enum lazy_mmu_state" and call it a day? >> >> I could envision something completely different for this type on >> s390, >> e.g. a pointer to a per-cpu structure. So I would really ask to >

Re: [PATCH v2 0/7] Nesting support for lazy MMU mode

2025-09-15 Thread Kevin Brodsky
On 15/09/2025 08:28, Alexander Gordeev wrote: > On Fri, Sep 12, 2025 at 05:25:27PM +0200, Kevin Brodsky wrote: > > Hi Kevin, > >> Based on the outcome of the discussion with David on patch 2 [1p], there >> is indeed an alternative approach that we should seriously

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-13 Thread Kevin Brodsky
On 09/09/2025 16:38, Alexander Gordeev wrote: > Would that integrate well with LAZY_MMU_DEFAULT etc? Hmm... I though the idea is to use LAZY_MMU_* by architectures that want to use it - at least that is how I read the description above. It is only kasan_populate|depopulate_v

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-13 Thread Kevin Brodsky
On 12/09/2025 16:25, David Hildenbrand wrote: > >> >> But I do not really expect it ever, since arch_enter_lazy_mmu_mode_pte() >> is only to be called in PTE walkers that never span more than one page >> table and follow the pattern: > > Well, the cover letter here states: > > "Unfortunately, a cor

Re: [PATCH v2 0/7] Nesting support for lazy MMU mode

2025-09-12 Thread Kevin Brodsky
On 09/09/2025 11:21, David Hildenbrand wrote: > On 09.09.25 04:16, Andrew Morton wrote: >> On Mon,  8 Sep 2025 08:39:24 +0100 Kevin Brodsky >> wrote: >> >>> The main change enabling nesting is patch 2, following the approach >>> suggested by Catalin Marinas

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-12 Thread Kevin Brodsky
On 12/09/2025 10:04, David Hildenbrand wrote: >>> >>> struct lazy_mmu_state { >>>  uint8_t enabled_count; >>>  bool paused; >> >> Looking at the arm64 implementation, I'm thinking: instead of the paused >> member, how about a PF_LAZY_MMU task flag? It would be set when lazy_mmu >> is actual

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-12 Thread Kevin Brodsky
On 11/09/2025 20:14, David Hildenbrand wrote: On the other hand, with a pagefault_disabled-like approach, there is no way to instruct call {3} to fully exit lazy_mmu regardless of the nesting level. >>> >>> Sure there is, with a better API. See below. :) >> >> I meant while keep

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-11 Thread Kevin Brodsky
On 10/09/2025 17:37, David Hildenbrand wrote: >> >> Somewhat, but in the regular case where enter() is called followed by >> leave() there is really no complexity for the caller, just an extra >> local variable. >> >> There are complications where we want to exit lazy_mmu temporarily, as >> in mm/k

[PATCH v2 5/7] powerpc/mm: support nested lazy_mmu sections

2025-09-11 Thread Kevin Brodsky
is occurring or not. Signed-off-by: Kevin Brodsky --- arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h in

Re: [PATCH v2 0/7] Nesting support for lazy MMU mode

2025-09-11 Thread Kevin Brodsky
On 09/09/2025 11:21, David Hildenbrand wrote: > On 09.09.25 04:16, Andrew Morton wrote: >> On Mon,  8 Sep 2025 08:39:24 +0100 Kevin Brodsky >> wrote: >> >>> The main change enabling nesting is patch 2, following the approach >>> suggested by Catalin Marinas

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-11 Thread Kevin Brodsky
On 11/09/2025 14:06, Alexander Gordeev wrote: > On Wed, Sep 10, 2025 at 06:11:54PM +0200, Kevin Brodsky wrote: > > Hi Kevin, > >> On 09/09/2025 16:38, Alexander Gordeev wrote: >>>>>>> Would that integrate well with LAZY_MMU_DEFAULT etc? >>>>

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-09 Thread Kevin Brodsky
On 09/09/2025 12:57, Juergen Gross wrote: > On 09.09.25 11:07, David Hildenbrand wrote: >> On 08.09.25 09:39, Kevin Brodsky wrote: >>> [...] >>> >>> Note: it is difficult to provide a default definition of >>> lazy_mmu_state_t for architectures imple

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-09 Thread Kevin Brodsky
id Hildenbrand wrote: >>>>> On 08.09.25 09:39, Kevin Brodsky wrote: >>>>>> arch_{enter,leave}_lazy_mmu_mode() currently have a stateless API >>>>>> (taking and returning no value). This is proving problematic in >>>>>> situations where

Re: [PATCH v2 4/7] x86/xen: support nested lazy_mmu sections (again)

2025-09-09 Thread Kevin Brodsky
On 09/09/2025 11:56, David Hildenbrand wrote: > On 09.09.25 11:37, Jürgen Groß wrote: >> On 09.09.25 11:13, David Hildenbrand wrote: >>> On 08.09.25 09:39, Kevin Brodsky wrote: >>>> Commit 49147beb0ccb ("x86/xen: allow nesting of same lazy mode") >>&g

Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-09 Thread Kevin Brodsky
On 09/09/2025 07:40, Andrew Morton wrote: > On Mon, 8 Sep 2025 08:39:26 +0100 Kevin Brodsky > wrote: > >> arch_{enter,leave}_lazy_mmu_mode() currently have a stateless API >> (taking and returning no value). This is proving problematic in >> situations where le

[PATCH v2 7/7] mm: update lazy_mmu documentation

2025-09-08 Thread Kevin Brodsky
We now support nested lazy_mmu sections on all architectures implementing the API. Update the API comment accordingly. Acked-by: Mike Rapoport (Microsoft) Signed-off-by: Kevin Brodsky --- include/linux/pgtable.h | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git

[PATCH v2 1/7] mm: remove arch_flush_lazy_mmu_mode()

2025-09-08 Thread Kevin Brodsky
there. Acked-by: Mike Rapoport (Microsoft) Signed-off-by: Kevin Brodsky --- arch/arm64/include/asm/pgtable.h | 9 + arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 2 -- arch/sparc/include/asm/tlbflush_64.h | 1 - arch/x86/include/asm/pgtable.h

[PATCH v2 6/7] sparc/mm: support nested lazy_mmu sections

2025-09-08 Thread Kevin Brodsky
is occurring or not. Signed-off-by: Kevin Brodsky --- arch/sparc/mm/tlb.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index bf5094b770af..fdc33438b85f 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -5

[PATCH v2 3/7] arm64: mm: fully support nested lazy_mmu sections

2025-09-08 Thread Kevin Brodsky
until the outermost lazy_mmu section ends. leave() still emits barriers if needed, regardless of the nesting level, as the caller may expect any page table changes to become visible when leave() returns. Signed-off-by: Kevin Brodsky --- arch/arm64/include/asm/pgtable.h | 19 +

[PATCH v2 4/7] x86/xen: support nested lazy_mmu sections (again)

2025-09-08 Thread Kevin Brodsky
_NESTED to instruct the matching xen_leave_lazy_mmu() call to leave xen_lazy_mode unchanged. The only effect of this patch is to ensure that xen_lazy_mode remains set to XEN_LAZY_MMU until the outermost lazy_mmu section ends. xen_leave_lazy_mmu() still calls xen_mc_flush() unconditionally. Signed-off

[PATCH v2 2/7] mm: introduce local state for lazy_mmu sections

2025-09-08 Thread Kevin Brodsky
on of lazy_mmu_state_t for architectures implementing lazy_mmu, because that definition would need to be available in arch/x86/include/asm/paravirt_types.h and adding a new generic #include there is very tricky due to the existing header soup. Acked-by: Mike Rapoport (Microsoft) Signed-off-by: Kevin Br

Re: [PATCH 2/7] mm: introduce local state for lazy_mmu sections

2025-09-07 Thread Kevin Brodsky
On 05/09/2025 13:37, Lorenzo Stoakes wrote: > On Fri, Sep 05, 2025 at 12:21:40PM +0100, Lorenzo Stoakes wrote: >> You should really base on mm-new. >> >> You need to account for everything that is potentially going to go >> upstream. mm-stable is generally not actually populated all too well until

[PATCH 6/7] sparc/mm: support nested lazy_mmu sections

2025-09-06 Thread Kevin Brodsky
is occurring or not. Signed-off-by: Kevin Brodsky --- arch/sparc/mm/tlb.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index bf5094b770af..42de93d74d0e 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -53

[PATCH 5/7] powerpc/mm: support nested lazy_mmu sections

2025-09-06 Thread Kevin Brodsky
is occurring or not. Signed-off-by: Kevin Brodsky --- .../powerpc/include/asm/book3s/64/tlbflush-hash.h | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h in

[PATCH 4/7] x86/xen: support nested lazy_mmu sections (again)

2025-09-06 Thread Kevin Brodsky
_NESTED to instruct the matching xen_leave_lazy_mmu() call to leave xen_lazy_mode unchanged. The only effect of this patch is to ensure that xen_lazy_mode remains set to XEN_LAZY_MMU until the outermost lazy_mmu section ends. xen_leave_lazy_mmu() still calls xen_mc_flush() unconditionally. Signed-off

Re: [PATCH 0/7] Nesting support for lazy MMU mode

2025-09-05 Thread Kevin Brodsky
On 05/09/2025 11:46, Alexander Gordeev wrote: > On Thu, Sep 04, 2025 at 01:57:29PM +0100, Kevin Brodsky wrote: > > Hi Kevin, > >> When the lazy MMU mode was introduced eons ago, it wasn't made clear >> whether such a sequence was legal: >&g

Re: [PATCH 2/7] mm: introduce local state for lazy_mmu sections

2025-09-04 Thread Kevin Brodsky
On 04/09/2025 19:28, Lorenzo Stoakes wrote: > Hi Kevin, > > This is causing a build failure: > > In file included from ./include/linux/mm.h:31, > from mm/userfaultfd.c:8: > mm/userfaultfd.c: In function ‘move_present_ptes’: > ./include/linux/pgtable.h:247:41: error: statement with

Re: [PATCH 2/7] mm: introduce local state for lazy_mmu sections

2025-09-04 Thread Kevin Brodsky
On 04/09/2025 17:06, Yeoreum Yun wrote: > Hi Kevin, > > [...] >> Signed-off-by: Kevin Brodsky >> --- >> arch/arm64/include/asm/pgtable.h | 10 +++--- >> .../include/asm/book3s/64/tlbflush-hash.h | 9 ++--- >> arch/powerp

[PATCH 0/7] Nesting support for lazy MMU mode

2025-09-04 Thread Kevin Brodsky
Cc: Vlastimil Babka Cc: Will Deacon Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org Cc: linuxppc-...@lists.ozlabs.org Cc: sparcli...@vger.kernel.org Cc: xen-devel@lists.xenproject.org --- Kevin Brodsky (7): mm: remove arch_flush_lazy_mmu_mode() mm: introduce local state

[PATCH 2/7] mm: introduce local state for lazy_mmu sections

2025-09-04 Thread Kevin Brodsky
o the existing header soup. Signed-off-by: Kevin Brodsky --- arch/arm64/include/asm/pgtable.h | 10 +++--- .../include/asm/book3s/64/tlbflush-hash.h | 9 ++--- arch/powerpc/mm/book3s64/hash_tlb.c | 10 ++ arch/powerpc/mm/book3s64/subpage_prot.c

[PATCH 3/7] arm64: mm: fully support nested lazy_mmu sections

2025-09-04 Thread Kevin Brodsky
until the outermost lazy_mmu section ends. leave() still emits barriers if needed, regardless of the nesting level, as the caller may expect any page table changes to become visible when leave() returns. Signed-off-by: Kevin Brodsky --- arch/arm64/include/asm/pgtable.h | 19 +

[PATCH 7/7] mm: update lazy_mmu documentation

2025-09-04 Thread Kevin Brodsky
We now support nested lazy_mmu sections on all architectures implementing the API. Update the API comment accordingly. Signed-off-by: Kevin Brodsky --- include/linux/pgtable.h | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/pgtable.h b/include

[PATCH 1/7] mm: remove arch_flush_lazy_mmu_mode()

2025-09-04 Thread Kevin Brodsky
there. Signed-off-by: Kevin Brodsky --- arch/arm64/include/asm/pgtable.h | 9 + arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 2 -- arch/sparc/include/asm/tlbflush_64.h | 1 - arch/x86/include/asm/pgtable.h | 3 ++- include/linux