Message ID | 3629aa32fd3e434e41e5e5f4a97ab50adb8edcdc.1411116672.git.osandov@osandov.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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, ...) \ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 2014-09-19 at 13:21 -0400, Steven Rostedt wrote: > 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. Except for the lack of usefulness of the return value itself. See: https://lkml.org/lkml/2009/10/7/275 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Sep 19, 2014 at 11:15:53AM -0700, Joe Perches wrote: > On Fri, 2014-09-19 at 13:21 -0400, Steven Rostedt wrote: > > 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. > > Except for the lack of usefulness of the return value itself. > See: https://lkml.org/lkml/2009/10/7/275 When printk()'s return value is changed to void, then yes, we should clearly change this code to match that. So, I have to ask... What happened to the patch later in that series that was to remove the uses of the printk() return value? Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sun, 2014-09-21 at 06:25 -0700, Paul E. McKenney wrote: > On Fri, Sep 19, 2014 at 11:15:53AM -0700, Joe Perches wrote: > > On Fri, 2014-09-19 at 13:21 -0400, Steven Rostedt wrote: > > > 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. > > > > Except for the lack of usefulness of the return value itself. > > See: https://lkml.org/lkml/2009/10/7/275 > > When printk()'s return value is changed to void, then yes, we should > clearly change this code to match that. > > So, I have to ask... What happened to the patch later in that series > that was to remove the uses of the printk() return value? I don't know. Last I recall via searching emails, Alan Jenkins was going to do something with it. (I've added his old email to this reply, but I doubt still works) I remember checking whether or not the removing the return value reduced the code size on x86 (it did not), and forgot about it. I don't know if removing the printk return value reduces overall image size in any arch, so I didn't pursue it. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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; \ 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, ...) \
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(-)