Re: [RFC PATCH 1/2] mm: make lazy MMU mode context-aware
From: David Hildenbrand (Arm)
Date: Tue Mar 31 2026 - 17:11:41 EST
On 3/25/26 17:20, Alexander Gordeev wrote:
> On Wed, Mar 25, 2026 at 10:55:23AM +0100, David Hildenbrand (Arm) wrote:
>
> Hi David,
>
>>> +/**
>>> + * lazy_mmu_mode_enable_pte() - Enable the lazy MMU mode with parameters
>>
>> You have to be a lot clearer about implications. For example, what
>> happens if we would bail out and not process all ptes? What are the
>> exact semantics.
>
> The only implication is "only this address/PTE range could be updated
> and that range may span one page table at most".
Probably phrase it stronger. "No ptes outside of this range must be
updated" etc.
>
> Whether all or portion of PTEs were actually updated is not defined,
> just like in case of lazy_mmu_mode_enable_pte().
Okay, then let's document that.
>
> Makes sense?
>
Yes.
>>> + * Enters a new lazy MMU mode section; if the mode was not already enabled,
>>> + * enables it and calls arch_enter_lazy_mmu_mode_pte().
>>> + *
>>> + * 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_pte(struct mm_struct *mm,
>>> + unsigned long addr,
>>> + unsigned long end,
>>> + pte_t *ptep)
>>
>> It can be multiple ptes, so should this be some kind of "pte_range"/
>>
>> lazy_mmu_mode_enable_for_pte_range()
>>
>> A bit mouthful but clearer.
>>
>>> +{
>>> + struct lazy_mmu_state *state = ¤t->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_pte(mm, addr, end, ptep);
>
> I will also change arch_enter_lazy_mmu_mode_pte() to
> arch_enter_lazy_mmu_mode_for_pte_range() then.
>
>>> +}
>>
>> I'm wondering whether that could instead be some optional interface that
>> we trigger after the lazy_mmu_mode_enable. But looking at
>
> To me just two separate and (as you put it) mouthful names appeal better
> than an optional follow-up interface.
Yes, probably better.
--
Cheers,
David