Re: [PATCH 2/7] mm: introduce local state for lazy_mmu sections
From: Kevin Brodsky
Date: Thu Sep 04 2025 - 11:48:08 EST
On 04/09/2025 17:06, Yeoreum Yun wrote:
> Hi Kevin,
>
> [...]
>> Signed-off-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
>> ---
>> 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 | 5 +++--
>> arch/sparc/include/asm/tlbflush_64.h | 5 +++--
>> arch/sparc/mm/tlb.c | 6 ++++--
>> arch/x86/include/asm/paravirt.h | 6 ++++--
>> arch/x86/include/asm/paravirt_types.h | 2 ++
>> arch/x86/xen/enlighten_pv.c | 2 +-
>> arch/x86/xen/mmu_pv.c | 2 +-
>> fs/proc/task_mmu.c | 5 +++--
>> include/linux/mm_types.h | 3 +++
>> include/linux/pgtable.h | 6 ++++--
>> mm/madvise.c | 20 ++++++++++---------
>> mm/memory.c | 20 +++++++++++--------
>> mm/migrate_device.c | 5 +++--
>> mm/mprotect.c | 5 +++--
>> mm/mremap.c | 5 +++--
>> mm/vmalloc.c | 15 ++++++++------
>> mm/vmscan.c | 15 ++++++++------
>> 20 files changed, 97 insertions(+), 59 deletions(-)
> I think you miss the mm/kasan/shadow.c
Ah yes that's because my series is based on v6.17-rc4 but [1] isn't in
mainline yet. I'll rebase v2 on top of mm-stable.
[1]
https://lore.kernel.org/all/0d2efb7ddddbff6b288fbffeeb10166e90771718.1755528662.git.agordeev@xxxxxxxxxxxxx/
> But here, the usage is like:
>
> static int kasan_populate_vmalloc_pte()
> {
> ...
> arch_leave_lazy_mmu_mode();
> ...
> arch_enter_lazy_mmu_mode();
> ...
> }
>
> Might be you can call the arch_leave_lazy_mmu_mode() with LAZY_MMU_DEFAULT
> in here since I think kasan_populate_vmalloc_pte() wouldn't be called
> nestly.
In fact in that case it doesn't matter if the section is nested or not.
We're already assuming that lazy_mmu is enabled, and we want to fully
disable it so that PTE operations take effect immediately. For that to
happen we must call arch_leave_lazy_mmu_mode(LAZY_MMU_DEFAULT). We will
then re-enable lazy_mmu, and the next call to leave() will do the right
thing whether it is nested or not.
It's worth nothing the same situation occurs in xen_flush_lazy_mmu() and
this patch handles it in the way I've just described.
I'll take care of that in v2, thanks for the heads-up!
- Kevin