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

From: Kevin Brodsky

Date: Mon Apr 20 2026 - 04:52:02 EST


On 15/04/2026 17:01, Alexander Gordeev wrote:
> +/**
> + * 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.

Does that mean that all PTEs mapping [addr, end) must belong to the same
PTE page? I think the wording should be more specific.

LGTM otherwise:

Reviewed-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>

> + *
> + * 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,
> + 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);
> +}