[PATCH v2 0/7] Nesting support for lazy MMU mode
Alexander Gordeev
agordeev at linux.ibm.com
Mon Sep 15 16:28:52 AEST 2025
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.
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.
> lazy_mmu_state.enabled = true;
...
Thanks!
More information about the Linuxppc-dev
mailing list