From: Joe Perches <joe@perches.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jason Baron <jbaron@akamai.com>,
Andrew Morton <akpm@linux-foundation.org>,
Krzysztof Mazur <krzysiek@podlesie.net>,
Felipe Balbi <balbi@ti.com>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH V2] printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
Date: Sat, 26 Oct 2013 20:41:53 -0700 [thread overview]
Message-ID: <1382845313.3238.28.camel@joe-AO722> (raw)
In-Reply-To: <20131026190151.GA26389@kroah.com>
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>
---
V2: Fix #include dependencies and typos.
Compile tested with and without CONFIG_DYNAMIC_DEBUG
It looks to me as if device.h should also have #include <dynamic_debug.h>
It currently gets the #include indirectly via kobject.h -> kernel.h.
include/linux/printk.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index e6131a78..6949258 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -233,6 +233,8 @@ extern asmlinkage void dump_stack(void) __cold;
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif
+#include <linux/dynamic_debug.h>
+
/* If you are writing a driver, please use dev_dbg instead */
#if defined(CONFIG_DYNAMIC_DEBUG)
/* 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
/* 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, ...) \
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
next prev parent reply other threads:[~2013-10-27 3:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-26 13:29 usbatm: printk_ratelimit() always called in the atm_rldbg() Krzysztof Mazur
2013-10-26 17:37 ` Greg Kroah-Hartman
2013-10-26 18:52 ` [PATCH] printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages Joe Perches
2013-10-26 19:01 ` Greg Kroah-Hartman
2013-10-26 19:51 ` Joe Perches
2013-10-27 3:41 ` Joe Perches [this message]
2013-10-27 10:33 ` [PATCH V2] " Krzysztof Mazur
2013-10-26 18:55 ` [PATCH] atmusb: Fix dynamic_debug macros Joe Perches
2013-10-26 19:28 ` Joe Perches
2013-10-26 20:02 ` Krzysztof Mazur
2013-10-27 3:49 ` [PATCH V2] usbatm: Fix dynamic_debug / ratelimited atm_dbg and atm_rldbg macros Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1382845313.3238.28.camel@joe-AO722 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=krzysiek@podlesie.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®