From: Akinobu Mita Date: Mon, 1 Mar 2010 18:25:49 +0000 (-0500) Subject: alpha: use __ratelimit X-Git-Tag: v3.0~5390^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a238a96358dde09aa52de9b9f97a383165ca651;p=platform%2Fkernel%2Flinux-amlogic.git alpha: use __ratelimit Replace open-coded rate limiting logic with __ratelimit(). Signed-off-by: Akinobu Mita Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: linux-alpha@vger.kernel.org Signed-off-by: Matt Turner --- diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index 6ee7655..b14f015 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -771,8 +772,7 @@ asmlinkage void do_entUnaUser(void __user * va, unsigned long opcode, unsigned long reg, struct pt_regs *regs) { - static int cnt = 0; - static unsigned long last_time; + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5); unsigned long tmp1, tmp2, tmp3, tmp4; unsigned long fake_reg, *reg_addr = &fake_reg; @@ -783,15 +783,11 @@ do_entUnaUser(void __user * va, unsigned long opcode, with the unaliged access. */ if (!test_thread_flag (TIF_UAC_NOPRINT)) { - if (cnt >= 5 && time_after(jiffies, last_time + 5 * HZ)) { - cnt = 0; - } - if (++cnt < 5) { + if (__ratelimit(&ratelimit)) { printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n", current->comm, task_pid_nr(current), regs->pc - 4, va, opcode, reg); } - last_time = jiffies; } if (test_thread_flag (TIF_UAC_SIGBUS)) goto give_sigbus;