[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48a4ecb5-3412-4d3f-9e43-535f8bee505f@arm.com>
Date: Thu, 6 Nov 2025 10:51:43 +0000
From: Kevin Brodsky <kevin.brodsky@....com>
To: Alexander Gordeev <agordeev@...ux.ibm.com>,
Ritesh Harjani <ritesh.list@...il.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
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 Hildenbrand <david@...hat.com>, "David S. Miller"
<davem@...emloft.net>, David Woodhouse <dwmw2@...radead.org>,
"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 v4 07/12] mm: enable lazy_mmu sections to nest
On 05/11/2025 16:12, Alexander Gordeev wrote:
> On Wed, Nov 05, 2025 at 02:19:03PM +0530, Ritesh Harjani wrote:
>>> + * in_lazy_mmu_mode() can be used to check whether the lazy MMU mode is
>>> + * currently enabled.
>>> */
>>> #ifdef CONFIG_ARCH_HAS_LAZY_MMU_MODE
>>> static inline void lazy_mmu_mode_enable(void)
>>> {
>>> - arch_enter_lazy_mmu_mode();
>>> + struct lazy_mmu_state *state = ¤t->lazy_mmu_state;
>>> +
>>> + VM_WARN_ON_ONCE(state->nesting_level == U8_MAX);
>>> + /* enable() must not be called while paused */
>>> + VM_WARN_ON(state->nesting_level > 0 && !state->active);
>>> +
>>> + if (state->nesting_level++ == 0) {
>>> + state->active = true;
>>> + arch_enter_lazy_mmu_mode();
>>> + }
>>> }
>> Some architectures disables preemption in their
>> arch_enter_lazy_mmu_mode(). So shouldn't the state->active = true should
>> happen after arch_enter_lazy_mmu_mode() has disabled preemption()? i.e.
> Do you have some scenario in mind that could cause an issue?
> IOW, what could go wrong if the process is scheduled to another
> CPU before preempt_disable() is called?
I'm not sure I understand the issue either.
>> static inline void lazy_mmu_mode_enable(void)
>> {
>> - arch_enter_lazy_mmu_mode();
>> + struct lazy_mmu_state *state = ¤t->lazy_mmu_state;
>> +
>> + VM_WARN_ON_ONCE(state->nesting_level == U8_MAX);
>> + /* enable() must not be called while paused */
>> + VM_WARN_ON(state->nesting_level > 0 && !state->active);
>> +
>> + if (state->nesting_level++ == 0) {
>> + arch_enter_lazy_mmu_mode();
>> + state->active = true;
>> + }
>> }
>>
>> ... I think it make more sense to enable the state after the arch_**
>> call right.
> But then in_lazy_mmu_mode() would return false if called from
> arch_enter_lazy_mmu_mode(). Not big problem, but still..
The ordering of nesting_level/active was the way you expected in v3, but
the conclusion of the discussion with David H [1] is that it doesn't
really matter so I simplified the ordering in v4 - the arch hooks
shouldn't call in_lazy_mmu_mode() or inspect lazy_mmu_state.
arch_enter()/arch_leave() shouldn't need it anyway since they're called
once per outer section (not in nested sections). arch_flush() could
potentially do something different when nested, but that seems unlikely.
- Kevin
[1]
https://lore.kernel.org/all/af4414b6-617c-4dc8-bddc-3ea00d1f6f3b@redhat.com/
Powered by blists - more mailing lists