* + mm-optimize-the-implementation-of-warn_on_once_gfp.patch added to mm-new branch
@ 2026-03-09 17:44 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-03-09 17:44 UTC (permalink / raw)
To: mm-commits, willy, vbabka, surenb, rppt, nathan, morbo, ljs,
liam.howlett, justinstitt, david, qq570070308, akpm
The patch titled
Subject: mm: optimize the implementation of WARN_ON_ONCE_GFP()
has been added to the -mm mm-new branch. Its filename is
mm-optimize-the-implementation-of-warn_on_once_gfp.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-optimize-the-implementation-of-warn_on_once_gfp.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Xie Yuanbin <qq570070308@gmail.com>
Subject: mm: optimize the implementation of WARN_ON_ONCE_GFP()
Date: Mon, 9 Mar 2026 23:38:11 +0800
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".
WARN_ON_ONCE_GFP() may be used in the hot path code:
1. The argument cond shoud be unlikely.
2. When "1." is true, !(gfp & __GFP_NOWARN) is unlikely, otherwise, a
WARN may be triggered, which is a very unlikely case.
3. When "1. && 2." is true, just like the implementation of WARN_ONCE(),
!__warned can be unlikely.
Reorder __ret_warn_once judgement to first and split out the unlikely() in
WARN_ON_ONCE_GFP() to optimize performance.
Link: https://lkml.kernel.org/r/20260309153811.40958-1-qq570070308@gmail.com
Signed-off-by: Xie Yuanbin <qq570070308@gmail.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Bill Wendling <morbo@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/internal.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/mm/internal.h~mm-optimize-the-implementation-of-warn_on_once_gfp
+++ a/mm/internal.h
@@ -94,7 +94,8 @@ struct pagetable_move_control {
static bool __section(".data..once") __warned; \
int __ret_warn_once = !!(cond); \
\
- if (unlikely(!(gfp & __GFP_NOWARN) && __ret_warn_once && !__warned)) { \
+ if (unlikely(__ret_warn_once) && \
+ unlikely(!(gfp & __GFP_NOWARN)) && unlikely(!__warned)) { \
__warned = true; \
WARN_ON(1); \
} \
_
Patches currently in -mm which might be from qq570070308@gmail.com are
mm-optimize-the-implementation-of-warn_on_once_gfp.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-09 17:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 17:44 + mm-optimize-the-implementation-of-warn_on_once_gfp.patch added to mm-new branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.