alpha: use __ratelimit

Replace open-coded rate limiting logic with __ratelimit().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: linux-alpha@vger.kernel.org
Signed-off-by: Matt Turner <mattst88@gmail.com>

authored by Akinobu Mita and committed by Matt Turner 2a238a96 39710479

+3 -7
+3 -7
arch/alpha/kernel/traps.c
··· 17 #include <linux/module.h> 18 #include <linux/init.h> 19 #include <linux/kallsyms.h> 20 21 #include <asm/gentrap.h> 22 #include <asm/uaccess.h> ··· 772 do_entUnaUser(void __user * va, unsigned long opcode, 773 unsigned long reg, struct pt_regs *regs) 774 { 775 - static int cnt = 0; 776 - static unsigned long last_time; 777 778 unsigned long tmp1, tmp2, tmp3, tmp4; 779 unsigned long fake_reg, *reg_addr = &fake_reg; ··· 783 with the unaliged access. */ 784 785 if (!test_thread_flag (TIF_UAC_NOPRINT)) { 786 - if (cnt >= 5 && time_after(jiffies, last_time + 5 * HZ)) { 787 - cnt = 0; 788 - } 789 - if (++cnt < 5) { 790 printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n", 791 current->comm, task_pid_nr(current), 792 regs->pc - 4, va, opcode, reg); 793 } 794 - last_time = jiffies; 795 } 796 if (test_thread_flag (TIF_UAC_SIGBUS)) 797 goto give_sigbus;
··· 17 #include <linux/module.h> 18 #include <linux/init.h> 19 #include <linux/kallsyms.h> 20 + #include <linux/ratelimit.h> 21 22 #include <asm/gentrap.h> 23 #include <asm/uaccess.h> ··· 771 do_entUnaUser(void __user * va, unsigned long opcode, 772 unsigned long reg, struct pt_regs *regs) 773 { 774 + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5); 775 776 unsigned long tmp1, tmp2, tmp3, tmp4; 777 unsigned long fake_reg, *reg_addr = &fake_reg; ··· 783 with the unaliged access. */ 784 785 if (!test_thread_flag (TIF_UAC_NOPRINT)) { 786 + if (__ratelimit(&ratelimit)) { 787 printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n", 788 current->comm, task_pid_nr(current), 789 regs->pc - 4, va, opcode, reg); 790 } 791 } 792 if (test_thread_flag (TIF_UAC_SIGBUS)) 793 goto give_sigbus;