aboutsummaryrefslogtreecommitdiff
path: root/Documentation/CodingStyle
diff options
context:
space:
mode:
authorJaewon Kim <jaewon31.kim@samsung.com>2016-01-21 16:55:07 -0800
committerMister Oyster <oysterized@gmail.com>2017-04-11 10:58:51 +0200
commit2b8187943cf3627489c32d78ed2a8855744d8843 (patch)
treea4c456a8fc14b407f7dc2e2ca1dc05b45125e8a3 /Documentation/CodingStyle
parent2400c09c53ef59259cfc30bbb074e590a030b845 (diff)
ratelimit: fix bug in time interval by resetting right begin time
commit c2594bc37f4464bc74f2c119eb3269a643400aa0 upstream. rs->begin in ratelimit is set in two cases. 1) when rs->begin was not initialized 2) when rs->interval was passed For case #2, current ratelimit sets the begin to 0. This incurrs improper suppression. The begin value will be set in the next ratelimit call by 1). Then the time interval check will be always false, and rs->printed will not be initialized. Although enough time passed, ratelimit may return 0 if rs->printed is not less than rs->burst. To reset interval properly, begin should be jiffies rather than 0. For an example code below: static DEFINE_RATELIMIT_STATE(mylimit, 1, 1); for (i = 1; i <= 10; i++) { if (__ratelimit(&mylimit)) printk("ratelimit test count %d\n", i); msleep(3000); } test result in the current code shows suppression even there is 3 seconds sleep. [ 78.391148] ratelimit test count 1 [ 81.295988] ratelimit test count 2 [ 87.315981] ratelimit test count 4 [ 93.336267] ratelimit test count 6 [ 99.356031] ratelimit test count 8 [ 105.376367] ratelimit test count 10 Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'Documentation/CodingStyle')
0 files changed, 0 insertions, 0 deletions