]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/bug: Implement WARN_ONCE()
authorPeter Zijlstra <peterz@infradead.org>
Mon, 2 Jun 2025 13:08:30 +0000 (15:08 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 24 Nov 2025 19:23:25 +0000 (20:23 +0100)
Implement WARN_ONCE like WARN using BUGFLAG_ONCE.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251110115758.339309119@infradead.org
arch/x86/include/asm/bug.h
include/asm-generic/bug.h

index b5474603460b48e57f0b53805241e8df300b9f53..87199e6633f9835b7303a8b5532b39b942d3f1dc 100644 (file)
@@ -178,6 +178,15 @@ do {                                                                       \
 #define __WARN_printf(taint, fmt, arg...) \
        __WARN_print_arg(BUGFLAG_TAINT(taint), fmt, ## arg)
 
+#define WARN_ONCE(cond, format, arg...) ({                             \
+       int __ret_warn_on = !!(cond);                                   \
+       if (unlikely(__ret_warn_on)) {                                  \
+               __WARN_print_arg(BUGFLAG_ONCE|BUGFLAG_TAINT(TAINT_WARN),\
+                               format, ## arg);                        \
+       }                                                               \
+       __ret_warn_on;                                                  \
+})
+
 #endif /* HAVE_ARCH_BUG_FORMAT_ARGS */
 
 #include <asm-generic/bug.h>
index e512071216becc3a2a7fecd0e095f0d6ead658cf..09e8eccee8ed97a4148b9e1d1f62451bd7af294c 100644 (file)
@@ -180,8 +180,10 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
        DO_ONCE_LITE_IF(condition, WARN_ON, 1)
 #endif
 
+#ifndef WARN_ONCE
 #define WARN_ONCE(condition, format...)                                \
        DO_ONCE_LITE_IF(condition, WARN, 1, format)
+#endif
 
 #define WARN_TAINT_ONCE(condition, taint, format...)           \
        DO_ONCE_LITE_IF(condition, WARN_TAINT, 1, taint, format)