From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Xie Yuanbin <qq570070308@gmail.com>, willy@infradead.org
Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org,
david.laight.linux@gmail.com, david@kernel.org,
justinstitt@google.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, ljs@kernel.org, llvm@lists.linux.dev,
mhocko@suse.com, morbo@google.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, rppt@kernel.org,
surenb@google.com
Subject: Re: [PATCH] mm: optimize the implementation of WARN_ON_ONCE_GFP()
Date: Tue, 10 Mar 2026 11:55:55 +0100 [thread overview]
Message-ID: <be647d6b-9bcb-41c8-bfcf-7fa03d2b942f@kernel.org> (raw)
In-Reply-To: <20260309155933.41179-1-qq570070308@gmail.com>
On 3/9/26 16:59, Xie Yuanbin wrote:
> On Mon, 9 Mar 2026 15:40:13 +0000, Matthew Wilcox wrote:
>>On Mon, Mar 09, 2026 at 11:38:11PM +0800, Xie Yuanbin wrote:
>>> As shown in the commit message of commit 242b872239f6a7deacbc
>>> ("include/linux/once_lite.h: fix judgment in WARN_ONCE with clang"),
>>> the code "unlikely(a && b)" may generate poor assembly code if it is
>>> actually "unlikely(a) && unlikely(b)" or "unlikely(a) && b".
>>
>> Why fix this in multiple places in the kernel instead of once in clang?
>
> If a and b is both unlikely, then "unlikely(a) && unlikely(b)" will
> generate better code than "unlikely(a && b)". This is also true for gcc.
What are the details of how it's better for gcc?
> As for the issue of clang judging twice, I have already submitted it to
> clang:
> Link: https://github.com/llvm/llvm-project/issues/167117
> However, even if clang fixes it, this optimization will not be merged
> back to the old version of clang.
That's life and not worth complicating the kernel code for. This is not
about making it functional, only about perf.
next prev parent reply other threads:[~2026-03-10 10:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 15:38 [PATCH] mm: optimize the implementation of WARN_ON_ONCE_GFP() Xie Yuanbin
2026-03-09 15:40 ` Matthew Wilcox
2026-03-09 15:59 ` Xie Yuanbin
2026-03-10 10:55 ` Vlastimil Babka (SUSE) [this message]
2026-03-10 14:52 ` David Laight
2026-03-27 5:34 ` Andrew Morton
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=be647d6b-9bcb-41c8-bfcf-7fa03d2b942f@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 \
--cc=willy@infradead.org \
/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