mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Dave Young <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
2711b793eb
commit
717115e1a5
10 changed files with 79 additions and 56 deletions
|
|
@ -1308,6 +1308,8 @@ void tty_write_message(struct tty_struct *tty, char *msg)
|
|||
}
|
||||
|
||||
#if defined CONFIG_PRINTK
|
||||
|
||||
DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10);
|
||||
/*
|
||||
* printk rate limiting, lifted from the networking subsystem.
|
||||
*
|
||||
|
|
@ -1315,22 +1317,9 @@ void tty_write_message(struct tty_struct *tty, char *msg)
|
|||
* every printk_ratelimit_jiffies to make a denial-of-service
|
||||
* attack impossible.
|
||||
*/
|
||||
int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst)
|
||||
{
|
||||
return __ratelimit(ratelimit_jiffies, ratelimit_burst);
|
||||
}
|
||||
EXPORT_SYMBOL(__printk_ratelimit);
|
||||
|
||||
/* minimum time in jiffies between messages */
|
||||
int printk_ratelimit_jiffies = 5 * HZ;
|
||||
|
||||
/* number of messages we send before ratelimiting */
|
||||
int printk_ratelimit_burst = 10;
|
||||
|
||||
int printk_ratelimit(void)
|
||||
{
|
||||
return __printk_ratelimit(printk_ratelimit_jiffies,
|
||||
printk_ratelimit_burst);
|
||||
return __ratelimit(&printk_ratelimit_state);
|
||||
}
|
||||
EXPORT_SYMBOL(printk_ratelimit);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue