diff options
author | Dave Young <hidave.darkstar@gmail.com> | 2008-07-25 04:45:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:29 -0400 |
commit | 717115e1a5856b57af0f71e1df7149108294fc10 (patch) | |
tree | 9528a992245c2fb993a0cf0bc8221dc7dea5d259 /kernel/printk.c | |
parent | 2711b793eb62a5873a0ba583a69252040aef176e (diff) |
printk ratelimiting rewrite
All ratelimit user use same jiffies and burst params, so some messages
(callbacks) will be lost.
For example:
a call printk_ratelimit(5 * HZ, 1)
b call printk_ratelimit(5 * HZ, 1) before the 5*HZ timeout of a, then b will
will be supressed.
- rewrite __ratelimit, and use a ratelimit_state as parameter. Thanks for
hints from andrew.
- Add WARN_ON_RATELIMIT, update rcupreempt.h
- remove __printk_ratelimit
- use __ratelimit in net_ratelimit
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk.c')
-rw-r--r-- | kernel/printk.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 3f7a2a94583b..a7f7559c5f6c 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -1308,6 +1308,8 @@ void tty_write_message(struct tty_struct *tty, char *msg) | |||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | #if defined CONFIG_PRINTK | 1310 | #if defined CONFIG_PRINTK |
1311 | |||
1312 | DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10); | ||
1311 | /* | 1313 | /* |
1312 | * printk rate limiting, lifted from the networking subsystem. | 1314 | * printk rate limiting, lifted from the networking subsystem. |
1313 | * | 1315 | * |
@@ -1315,22 +1317,9 @@ void tty_write_message(struct tty_struct *tty, char *msg) | |||
1315 | * every printk_ratelimit_jiffies to make a denial-of-service | 1317 | * every printk_ratelimit_jiffies to make a denial-of-service |
1316 | * attack impossible. | 1318 | * attack impossible. |
1317 | */ | 1319 | */ |
1318 | int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) | ||
1319 | { | ||
1320 | return __ratelimit(ratelimit_jiffies, ratelimit_burst); | ||
1321 | } | ||
1322 | EXPORT_SYMBOL(__printk_ratelimit); | ||
1323 | |||
1324 | /* minimum time in jiffies between messages */ | ||
1325 | int printk_ratelimit_jiffies = 5 * HZ; | ||
1326 | |||
1327 | /* number of messages we send before ratelimiting */ | ||
1328 | int printk_ratelimit_burst = 10; | ||
1329 | |||
1330 | int printk_ratelimit(void) | 1320 | int printk_ratelimit(void) |
1331 | { | 1321 | { |
1332 | return __printk_ratelimit(printk_ratelimit_jiffies, | 1322 | return __ratelimit(&printk_ratelimit_state); |
1333 | printk_ratelimit_burst); | ||
1334 | } | 1323 | } |
1335 | EXPORT_SYMBOL(printk_ratelimit); | 1324 | EXPORT_SYMBOL(printk_ratelimit); |
1336 | 1325 | ||