From: Steven Rostedt <rostedt@goodmis.org>
To: Omar Sandoval <osandov@osandov.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
linux-btrfs@vger.kernel.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Josh Triplett <josh@joshtriplett.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] Return a value from printk_ratelimited
Date: Fri, 19 Sep 2014 13:21:23 -0400 [thread overview]
Message-ID: <20140919132123.418b276f@gandalf.local.home> (raw)
In-Reply-To: <3629aa32fd3e434e41e5e5f4a97ab50adb8edcdc.1411116672.git.osandov@osandov.com>
On Fri, 19 Sep 2014 02:01:29 -0700
Omar Sandoval <osandov@osandov.com> wrote:
> printk returns an integer; there's no reason for printk_ratelimited to swallow
> it.
>
> Signed-off-by: Omar Sandoval <osandov@osandov.com>
> ---
> include/linux/printk.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index d78125f..67534bc 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -343,12 +343,14 @@ extern asmlinkage void dump_stack(void) __cold;
> #ifdef CONFIG_PRINTK
> #define printk_ratelimited(fmt, ...) \
> ({ \
> + int __ret = 0; \
My only issues is with the "__ret" name.
It's not really unique enough. If something else uses __ret and does
printk_ratelimit("some fmt string %d\n", __ret);
This will not print the right value.
printk_ratelimit can be used almost anywhere thus using a really unique
value may be worth while here.
What about:
int ______r
?
-- Steve
> static DEFINE_RATELIMIT_STATE(_rs, \
> DEFAULT_RATELIMIT_INTERVAL, \
> DEFAULT_RATELIMIT_BURST); \
> \
> if (__ratelimit(&_rs)) \
> - printk(fmt, ##__VA_ARGS__); \
> + __ret = printk(fmt, ##__VA_ARGS__); \
> + __ret; \
> })
> #else
> #define printk_ratelimited(fmt, ...) \
next prev parent reply other threads:[~2014-09-19 17:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-19 9:01 [PATCH v2 0/2] Move BTRFS RCU string to common library Omar Sandoval
2014-09-19 9:01 ` [PATCH v2 1/2] Return a value from printk_ratelimited Omar Sandoval
2014-09-19 17:21 ` Steven Rostedt [this message]
2014-09-19 18:15 ` Joe Perches
2014-09-21 13:25 ` Paul E. McKenney
2014-09-21 15:53 ` Joe Perches
2014-09-19 9:01 ` [PATCH v2 2/2] Move BTRFS RCU string to common library Omar Sandoval
2014-09-26 23:25 ` josh
2014-09-19 15:45 ` [PATCH v2 0/2] " Paul E. McKenney
2014-09-19 15:47 ` Chris Mason
2014-09-19 16:05 ` Paul E. McKenney
2014-09-19 16:22 ` Chris Mason
2014-09-21 13:25 ` Paul E. McKenney
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=20140919132123.418b276f@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=clm@fb.com \
--cc=jbacik@fb.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=osandov@osandov.com \
--cc=paulmck@linux.vnet.ibm.com \
/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).