Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311677 > unrolled thread

[RFC] ratelimit: fix time interval by setting right start time

Started byJaewon Kim <jaewon31.kim@gmail.com>
First post2016-01-18 18:00 +0100
Last post2016-01-18 18:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [RFC] ratelimit: fix time interval by setting right start time Jaewon Kim <jaewon31.kim@gmail.com> - 2016-01-18 18:00 +0100

#1311677 — [RFC] ratelimit: fix time interval by setting right start time

FromJaewon Kim <jaewon31.kim@gmail.com>
Date2016-01-18 18:00 +0100
Subject[RFC] ratelimit: fix time interval by setting right start time
Message-ID<qSljT-3pb-57@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web