[PATCH v2 0/7] Nesting support for lazy MMU mode
Kevin Brodsky
kevin.brodsky at arm.com
Mon Sep 15 21:19:32 AEST 2025
On 15/09/2025 08:28, Alexander Gordeev wrote:
> On Fri, Sep 12, 2025 at 05:25:27PM +0200, Kevin Brodsky wrote:
>
> Hi Kevin,
>
>> Based on the outcome of the discussion with David on patch 2 [1p], there
>> is indeed an alternative approach that we should seriously consider. In
>> summary:
>>
>> * Keep the API stateless, handle nesting with a counter in task_struct
>> * Introduce new functions to temporarily disable lazy_mmu without
>> impacting nesting, track that with a bool in task_struct (addresses the
>> situation in mm/kasan/shadow.c and possibly some x86 cases too)
>> * Move as much handling from arch_* to generic functions
>>
>> What the new generic infrastructure would look like:
>>
>> struct task_struct {
>> ...
>> #ifdef CONFIG_ARCH_LAZY_MMU
>> struct {
>> uint8_t count;
>> bool enabled; /* or paused, see below */
>> } lazy_mmu_state;
>> #endif
>> }
>>
>> * lazy_mmu_mode_enable():
> This helper is parameter-free, assuming the MMU unit does not need any
> configuration other than turning it on/off. That is currently true, but
> (as I noted in my other mail) I am going to introduce a friend enable
> function that accepts parameters, creates an arch-specific state and
> uses it while the lazy mmu mode is active.
Yes I think that's fine.
> That does not impact your design (AFAICT), except one change below.
>
>> if (!lazy_mmu_state.count) {
>> arch_enter_lazy_mmu_mode();
>> lazy_mmu_state.enabled = true;
>> }
>> lazy_mmu_state.count++;
>>
>> * lazy_mmu_mode_disable():
>> lazy_mmu_count--;
>> if (!lazy_mmu_state.count) {
>> lazy_mmu_state.enabled = false;
>> arch_leave_lazy_mmu_mode();
>> } else {
>> arch_flush_lazy_mmu_mode();
>> }
>>
>> * lazy_mmu_mode_pause():
>> lazy_mmu_state.enabled = false;
>> arch_leave_lazy_mmu_mode();
> This needs to be arch_pause_lazy_mmu_mode(), otherwise the arch-specific
> state will be lost.
>
>> * lazy_mmu_mode_resume();
>> arch_enter_lazy_mmu_mode();
> Conversely, this needs to be arch_resume_lazy_mmu_mode(). And it can not
> be arch_enter_lazy_mmu_mode(), since a lazy_mmu_mode_resume() caller does
> not know the parameters passed to the lazy_mmu_mode_enable(...)-friend.
Got it, that makes sense. Even without your proposal, it is probably a
good idea to allow arch's to behave differently on pause/resume.
I hope we can avoid forcing all arch's to define arch_pause/arch_resume
though, since only s390 will use it for the foreseeable future. Using
optional macros should do the trick.
- Kevin
More information about the Linuxppc-dev
mailing list