mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaewon Kim <jaewon31.kim@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Jaewon Kim <jaewon31.kim@gmail.com>
Subject: [RFC] ratelimit: fix time interval by setting right start time
Date: Tue, 19 Jan 2016 01:53:15 +0900	[thread overview]
Message-ID: <1453135995-27374-1-git-send-email-jaewon31.kim@gmail.com> (raw)

rs->begin should be initialized to the current jiffies if the begin was 0.
Even when the time interval passes, the current resetting logic sets the begin
back to 0. So next interval starts from the next call rather than from the
current resetting call. This incurrs improper suppression.

For example:
B will be suppressed althouth 3 seconds passed.
	DEFINE_RATELIMIT_STATE(limit, HZ, 1);
	__ratelimit(&limit); /* A */
	sleep(3);
	__ratelimit(&limit); /* B */

Signed-off-by: Jaewon Kim <jaewon31.kim@gmail.com>
---
 lib/ratelimit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 40e03ea..2c5de86 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -49,7 +49,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
 		if (rs->missed)
 			printk(KERN_WARNING "%s: %d callbacks suppressed\n",
 				func, rs->missed);
-		rs->begin   = 0;
+		rs->begin   = jiffies;
 		rs->printed = 0;
 		rs->missed  = 0;
 	}
-- 
1.9.1

                 reply	other threads:[~2016-01-18 16:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453135995-27374-1-git-send-email-jaewon31.kim@gmail.com \
    --to=jaewon31.kim@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®