From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Suren Baghdasaryan <surenb@google.com>,
"Liam R. Howlett" <liam@infradead.org>,
Shakeel Butt <shakeel.butt@linux.dev>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] mm: only assert mmap locks if CONFIG_DEBUG_VM or lockdep is set
Date: Wed, 11 Nov 2026 10:35:42 +0100 [thread overview]
Message-ID: <f796b3fc-90e4-4fa7-997f-8df8cd5d2b47@kernel.org> (raw)
In-Reply-To: <20261110-tame-vma-asserts-v1-1-be293ff499a7@kernel.org>
On 11/10/26 17:57, Lorenzo Stoakes (ARM) wrote:
> For a long while we have asserted the mmap lock being held regardless of
> whether or not the kernel is a debug build or not.
>
> In general, given that these have been added as programmatic asserts that
> nobody did something stupid, production kernels are simply wasting their
> time checking for this.
>
> It also means there is a two tier system - where some programmatic
> asserts (e.g. VM_WARN_ON_ONCE()-checked conditions) are only checked for if
> CONFIG_DEBUG_VM is enabled, whereas others are checked unconditionally.
>
> If we genuinely want to unconditionally check for the mmap lock being held
> at runtime, then that should be made clear in the code doing it.
>
> Regardless, if CONFIG_LOCKDEP is enabled, ensure that the lockdep
> assertions are performed.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> ---
> include/linux/mmap_lock.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h
> index 9c3a9c6525c1..9367430ee53c 100644
> --- a/include/linux/mmap_lock.h
> +++ b/include/linux/mmap_lock.h
> @@ -75,12 +75,14 @@ static inline void __mmap_lock_trace_released(struct mm_struct *mm, bool write)
>
> static inline void mmap_assert_locked(const struct mm_struct *mm)
> {
> - rwsem_assert_held(&mm->mmap_lock);
> + if (IS_ENABLED(CONFIG_DEBUG_VM) || IS_ENABLED(CONFIG_LOCKDEP))
> + rwsem_assert_held(&mm->mmap_lock);
> }
>
> static inline void mmap_assert_write_locked(const struct mm_struct *mm)
> {
> - rwsem_assert_held_write(&mm->mmap_lock);
> + if (IS_ENABLED(CONFIG_DEBUG_VM) || IS_ENABLED(CONFIG_LOCKDEP))
> + rwsem_assert_held_write(&mm->mmap_lock);
> }
>
> #ifdef CONFIG_LOCKDEP
>
next prev parent reply other threads:[~2026-11-11 9:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 16:57 [PATCH 0/3] mm: only assert mmap and VMA locks if CONFIG_DEBUG_VM " Lorenzo Stoakes (ARM)
2026-11-10 16:57 ` [PATCH 1/3] mm: only assert mmap locks if CONFIG_DEBUG_VM or lockdep " Lorenzo Stoakes (ARM)
2026-11-11 1:23 ` Liam R. Howlett
2026-11-11 9:35 ` Vlastimil Babka (SUSE) [this message]
2026-11-10 16:57 ` [PATCH 2/3] mm: only assert VMA locks if CONFIG_DEBUG_VM " Lorenzo Stoakes (ARM)
2026-11-11 1:29 ` Liam R. Howlett
2026-11-11 9:38 ` Vlastimil Babka (SUSE)
2026-11-10 16:57 ` [PATCH 3/3] mm: convert WARN_ON_ONCE()'s to VM_WARN_ON_ONCE() in VMA lock code Lorenzo Stoakes (ARM)
2026-11-11 1:30 ` Liam R. Howlett
2026-11-11 9:38 ` Vlastimil Babka (SUSE)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f796b3fc-90e4-4fa7-997f-8df8cd5d2b47@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®