Patchwork sparc: use __ratelimit

login
register
mail settings
Submitter Akinobu Mita
Date Feb. 28, 2010, 10:58 a.m.
Message ID <1267354697-6456-5-git-send-email-akinobu.mita@gmail.com>
Download mbox | patch
Permalink /patch/46490/
State Accepted
Delegated to: David Miller
Headers show

Comments

Akinobu Mita - Feb. 28, 2010, 10:58 a.m.
Replace open-coded rate limiting logic with __ratelimit().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
---
 arch/sparc/kernel/unaligned_64.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
David Miller - Feb. 28, 2010, 11:31 a.m.
From: Akinobu Mita <akinobu.mita@gmail.com>
Date: Sun, 28 Feb 2010 19:58:17 +0900

> Replace open-coded rate limiting logic with __ratelimit().
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
index 378ca82..f03641f 100644
--- a/arch/sparc/kernel/unaligned_64.c
+++ b/arch/sparc/kernel/unaligned_64.c
@@ -21,6 +21,7 @@ 
 #include <linux/smp.h>
 #include <linux/bitops.h>
 #include <linux/perf_event.h>
+#include <linux/ratelimit.h>
 #include <asm/fpumacro.h>
 
 enum direction {
@@ -274,13 +275,9 @@  static void kernel_mna_trap_fault(int fixup_tstate_asi)
 
 static void log_unaligned(struct pt_regs *regs)
 {
-	static unsigned long count, last_time;
+	static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
 
-	if (time_after(jiffies, last_time + 5 * HZ))
-		count = 0;
-	if (count < 5) {
-		last_time = jiffies;
-		count++;
+	if (__ratelimit(&ratelimit)) {
 		printk("Kernel unaligned access at TPC[%lx] %pS\n",
 		       regs->tpc, (void *) regs->tpc);
 	}