Re: [PATCH 4/6] sparc/mm: Do not disable preemption in lazy MMU mode

2025-06-13 Thread Ryan Roberts
On 12/06/2025 18:36, Alexander Gordeev wrote: > Commit a1d416bf9faf ("sparc/mm: disable preemption in lazy mmu mode") > is not necessary anymore, since the lazy MMU mode is entered with a > spinlock held and sparc does not support Real-Time. Thus, upon entering > the lazy mode the preemption is alr

Re: [PATCH 2/6] mm: Lock kernel page tables before entering lazy MMU mode

2025-06-13 Thread Ryan Roberts
On 12/06/2025 18:36, Alexander Gordeev wrote: > As a follow-up to commit 691ee97e1a9d ("mm: fix lazy mmu docs and > usage") take a step forward and protect with a lock not only user, > but also kernel mappings before entering the lazy MMU mode. With > that the semantics of arch_enter|leave_lazy_mmu

Re: [RFC PATCH v1 0/6] Lazy mmu mode fixes and improvements

2025-06-02 Thread Ryan Roberts
On 31/05/2025 08:46, Mike Rapoport wrote: > Hi Ryan, > > On Fri, May 30, 2025 at 04:55:36PM +0100, Ryan Roberts wrote: >> On 30/05/2025 15:47, Lorenzo Stoakes wrote: >>> +cc Jann who is a specialist in all things page table-y and especially scary >>> edge cases :

[RFC PATCH v1 1/6] fs/proc/task_mmu: Fix pte update and tlb maintenance ordering in pagemap_scan_pmd_entry()

2025-05-30 Thread Ryan Roberts
lly clear info about PTEs") Signed-off-by: Ryan Roberts --- fs/proc/task_mmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 994cde10e3f4..361f3ffd9a0c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -2557,10 +2

Re: [RFC PATCH v1 3/6] mm: Avoid calling page allocator from apply_to_page_range()

2025-05-30 Thread Ryan Roberts
On 30/05/2025 17:23, Liam R. Howlett wrote: > * Ryan Roberts [250530 10:05]: >> Lazy mmu mode applies to the current task and permits pte modifications >> to be deferred and updated at a later time in a batch to improve >> performance. apply_to_page_range() calls its call

Re: [RFC PATCH v1 1/6] fs/proc/task_mmu: Fix pte update and tlb maintenance ordering in pagemap_scan_pmd_entry()

2025-05-30 Thread Ryan Roberts
On 30/05/2025 17:26, Jann Horn wrote: > On Fri, May 30, 2025 at 4:04 PM Ryan Roberts wrote: >> pagemap_scan_pmd_entry() was previously modifying ptes while in lazy mmu >> mode, then performing tlb maintenance for the modified ptes, then >> leaving lazy mmu mode. But any pte

Re: [RFC PATCH v1 0/6] Lazy mmu mode fixes and improvements

2025-05-30 Thread Ryan Roberts
On 30/05/2025 15:47, Lorenzo Stoakes wrote: > +cc Jann who is a specialist in all things page table-y and especially scary > edge cases :) > > On Fri, May 30, 2025 at 03:04:38PM +0100, Ryan Roberts wrote: >> Hi All, >> >> I recently added support for lazy mmu mode

[RFC PATCH v1 6/6] Revert "arm64/mm: Permit lazy_mmu_mode to be nested"

2025-05-30 Thread Ryan Roberts
commit and reinstate the VM_WARN() if nesting is detected in future. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index ad

[RFC PATCH v1 4/6] mm: Introduce arch_in_lazy_mmu_mode()

2025-05-30 Thread Ryan Roberts
performing an allocation, and will additionally be used to ensure pte modification vs tlb flushing order does not get inadvertantly swapped. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 8 .../powerpc/include/asm/book3s/64/tlbflush-hash.h | 15

[RFC PATCH v1 2/6] mm: Fix pte update and tlb maintenance ordering in migrate_vma_collect_pmd()

2025-05-30 Thread Ryan Roberts
ot;) Signed-off-by: Ryan Roberts --- mm/migrate_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 3158afe7eb23..fc73a940c112 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -283,11 +283,1

[RFC PATCH v1 5/6] mm: Avoid calling page allocator while in lazy mmu mode

2025-05-30 Thread Ryan Roberts
PI to check if we are in lazy mmu mode, and if so, when calling into the page allocator, temporarily leave lazy mmu mode. Given this new API we can also add VM_WARNings to check that we exit lazy mmu mode when required to ensure the PTEs are actually updated prior to tlb flushing. Signed-off-by:

[RFC PATCH v1 3/6] mm: Avoid calling page allocator from apply_to_page_range()

2025-05-30 Thread Ryan Roberts
e updated to use the _nolazy variants. Signed-off-by: Ryan Roberts --- include/linux/mm.h | 6 ++ kernel/bpf/arena.c | 6 +++--- mm/kasan/shadow.c | 2 +- mm/memory.c| 54 +++--- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/

[RFC PATCH v1 0/6] Lazy mmu mode fixes and improvements

2025-05-30 Thread Ryan Roberts
es (with DEBUG_PAGEALLOC and KFENCE enabled). Applies against Linus's master branch (f66bc387efbe). Thanks, Ryan Ryan Roberts (6): fs/proc/task_mmu: Fix pte update and tlb maintenance ordering in pagemap_scan_pmd_entry() mm: Fix pte update and tlb maintenance orderi

Re: [PATCH v2 0/5] Fix lazy mmu mode

2025-04-14 Thread Ryan Roberts
On 10/04/2025 17:07, Alexander Gordeev wrote: > On Mon, Mar 03, 2025 at 02:15:34PM +0000, Ryan Roberts wrote: > > Hi Ryan, > >> I'm planning to implement lazy mmu mode for arm64 to optimize vmalloc. As >> part >> of that, I will extend lazy mmu mode to cover k

Re: [PATCH v2 0/5] Fix lazy mmu mode

2025-04-14 Thread Ryan Roberts
On 14/04/2025 15:04, Alexander Gordeev wrote: > On Mon, Apr 14, 2025 at 02:22:53PM +0100, Ryan Roberts wrote: >> On 10/04/2025 17:07, Alexander Gordeev wrote: >>>> I'm planning to implement lazy mmu mode for arm64 to optimize vmalloc. As >>>> part >&g

[PATCH v2 4/5] sparc/mm: Avoid calling arch_enter/leave_lazy_mmu() in set_ptes

2025-03-03 Thread Ryan Roberts
and Acked-by: Andreas Larsson Signed-off-by: Ryan Roberts --- arch/sparc/include/asm/pgtable_64.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 2b7f358762c1..dc28f2c4eee3 100644 --- a/arch/sparc/include/

[PATCH v2 1/5] mm: Fix lazy mmu docs and usage

2025-03-03 Thread Ryan Roberts
of issues being reported in the wild. Cc: Fixes: bcc6cc832573 ("mm: add default definition of set_ptes()") Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- include/linux/pgtable.h | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/li

[PATCH v2 5/5] Revert "x86/xen: allow nesting of same lazy mode"

2025-03-03 Thread Ryan Roberts
) and remove this x86-specific solution. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- arch/x86/include/asm/xen/hypervisor.h | 15 ++- arch/x86/xen/enlighten_pv.c | 1 - 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/arch/x86/include/asm/xen/hyperv

[PATCH v2 2/5] fs/proc/task_mmu: Reduce scope of lazy mmu region

2025-03-03 Thread Ryan Roberts
asn't technically a bug here, the original scope made it easier to accidentally nest or, worse, accidentally call something like kmap() which would expect an immediate mode pte modification but it would end up deferred. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- fs/proc/task_

[PATCH v2 3/5] sparc/mm: Disable preemption in lazy mmu mode

2025-03-03 Thread Ryan Roberts
: call pte function with lazy updates") Acked-by: David Hildenbrand Acked-by: Andreas Larsson Signed-off-by: Ryan Roberts --- arch/sparc/mm/tlb.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 8648a50afe88..a35ddcca5e76

[PATCH v2 0/5] Fix lazy mmu mode

2025-03-03 Thread Ryan Roberts
hanges since v1 - split v1 patch #1 into v2 patch #1 and #2; per David - Added Acked-by tags from David and Andreas; Thanks! - Refined the patches which are truely fixes and added to stable to cc Thanks, Ryan Ryan Roberts (5): mm: Fix lazy mmu docs and usage fs/proc/task_mmu:

Re: [PATCH v1 4/4] Revert "x86/xen: allow nesting of same lazy mode"

2025-03-03 Thread Ryan Roberts
On 03/03/2025 11:52, David Hildenbrand wrote: > On 02.03.25 15:55, Ryan Roberts wrote: >> Commit 49147beb0ccb ("x86/xen: allow nesting of same lazy mode") was >> added as a solution for a core-mm code change where >> arch_[enter|leave]_lazy_mmu_mode() started to

Re: [PATCH v1 1/4] mm: Fix lazy mmu docs and usage

2025-03-03 Thread Ryan Roberts
On 03/03/2025 08:52, David Hildenbrand wrote: > On 03.03.25 09:49, David Hildenbrand wrote: >> On 02.03.25 15:55, Ryan Roberts wrote: >>> The docs, implementations and use of arch_[enter|leave]_lazy_mmu_mode() >>> is a bit of a mess (to put it politely). There are a numb

[PATCH v1 4/4] Revert "x86/xen: allow nesting of same lazy mode"

2025-03-02 Thread Ryan Roberts
) and remove this x86-specific solution. Fixes: 49147beb0ccb ("x86/xen: allow nesting of same lazy mode") Signed-off-by: Ryan Roberts --- arch/x86/include/asm/xen/hypervisor.h | 15 ++- arch/x86/xen/enlighten_pv.c | 1 - 2 files changed, 2 insertions(+), 14 deletions(-

[PATCH v1 0/4] Fix lazy mmu mode

2025-03-02 Thread Ryan Roberts
eries. See patch #1 commit log for all the details. Note that I have only been able to compile test these changes so appreciate any help in testing. Applies on Friday's mm-unstable (5f089a9aa987), as I assume this would be preferred via that tree. Thanks, Ryan Ryan Roberts (4): mm: Fix la

[PATCH v1 3/4] sparc/mm: Avoid calling arch_enter/leave_lazy_mmu() in set_ptes

2025-03-02 Thread Ryan Roberts
leave_lazy_mmu() Powerpc suffered the same problem and fixed it in a corresponding way with commit 47b8def9358c ("powerpc/mm: Avoid calling arch_enter/leave_lazy_mmu() in set_ptes"). Fixes: 1a10a44dfc1d ("sparc64: implement the new page table range API") Signed-off-by: Ryan Roberts

[PATCH v1 2/4] sparc/mm: Disable preemption in lazy mmu mode

2025-03-02 Thread Ryan Roberts
l pte function with lazy updates") Signed-off-by: Ryan Roberts --- arch/sparc/mm/tlb.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 8648a50afe88..a35ddcca5e76 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tl

[PATCH v1 1/4] mm: Fix lazy mmu docs and usage

2025-03-02 Thread Ryan Roberts
it would end up deferred. arch-specific fixes to conform to the new spec will proceed this one. These issues were spotted by code review and I have no evidence of issues being reported in the wild. Signed-off-by: Ryan Roberts --- fs/proc/task_mmu.c | 11 --- include/linux/pgtable.h

Re: [RFC PATCH v1 36/57] xen: Remove PAGE_SIZE compile-time constant assumption

2024-10-24 Thread Ryan Roberts
On 23/10/2024 02:23, Stefano Stabellini wrote: > +Julien > > On Wed, 16 Oct 2024, Ryan Roberts wrote: >> + Juergen Gross, Stefano Stabellini >> >> This was a rather tricky series to get the recipients correct for and my >> script >> did not reali

Re: [RFC PATCH v1 36/57] xen: Remove PAGE_SIZE compile-time constant assumption

2024-10-16 Thread Ryan Roberts
/lore.kernel.org/all/20241014105514.3206191-1-ryan.robe...@arm.com/ On 14/10/2024 11:58, Ryan Roberts wrote: > To prepare for supporting boot-time page size selection, refactor code > to remove assumptions about PAGE_SIZE being compile-time constant. Code > intended to be equivalent when com

[RFC PATCH v1 36/57] xen: Remove PAGE_SIZE compile-time constant assumption

2024-10-14 Thread Ryan Roberts
t-time, it can be evaluated at run time. Refactor a BUILD_BUG_ON to evaluate the limit (when the minimum supported page size is selected at boot-time). Reserve enough storage for max page size in "struct remap_data" and "struct xenbus_map_node". Signed-off-by: Ryan Roberts