Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/bug: Implement WARN_ONCE()

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

+11
+9
arch/x86/include/asm/bug.h
··· 178 178 #define __WARN_printf(taint, fmt, arg...) \ 179 179 __WARN_print_arg(BUGFLAG_TAINT(taint), fmt, ## arg) 180 180 181 + #define WARN_ONCE(cond, format, arg...) ({ \ 182 + int __ret_warn_on = !!(cond); \ 183 + if (unlikely(__ret_warn_on)) { \ 184 + __WARN_print_arg(BUGFLAG_ONCE|BUGFLAG_TAINT(TAINT_WARN),\ 185 + format, ## arg); \ 186 + } \ 187 + __ret_warn_on; \ 188 + }) 189 + 181 190 #endif /* HAVE_ARCH_BUG_FORMAT_ARGS */ 182 191 183 192 #include <asm-generic/bug.h>
+2
include/asm-generic/bug.h
··· 180 180 DO_ONCE_LITE_IF(condition, WARN_ON, 1) 181 181 #endif 182 182 183 + #ifndef WARN_ONCE 183 184 #define WARN_ONCE(condition, format...) \ 184 185 DO_ONCE_LITE_IF(condition, WARN, 1, format) 186 + #endif 185 187 186 188 #define WARN_TAINT_ONCE(condition, taint, format...) \ 187 189 DO_ONCE_LITE_IF(condition, WARN_TAINT, 1, taint, format)