mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
pr_debug_ratelimited should be coded similarly to dev_dbg_ratelimited to reduce the "callbacks suppressed" messages. Add #include <linux/dynamic_debug.h> to printk.h. Unfortunately, this new #include must be after the prototype/declaration of function printk. It may be better to split out these _ratelimited declarations into a separate file one day. Any use of these pr_<foo>_ratelimited functions must also have another specific #include <ratelimited.h>. Most users have this done indirectly via #include <linux/kernel.h> printk.h may not #include <linux/ratelimit.h> as it causes circular dependencies and compilation failures. Signed-off-by: Joe Perches <joe@perches.com> Tested-by: Krzysztof Mazur <krzysiek@podlesie.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9d3bd76846
commit
29fc2bc753
@ -233,6 +233,8 @@ extern asmlinkage void dump_stack(void) __cold;
|
|||||||
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <linux/dynamic_debug.h>
|
||||||
|
|
||||||
/* If you are writing a driver, please use dev_dbg instead */
|
/* If you are writing a driver, please use dev_dbg instead */
|
||||||
#if defined(CONFIG_DYNAMIC_DEBUG)
|
#if defined(CONFIG_DYNAMIC_DEBUG)
|
||||||
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
|
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
|
||||||
@ -343,7 +345,19 @@ extern asmlinkage void dump_stack(void) __cold;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If you are writing a driver, please use dev_dbg instead */
|
/* If you are writing a driver, please use dev_dbg instead */
|
||||||
#if defined(DEBUG)
|
#if defined(CONFIG_DYNAMIC_DEBUG)
|
||||||
|
/* descriptor check is first to prevent flooding with "callbacks suppressed" */
|
||||||
|
#define pr_debug_ratelimited(fmt, ...) \
|
||||||
|
do { \
|
||||||
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||||
|
DEFAULT_RATELIMIT_INTERVAL, \
|
||||||
|
DEFAULT_RATELIMIT_BURST); \
|
||||||
|
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
|
||||||
|
if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
|
||||||
|
__ratelimit(&_rs)) \
|
||||||
|
__dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
#elif defined(DEBUG)
|
||||||
#define pr_debug_ratelimited(fmt, ...) \
|
#define pr_debug_ratelimited(fmt, ...) \
|
||||||
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user