Skip to content

Commit 11bb494

Browse files
author
Peter Zijlstra
committed
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
1 parent 5b472b6 commit 11bb494

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

arch/x86/include/asm/bug.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ do { \
178178
#define __WARN_printf(taint, fmt, arg...) \
179179
__WARN_print_arg(BUGFLAG_TAINT(taint), fmt, ## arg)
180180

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+
181190
#endif /* HAVE_ARCH_BUG_FORMAT_ARGS */
182191

183192
#include <asm-generic/bug.h>

include/asm-generic/bug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
180180
DO_ONCE_LITE_IF(condition, WARN_ON, 1)
181181
#endif
182182

183+
#ifndef WARN_ONCE
183184
#define WARN_ONCE(condition, format...) \
184185
DO_ONCE_LITE_IF(condition, WARN, 1, format)
186+
#endif
185187

186188
#define WARN_TAINT_ONCE(condition, taint, format...) \
187189
DO_ONCE_LITE_IF(condition, WARN_TAINT, 1, taint, format)

0 commit comments

Comments
 (0)