From: vbabka@kernel.org
To: Xie Yuanbin <qq570070308@gmail.com>,
rppt@kernel.org, david.laight.linux@gmail.com,
akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
Liam.Howlett@oracle.com, surenb@google.com, mhocko@suse.com,
nathan@kernel.org, nick.desaulniers+lkml@gmail.com,
morbo@google.com, justinstitt@google.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] mm/debug: optimize once judgment with clang
Date: Tue, 10 Mar 2026 11:50:11 +0100 [thread overview]
Message-ID: <a7d5ed43-2ab4-4338-87f0-7a50af463018@kernel.org> (raw)
In-Reply-To: <20260309153405.20130-1-qq570070308@gmail.com>
On 3/9/26 16:34, Xie Yuanbin wrote:
> commit 242b872239f6a7deacbc ("include/linux/once_lite.h: fix judgment in
> WARN_ONCE with clang") helps optimize performance and size under the
> clang compiler, but the modification is not complete.
>
> Port the modification to VM_WARN_ON_ONCE_PAGE(), VM_WARN_ON_ONCE_FOLIO(),
> VM_WARN_ON_ONCE_MM() and VM_WARN_ON_ONCE_VMA().
>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: David Laight <david.laight.linux@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Xie Yuanbin <qq570070308@gmail.com>
We don't need to make debug code (hence perf doesn't matter there) more ugly
just for clang's sake, I think.
> ---
> include/linux/mmdebug.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
> index ab60ffba08f5..a167c5aa525e 100644
> --- a/include/linux/mmdebug.h
> +++ b/include/linux/mmdebug.h
> @@ -60,7 +60,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
> static bool __section(".data..once") __warned; \
> int __ret_warn_once = !!(cond); \
> \
> - if (unlikely(__ret_warn_once && !__warned)) { \
> + if (unlikely(__ret_warn_once) && unlikely(!__warned)) { \
> dump_page(page, "VM_WARN_ON_ONCE_PAGE(" __stringify(cond)")");\
> __warned = true; \
> WARN_ON(1); \
> @@ -80,7 +80,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
> static bool __section(".data..once") __warned; \
> int __ret_warn_once = !!(cond); \
> \
> - if (unlikely(__ret_warn_once && !__warned)) { \
> + if (unlikely(__ret_warn_once) && unlikely(!__warned)) { \
> dump_page(&folio->page, "VM_WARN_ON_ONCE_FOLIO(" __stringify(cond)")");\
> __warned = true; \
> WARN_ON(1); \
> @@ -91,7 +91,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
> static bool __section(".data..once") __warned; \
> int __ret_warn_once = !!(cond); \
> \
> - if (unlikely(__ret_warn_once && !__warned)) { \
> + if (unlikely(__ret_warn_once) && unlikely(!__warned)) { \
> dump_mm(mm); \
> __warned = true; \
> WARN_ON(1); \
> @@ -102,7 +102,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
> static bool __section(".data..once") __warned; \
> int __ret_warn_once = !!(cond); \
> \
> - if (unlikely(__ret_warn_once && !__warned)) { \
> + if (unlikely(__ret_warn_once) && unlikely(!__warned)) { \
> dump_vma(vma); \
> __warned = true; \
> WARN_ON(1); \
prev parent reply other threads:[~2026-03-10 10:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 15:34 [PATCH] mm/debug: optimize once judgment with clang Xie Yuanbin
2026-03-10 10:50 ` vbabka [this message]
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=a7d5ed43-2ab4-4338-87f0-7a50af463018@kernel.org \
--to=vbabka@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david.laight.linux@gmail.com \
--cc=david@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mhocko@suse.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=qq570070308@gmail.com \
--cc=rppt@kernel.org \
--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