Re: [PATCH v4 06/12] mm: introduce generic lazy_mmu helpers
From: Kevin Brodsky <hidden>
Date: 2025-11-24 12:48:05
Also in:
linux-arm-kernel, linux-mm, lkml, sparclinux, xen-devel
On 10/11/2025 11:45, Kevin Brodsky wrote:
quoted
quoted
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index b8d37eb037fc..d9c8e94f140f 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c@@ -731,7 +731,7 @@ int split_kernel_leaf_mapping(unsigned long start, unsigned long end) return -EINVAL; mutex_lock(&pgtable_split_lock); - arch_enter_lazy_mmu_mode(); + lazy_mmu_mode_enable(); /* * The split_kernel_leaf_mapping_locked() may sleep, it is not aThis is a bit unfortunate, IMHO. The rest of this comment explains that although you're not supposed to sleep inside lazy mmu mode, it's fine for arm64's implementation. But we are no longer calling arm64's implementation; we are calling a generic function, which does who knows what. I think it all still works, but we are no longer containing our assumptions in arm64 code. We are relying on implementation details of generic code.I see your point. The change itself is still correct (and required considering patch 8), but maybe the documentation of the generic interface should be clarified to guarantee that the generic layer can itself cope with sleeping - without any guarantee regarding the behaviour of arch_*_lazy_mmu_mode.
Re-reading the existing comment in <linux/pgtable.h>, I think it already makes clear that sleeping is not forbidden by design:
* In the general case, no lock is guaranteed to be held between entry and exit * of the lazy mode. So the implementation must assume preemption may be enabled * and cpu migration is possible; it must take steps to be robust against this.
The arch implementation may disable preemption, but arm64 code can rely on the arm64 implementation allowing sleeping. - Kevin