aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2008-04-29 03:59:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:06 -0400
commit5f97a5a8799b8d7d0afdb9d68a50a4e0e8298a05 (patch)
tree03f0a35e50e9a765603fc9249e601b52e043fd0d /kernel
parent762873c251b056c6c1b29e83a4dabafb064e5421 (diff)
isolate ratelimit from printk.c for other use
Due to the rcupreempt.h WARN_ON trigged, I got 2G syslog file. For some serious complaining of kernel, we need repeat the warnings, so here I isolate the ratelimit part of printk.c to a standalone file. Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index bdd4ea8c3f2b..d3f9c0f788bf 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1287,31 +1287,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
1287 */ 1287 */
1288int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) 1288int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst)
1289{ 1289{
1290 static DEFINE_SPINLOCK(ratelimit_lock); 1290 return __ratelimit(ratelimit_jiffies, ratelimit_burst);
1291 static unsigned toks = 10 * 5 * HZ;
1292 static unsigned long last_msg;
1293 static int missed;
1294 unsigned long flags;
1295 unsigned long now = jiffies;
1296
1297 spin_lock_irqsave(&ratelimit_lock, flags);
1298 toks += now - last_msg;
1299 last_msg = now;
1300 if (toks > (ratelimit_burst * ratelimit_jiffies))
1301 toks = ratelimit_burst * ratelimit_jiffies;
1302 if (toks >= ratelimit_jiffies) {
1303 int lost = missed;
1304
1305 missed = 0;
1306 toks -= ratelimit_jiffies;
1307 spin_unlock_irqrestore(&ratelimit_lock, flags);
1308 if (lost)
1309 printk(KERN_WARNING "printk: %d messages suppressed.\n", lost);
1310 return 1;
1311 }
1312 missed++;
1313 spin_unlock_irqrestore(&ratelimit_lock, flags);
1314 return 0;
1315} 1291}
1316EXPORT_SYMBOL(__printk_ratelimit); 1292EXPORT_SYMBOL(__printk_ratelimit);
1317 1293