2008-03-12 01:03:53

by Dave Young

[permalink] [raw]
Subject: [PATCH -mm] do not check condition twice in WARN_ON_SECS

Don't check condition twice, change WARN_ON(condition) to WARN_ON(1)
Thanks Marcin Slusarz <[email protected]> for pointing out

Signed-off-by: Dave Young <[email protected]>

---
include/asm-generic/bug.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff -upr linux/include/asm-generic/bug.h linux.new/include/asm-generic/bug.h
--- linux/include/asm-generic/bug.h 2008-03-12 08:45:08.000000000 +0800
+++ linux.new/include/asm-generic/bug.h 2008-03-12 09:04:07.000000000 +0800
@@ -80,7 +80,8 @@ extern void warn_on_slowpath(const char
int __ret_warn_on = !!(condition); \
if (unlikely(__ret_warn_on)) \
if (__ratelimit(secs * HZ, 1)) \
- WARN_ON(condition); \
+ WARN_ON(1); \
+ unlikely(__ret_warn_on); \
})

#ifdef CONFIG_SMP


2008-03-12 13:50:22

by Johannes Weiner

[permalink] [raw]
Subject: Re: [PATCH -mm] do not check condition twice in WARN_ON_SECS

Hi Dave,

Dave Young <[email protected]> writes:

> Don't check condition twice, change WARN_ON(condition) to WARN_ON(1)
> Thanks Marcin Slusarz <[email protected]> for pointing out
>
> Signed-off-by: Dave Young <[email protected]>
>
> ---
> include/asm-generic/bug.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff -upr linux/include/asm-generic/bug.h linux.new/include/asm-generic/bug.h
> --- linux/include/asm-generic/bug.h 2008-03-12 08:45:08.000000000 +0800
> +++ linux.new/include/asm-generic/bug.h 2008-03-12 09:04:07.000000000 +0800
> @@ -80,7 +80,8 @@ extern void warn_on_slowpath(const char
> int __ret_warn_on = !!(condition); \
> if (unlikely(__ret_warn_on)) \
> if (__ratelimit(secs * HZ, 1)) \
> - WARN_ON(condition); \
> + WARN_ON(1); \
> + unlikely(__ret_warn_on); \
> })

What's wrong with:

#define WARN_ON_SECS(condition, secs) \
WARN_ON(condition && __ratelimit(secs * HZ, 1))

?

Hannes

2008-03-13 00:44:58

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH -mm] do not check condition twice in WARN_ON_SECS

On Wed, Mar 12, 2008 at 9:47 PM, Johannes Weiner <[email protected]> wrote:
> Hi Dave,
>
>
>
> Dave Young <[email protected]> writes:
>
> > Don't check condition twice, change WARN_ON(condition) to WARN_ON(1)
> > Thanks Marcin Slusarz <[email protected]> for pointing out
> >
> > Signed-off-by: Dave Young <[email protected]>
> >
> > ---
> > include/asm-generic/bug.h | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff -upr linux/include/asm-generic/bug.h linux.new/include/asm-generic/bug.h
> > --- linux/include/asm-generic/bug.h 2008-03-12 08:45:08.000000000 +0800
> > +++ linux.new/include/asm-generic/bug.h 2008-03-12 09:04:07.000000000 +0800
> > @@ -80,7 +80,8 @@ extern void warn_on_slowpath(const char
> > int __ret_warn_on = !!(condition); \
> > if (unlikely(__ret_warn_on)) \
> > if (__ratelimit(secs * HZ, 1)) \
> > - WARN_ON(condition); \
> > + WARN_ON(1); \
> > + unlikely(__ret_warn_on); \
> > })
>
> What's wrong with:
>
> #define WARN_ON_SECS(condition, secs) \
> WARN_ON(condition && __ratelimit(secs * HZ, 1))

Looks concise.
Should I update the third time?

2008-03-13 04:48:26

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH -mm] do not check condition twice in WARN_ON_SECS



On Wed, 12 Mar 2008, Johannes Weiner wrote:
>
> What's wrong with:
>
> #define WARN_ON_SECS(condition, secs) \
> WARN_ON(condition && __ratelimit(secs * HZ, 1))

Add parenthesis around the arguments, please.

Linus