parisc: use __ratelimit in unaligned.c
Replace open-coded rate limiting logic with __ratelimit(). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
This commit is contained in:
committed by
Kyle McMartin
parent
c60185248f
commit
6ee77658ce
@@ -25,6 +25,7 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/signal.h>
|
#include <linux/signal.h>
|
||||||
|
#include <linux/ratelimit.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
|
|
||||||
/* #define DEBUG_UNALIGNED 1 */
|
/* #define DEBUG_UNALIGNED 1 */
|
||||||
@@ -446,8 +447,7 @@ static int emulate_std(struct pt_regs *regs, int frreg, int flop)
|
|||||||
|
|
||||||
void handle_unaligned(struct pt_regs *regs)
|
void handle_unaligned(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
static unsigned long unaligned_count = 0;
|
static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
|
||||||
static unsigned long last_time = 0;
|
|
||||||
unsigned long newbase = R1(regs->iir)?regs->gr[R1(regs->iir)]:0;
|
unsigned long newbase = R1(regs->iir)?regs->gr[R1(regs->iir)]:0;
|
||||||
int modify = 0;
|
int modify = 0;
|
||||||
int ret = ERR_NOTHANDLED;
|
int ret = ERR_NOTHANDLED;
|
||||||
@@ -460,14 +460,8 @@ void handle_unaligned(struct pt_regs *regs)
|
|||||||
goto force_sigbus;
|
goto force_sigbus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unaligned_count > 5 &&
|
if (!(current->thread.flags & PARISC_UAC_NOPRINT) &&
|
||||||
time_after(jiffies, last_time + 5 * HZ)) {
|
__ratelimit(&ratelimit)) {
|
||||||
unaligned_count = 0;
|
|
||||||
last_time = jiffies;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(current->thread.flags & PARISC_UAC_NOPRINT)
|
|
||||||
&& ++unaligned_count < 5) {
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
sprintf(buf, "%s(%d): unaligned access to 0x" RFMT " at ip=0x" RFMT "\n",
|
sprintf(buf, "%s(%d): unaligned access to 0x" RFMT " at ip=0x" RFMT "\n",
|
||||||
current->comm, task_pid_nr(current), regs->ior, regs->iaoq[0]);
|
current->comm, task_pid_nr(current), regs->ior, regs->iaoq[0]);
|
||||||
|
Reference in New Issue
Block a user