[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <af4414b6-617c-4dc8-bddc-3ea00d1f6f3b@redhat.com>
Date: Fri, 24 Oct 2025 15:23:39 +0200
From: David Hildenbrand <david@...hat.com>
To: Kevin Brodsky <kevin.brodsky@....com>, linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org, Alexander Gordeev <agordeev@...ux.ibm.com>,
Andreas Larsson <andreas@...sler.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>, Borislav Petkov
<bp@...en8.de>, Catalin Marinas <catalin.marinas@....com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"David S. Miller" <davem@...emloft.net>, "H. Peter Anvin" <hpa@...or.com>,
Ingo Molnar <mingo@...hat.com>, Jann Horn <jannh@...gle.com>,
Juergen Gross <jgross@...e.com>, "Liam R. Howlett"
<Liam.Howlett@...cle.com>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Michael Ellerman <mpe@...erman.id.au>, Michal Hocko <mhocko@...e.com>,
Mike Rapoport <rppt@...nel.org>, Nicholas Piggin <npiggin@...il.com>,
Peter Zijlstra <peterz@...radead.org>, Ryan Roberts <ryan.roberts@....com>,
Suren Baghdasaryan <surenb@...gle.com>, Thomas Gleixner
<tglx@...utronix.de>, Vlastimil Babka <vbabka@...e.cz>,
Will Deacon <will@...nel.org>, Yeoreum Yun <yeoreum.yun@....com>,
linux-arm-kernel@...ts.infradead.org, linuxppc-dev@...ts.ozlabs.org,
sparclinux@...r.kernel.org, xen-devel@...ts.xenproject.org, x86@...nel.org
Subject: Re: [PATCH v3 07/13] mm: enable lazy_mmu sections to nest
>>> + * currently enabled.
>>> */
>>> #ifdef CONFIG_ARCH_LAZY_MMU
>>> static inline void lazy_mmu_mode_enable(void)
>>> {
>>> - arch_enter_lazy_mmu_mode();
>>> + struct lazy_mmu_state *state = ¤t->lazy_mmu_state;
>>> +
>>> + VM_BUG_ON(state->count == U8_MAX);
>>
>> No VM_BUG_ON() please.
>
> I did wonder if this would be acceptable!
Use VM_WARN_ON_ONCE() and let early testing find any such issues.
VM_* is active in debug kernels only either way! :)
If you'd want to handle this in production kernels you'd need
if (WARN_ON_ONCE()) {
/* Try to recover */
}
And that seems unnecessary/overly-complicated for something that should
never happen, and if it happens, can be found early during testing.
>
> What should we do in case of underflow/overflow then? Saturate or just
> let it wrap around? If an overflow occurs we're probably in some
> infinite recursion and we'll crash anyway, but an underflow is likely
> due to a double disable() and saturating would probably allow to recover.
>
>>
>>> + /* enable() must not be called while paused */
>>> + VM_WARN_ON(state->count > 0 && !state->enabled);
>>> +
>>> + if (state->count == 0) {
>>> + arch_enter_lazy_mmu_mode();
>>> + state->enabled = true;
>>> + }
>>> + ++state->count;
>>
>> Can do
>>
>> if (state->count++ == 0) {
>
> My idea here was to have exactly the reverse order between enable() and
> disable(), so that arch_enter() is called before lazy_mmu_state is
> updated, and arch_leave() afterwards. arch_* probably shouldn't rely on
> this (or care), but I liked the symmetry.
I see, but really the arch callback should never have to care about that
value -- unless something is messed up :)
[...]
>>> +static inline bool in_lazy_mmu_mode(void)
>>
>> So these functions will reveal the actual arch state, not whether
>> _enabled() was called.
>>
>> As I can see in later patches, in interrupt context they are also
>> return "not in lazy mmu mode".
>
> Yes - the idea is that a task is in lazy MMU mode if it enabled it and
> is in process context. The mode is never enabled in interrupt context.
> This has always been the intention, but it wasn't formalised until patch
> 12 (except on arm64).
Okay, thanks for clarifying.
--
Cheers
David / dhildenb
Powered by blists - more mailing lists