Re: [PATCH v2 1/6] mm: Make lazy MMU mode context-aware

David Hildenbrand (Arm)
2026-04-21T14:15:50Z

> +/**
> + * lazy_mmu_mode_enable_for_pte_range() - Enable the lazy MMU mode with a speedup hint.
> + * @mm: Address space the pages are mapped into.
> + * @addr: Start address of the range.
> + * @end: End address of the range.
> + * @ptep: Page table pointer for the first entry.
> + *
> + * Enters a new lazy MMU mode section; if the mode was not already enabled,
> + * enables it and calls arch_enter_lazy_mmu_mode_for_pte_range().
> + *
> + * PTEs that fall within the specified range might observe update speedups.
> + * The PTE range must belong to the specified memory space and not cross
> + * a page table boundary.
> + *
> + * There are no requirements on the order or range completeness of PTE
> + * updates for the specified range.
> + *
> + * Must be paired with a call to lazy_mmu_mode_disable().
> + *
> + * Has no effect if called:
> + * - While paused - see lazy_mmu_mode_pause()
> + * - In interrupt context
> + */
> +static inline void lazy_mmu_mode_enable_for_pte_range(struct mm_struct *mm,

I'm still wondering about a better name for this. "enable_for" indeed
sounds like it's only for that range.

Maybe really something including a hint like you previously proposed

lazy_mmu_mode_enable_with_ptes()

lazy_mmu_mode_enable_with_pte_hints()

I think lazy_mmu_mode_enable_with_ptes() is neat.

Thoughts?

In any case, on the general approach + semantics:

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

> + unsigned long addr, unsigned long end, pte_t *ptep)
> +{
> + struct lazy_mmu_state *state = &current->lazy_mmu_state;
> +
> + if (in_interrupt() || state->pause_count > 0)
> + return;
> +
> + VM_WARN_ON_ONCE(state->enable_count == U8_MAX);
> +
> + if (state->enable_count++ == 0)
> + arch_enter_lazy_mmu_mode_for_pte_range(mm, addr, end, ptep);

Okay, so the "hint" is ignored for nesting levels, that works.

--
Cheers,

David