From: David Miller <davem@davemloft.net>
To: Jason@zx2c4.com
Cc: akpm@linux-foundation.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, joe@perches.com
Subject: Re: [PATCH v3] net_dbg_ratelimited: turn into no-op when !DEBUG
Date: Thu, 06 Aug 2015 23:51:45 -0700 (PDT) [thread overview]
Message-ID: <20150806.235145.838510256404062404.davem@davemloft.net> (raw)
In-Reply-To: <1438705579-18461-1-git-send-email-Jason@zx2c4.com>
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.
prev parent reply other threads:[~2015-08-07 6:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 3:26 [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG Jason A. Donenfeld
2015-08-04 3:57 ` Joe Perches
2015-08-04 4:02 ` Joe Perches
2015-08-04 4:59 ` David Miller
2015-08-04 15:07 ` Jason A. Donenfeld
2015-08-04 15:08 ` Jason A. Donenfeld
2015-08-04 15:51 ` Joe Perches
2015-08-04 16:26 ` [PATCH v3] " Jason A. Donenfeld
2015-08-07 6:51 ` David Miller [this message]
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=20150806.235145.838510256404062404.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).