lkml.org 
[lkml]   [2012]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ratelimit: check the condition in WARN_RATELIMIT first
Date
Before calling __ratelimit in __WARN_RATELIMIT, check the condition
first. When this check was not there, we got constant income of:
tty_init_dev: 60 callbacks suppressed
tty_init_dev: 59 callbacks suppressed

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Joe Perches <joe@perches.com>
---
include/linux/ratelimit.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
index e11ccb4..966d35c 100644
--- a/include/linux/ratelimit.h
+++ b/include/linux/ratelimit.h
@@ -49,8 +49,9 @@ extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
#define __WARN_RATELIMIT(condition, state, format...) \
({ \
int rtn = 0; \
- if (unlikely(__ratelimit(state))) \
- rtn = WARN(condition, format); \
+ int __rtcond = !!condition; \
+ if (unlikely(__rtcond && __ratelimit(state))) \
+ rtn = WARN(__rtcond, format); \
rtn; \
})

--
1.7.11.5



\
 
 \ /
  Last update: 2012-08-17 16:21    [W:0.043 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site