mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ameen <ameenali023@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Ameen <AmeenAli023@gmail.com>
Subject: [PATCH] Update ratelimit.c
Date: Wed, 25 Nov 2015 20:52:15 +0200	[thread overview]
Message-ID: <1448477535-5255-1-git-send-email-AmeenAli023@gmail.com> (raw)

fix a bug in ratelimit, if the "begin" doesn't update at the same time with printed
the print will start from 1 in loops except for the first time,
lets to only 9 logs suppressed, but not 10 as expected.

Signed-off-by : Ameen Ali <AmeenAli023@gmail.com>
---
 lib/ratelimit.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 40e03ea..7118ea7 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -42,14 +42,12 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
 	if (!raw_spin_trylock_irqsave(&rs->lock, flags))
 		return 0;
 
-	if (!rs->begin)
-		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   = 0;
+		rs->begin   = jiffies;
 		rs->printed = 0;
 		rs->missed  = 0;
 	}
-- 
2.5.0


                 reply	other threads:[~2015-11-25 18:52 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=1448477535-5255-1-git-send-email-AmeenAli023@gmail.com \
    --to=ameenali023@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®