netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Implement net_dbg_ratelimited() for CONFIG_DYNAMIC_DEBUG case
@ 2016-04-29 17:30 Tim Bingham
  2016-05-02  1:49 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Bingham @ 2016-04-29 17:30 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: Jason A. Donenfeld, Tim Bingham

Prior to commit d92cff89a0c8 ("net_dbg_ratelimited: turn into no-op
when !DEBUG") the implementation of net_dbg_ratelimited() was buggy
for both the DEBUG and CONFIG_DYNAMIC_DEBUG cases.

The bug was that net_ratelimit() was being called and, despite
returning true, nothing was being printed to the console. This
resulted in messages like the following -

"net_ratelimit: %d callbacks suppressed"

with no other output nearby.

After commit d92cff89a0c8 ("net_dbg_ratelimited: turn into no-op when
!DEBUG") the bug is fixed for the DEBUG case. However, there's no
output at all for CONFIG_DYNAMIC_DEBUG case.

This patch restores debug output (if enabled) for the
CONFIG_DYNAMIC_DEBUG case.

Add a definition of net_dbg_ratelimited() for the CONFIG_DYNAMIC_DEBUG
case. The implementation takes care to check that dynamic debugging is
enabled before calling net_ratelimit().

Fixes: d92cff89a0c8 ("net_dbg_ratelimited: turn into no-op when !DEBUG")
Signed-off-by: Tim Bingham <tbingham@akamai.com>
---
 include/linux/net.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index 49175e4..f840d77 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -246,7 +246,15 @@ do {								\
 	net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
 #define net_info_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
-#if defined(DEBUG)
+#if defined(CONFIG_DYNAMIC_DEBUG)
+#define net_dbg_ratelimited(fmt, ...)					\
+do {									\
+	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
+	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
+	    net_ratelimit())						\
+		__dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__);	\
+} while (0)
+#elif defined(DEBUG)
 #define net_dbg_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
 #else
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: Implement net_dbg_ratelimited() for CONFIG_DYNAMIC_DEBUG case
  2016-04-29 17:30 [PATCH] net: Implement net_dbg_ratelimited() for CONFIG_DYNAMIC_DEBUG case Tim Bingham
@ 2016-05-02  1:49 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-05-02  1:49 UTC (permalink / raw)
  To: tbingham; +Cc: netdev, Jason

From: Tim Bingham <tbingham@akamai.com>
Date: Fri, 29 Apr 2016 13:30:23 -0400

> Prior to commit d92cff89a0c8 ("net_dbg_ratelimited: turn into no-op
> when !DEBUG") the implementation of net_dbg_ratelimited() was buggy
> for both the DEBUG and CONFIG_DYNAMIC_DEBUG cases.
> 
> The bug was that net_ratelimit() was being called and, despite
> returning true, nothing was being printed to the console. This
> resulted in messages like the following -
> 
> "net_ratelimit: %d callbacks suppressed"
> 
> with no other output nearby.
> 
> After commit d92cff89a0c8 ("net_dbg_ratelimited: turn into no-op when
> !DEBUG") the bug is fixed for the DEBUG case. However, there's no
> output at all for CONFIG_DYNAMIC_DEBUG case.
> 
> This patch restores debug output (if enabled) for the
> CONFIG_DYNAMIC_DEBUG case.
> 
> Add a definition of net_dbg_ratelimited() for the CONFIG_DYNAMIC_DEBUG
> case. The implementation takes care to check that dynamic debugging is
> enabled before calling net_ratelimit().
> 
> Fixes: d92cff89a0c8 ("net_dbg_ratelimited: turn into no-op when !DEBUG")
> Signed-off-by: Tim Bingham <tbingham@akamai.com>

Looks good, applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-02  1:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-29 17:30 [PATCH] net: Implement net_dbg_ratelimited() for CONFIG_DYNAMIC_DEBUG case Tim Bingham
2016-05-02  1:49 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).