Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1202321
| From | David Miller <davem@davemloft.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3] net_dbg_ratelimited: turn into no-op when !DEBUG |
| Date | 2015-08-07 09:00 +0200 |
| Message-ID | <pUJNg-6G-5@gated-at.bofh.it> (permalink) |
| References | <pTMNd-6DQ-15@gated-at.bofh.it> <pTNgd-7qY-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: Tue, 4 Aug 2015 18:26:19 +0200 > The pr_debug family of functions turns into a no-op when -DDEBUG is not > specified, opting instead to call "no_printk", which gets compiled to a > no-op (but retains gcc's nice warnings about printf-style arguments). > > The problem with net_dbg_ratelimited is that it is defined to be a > variant of net_ratelimited_function, which expands to essentially: > > if (net_ratelimit()) > pr_debug(fmt, ...); > > When DEBUG is not defined, then this becomes, > > if (net_ratelimit()) > ; > > This seems benign, except it isn't. Firstly, there's the obvious > overhead of calling net_ratelimit needlessly, which does quite some book > keeping for the rate limiting. Given that the pr_debug and > net_dbg_ratelimited family of functions are sprinkled liberally through > performance critical code, with developers assuming they'll be compiled > out to a no-op most of the time, we certainly do not want this needless > book keeping. Secondly, and most visibly, even though no debug message > is printed when DEBUG is not defined, if there is a flood of > invocations, dmesg winds up peppered with messages such as > "net_ratelimit: 320 callbacks suppressed". This is because our > aforementioned net_ratelimit() function actually prints this text in > some circumstances. It's especially odd to see this when there isn't any > other accompanying debug message. > > So, in sum, it doesn't make sense to have this function's current > behavior, and instead it should match what every other debug family of > functions in the kernel does with !DEBUG -- nothing. > > This patch replaces calls to net_dbg_ratelimited when !DEBUG with > no_printk, keeping with the idiom of all the other debug print helpers. > > Also, though not strictly neccessary, it guards the call with an if (0) > so that all evaluation of any arguments are sure to be compiled out. > > Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Applied to net-next, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-08-04 17:10 +0200
Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG Joe Perches <joe@perches.com> - 2015-08-04 18:00 +0200
[PATCH v3] net_dbg_ratelimited: turn into no-op when !DEBUG "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-08-04 18:30 +0200
Re: [PATCH v3] net_dbg_ratelimited: turn into no-op when !DEBUG David Miller <davem@davemloft.net> - 2015-08-07 09:00 +0200
csiph-web