Skip to content

Commit

Permalink
alpha: use __ratelimit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Akinobu Mita authored and Matt Turner committed Mar 19, 2010
1 parent 3971047 commit 2a238a9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions arch/alpha/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kallsyms.h>
#include <linux/ratelimit.h>

#include <asm/gentrap.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 2a238a9

Please sign in to comment.