Re: [PATCH -v3.1 1/2] ratelimit: Extend to print suppressed messages on release
From: Steven Rostedt
Date: Wed Jul 06 2016 - 09:40:42 EST
On Wed, 6 Jul 2016 15:28:00 +0200
Borislav Petkov <bp@xxxxxxxxx> wrote:
> extern struct ratelimit_state printk_ratelimit_state;
> diff --git a/lib/ratelimit.c b/lib/ratelimit.c
> index 2c5de86460c5..734cba5c8842 100644
> --- a/lib/ratelimit.c
> +++ b/lib/ratelimit.c
> @@ -46,12 +46,15 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
> rs->begin = jiffies;
>
> if (time_is_before_jiffies(rs->begin + rs->interval)) {
> - if (rs->missed)
> - printk(KERN_WARNING "%s: %d callbacks suppressed\n",
> - func, rs->missed);
> - rs->begin = jiffies;
> - rs->printed = 0;
> - rs->missed = 0;
> + if (rs->missed) {
> + if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
> + pr_warn("%s: %d callbacks suppressed\n", func, rs->missed);
> + rs->missed = 0;
> + }
> +
> + rs->begin = jiffies;
> + rs->printed = 0;
> + }
Hmm, the above changes the previous logic. That seems wrong.
Before:
if (rs->missed)
[...]
rs->begin = jiffies;
rs->printed = 0;
after:
if (rs->missed) {
rs->begin = jiffies;
rs->printed = 0;
}
I think you wanted:
if (rs->missed) {
if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
[..]
rs->missed = 0;
}
}
rs->begin = jiffies;
rs->printed = 0;
-- Steve
> }
> if (rs->burst && rs->burst > rs->printed) {
> rs->printed++;