once: implement DO_ONCE_LITE for non-fast-path "do once" functionality
Certain uses of "do once" functionality reside outside of fast path,
and so do not require jump label patching via static keys, making
existing DO_ONCE undesirable in such cases.
Replace uses of __section(".data.once") with DO_ONCE_LITE(_IF)?
This patch changes the return values of xfs_printk_once, printk_once,
and printk_deferred_once. Before, they returned whether the print was
performed, but now, they always return true. This is okay because the
return values of the following macros are entirely ignored throughout
the kernel:
- xfs_printk_once
- xfs_warn_once
- xfs_notice_once
- xfs_info_once
- printk_once
- pr_emerg_once
- pr_alert_once
- pr_crit_once
- pr_err_once
- pr_warn_once
- pr_notice_once
- pr_info_once
- pr_devel_once
- pr_debug_once
- printk_deferred_once
- orc_warn
Changes
v3:
- Expand commit message to explain why changing return values of
xfs_printk_once, printk_once, printk_deferred_once is benign
v2:
- Fix i386 build warnings
Signed-off-by: Tanner Love <tannerlove@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Acked-by: Mahesh Bandewar <maheshb@google.com>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b74ef9f9cb
commit
a358f40600
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/instrumentation.h>
|
||||
#include <linux/once_lite.h>
|
||||
|
||||
#define CUT_HERE "------------[ cut here ]------------\n"
|
||||
|
||||
@@ -140,39 +141,15 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
|
||||
})
|
||||
|
||||
#ifndef WARN_ON_ONCE
|
||||
#define WARN_ON_ONCE(condition) ({ \
|
||||
static bool __section(".data.once") __warned; \
|
||||
int __ret_warn_once = !!(condition); \
|
||||
\
|
||||
if (unlikely(__ret_warn_once && !__warned)) { \
|
||||
__warned = true; \
|
||||
WARN_ON(1); \
|
||||
} \
|
||||
unlikely(__ret_warn_once); \
|
||||
})
|
||||
#define WARN_ON_ONCE(condition) \
|
||||
DO_ONCE_LITE_IF(condition, WARN_ON, 1)
|
||||
#endif
|
||||
|
||||
#define WARN_ONCE(condition, format...) ({ \
|
||||
static bool __section(".data.once") __warned; \
|
||||
int __ret_warn_once = !!(condition); \
|
||||
\
|
||||
if (unlikely(__ret_warn_once && !__warned)) { \
|
||||
__warned = true; \
|
||||
WARN(1, format); \
|
||||
} \
|
||||
unlikely(__ret_warn_once); \
|
||||
})
|
||||
#define WARN_ONCE(condition, format...) \
|
||||
DO_ONCE_LITE_IF(condition, WARN, 1, format)
|
||||
|
||||
#define WARN_TAINT_ONCE(condition, taint, format...) ({ \
|
||||
static bool __section(".data.once") __warned; \
|
||||
int __ret_warn_once = !!(condition); \
|
||||
\
|
||||
if (unlikely(__ret_warn_once && !__warned)) { \
|
||||
__warned = true; \
|
||||
WARN_TAINT(1, taint, format); \
|
||||
} \
|
||||
unlikely(__ret_warn_once); \
|
||||
})
|
||||
#define WARN_TAINT_ONCE(condition, taint, format...) \
|
||||
DO_ONCE_LITE_IF(condition, WARN_TAINT, 1, taint, format)
|
||||
|
||||
#else /* !CONFIG_BUG */
|
||||
#ifndef HAVE_ARCH_BUG
|
||||
|
||||
Reference in New Issue
Block a user