Commit 7683a3f9 authored by Akinobu Mita's avatar Akinobu Mita Committed by Tony Luck

[IA64] use __ratelimit

Replace open-coded rate limiting logic with __ratelimit().
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 552dce3a
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/threads.h> #include <linux/threads.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/ratelimit.h>
#include <asm/delay.h> #include <asm/delay.h>
#include <asm/intrinsics.h> #include <asm/intrinsics.h>
...@@ -467,13 +468,9 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs) ...@@ -467,13 +468,9 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
sp = ia64_getreg(_IA64_REG_SP); sp = ia64_getreg(_IA64_REG_SP);
if ((sp - bsp) < 1024) { if ((sp - bsp) < 1024) {
static unsigned char count; static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
static long last_time;
if (time_after(jiffies, last_time + 5 * HZ)) if (__ratelimit(&ratelimit)) {
count = 0;
if (++count < 5) {
last_time = jiffies;
printk("ia64_handle_irq: DANGER: less than " printk("ia64_handle_irq: DANGER: less than "
"1KB of free stack space!!\n" "1KB of free stack space!!\n"
"(bsp=0x%lx, sp=%lx)\n", bsp, sp); "(bsp=0x%lx, sp=%lx)\n", bsp, sp);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/ratelimit.h>
#include <asm/intrinsics.h> #include <asm/intrinsics.h>
#include <asm/processor.h> #include <asm/processor.h>
...@@ -1283,24 +1284,9 @@ emulate_store_float (unsigned long ifa, load_store_t ld, struct pt_regs *regs) ...@@ -1283,24 +1284,9 @@ emulate_store_float (unsigned long ifa, load_store_t ld, struct pt_regs *regs)
/* /*
* Make sure we log the unaligned access, so that user/sysadmin can notice it and * Make sure we log the unaligned access, so that user/sysadmin can notice it and
* eventually fix the program. However, we don't want to do that for every access so we * eventually fix the program. However, we don't want to do that for every access so we
* pace it with jiffies. This isn't really MP-safe, but it doesn't really have to be * pace it with jiffies.
* either...
*/ */
static int static DEFINE_RATELIMIT_STATE(logging_rate_limit, 5 * HZ, 5);
within_logging_rate_limit (void)
{
static unsigned long count, last_time;
if (time_after(jiffies, last_time + 5 * HZ))
count = 0;
if (count < 5) {
last_time = jiffies;
count++;
return 1;
}
return 0;
}
void void
ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
...@@ -1337,7 +1323,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) ...@@ -1337,7 +1323,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
if (!no_unaligned_warning && if (!no_unaligned_warning &&
!(current->thread.flags & IA64_THREAD_UAC_NOPRINT) && !(current->thread.flags & IA64_THREAD_UAC_NOPRINT) &&
within_logging_rate_limit()) __ratelimit(&logging_rate_limit))
{ {
char buf[200]; /* comm[] is at most 16 bytes... */ char buf[200]; /* comm[] is at most 16 bytes... */
size_t len; size_t len;
...@@ -1370,7 +1356,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) ...@@ -1370,7 +1356,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
} }
} }
} else { } else {
if (within_logging_rate_limit()) { if (__ratelimit(&logging_rate_limit)) {
printk(KERN_WARNING "kernel unaligned access to 0x%016lx, ip=0x%016lx\n", printk(KERN_WARNING "kernel unaligned access to 0x%016lx, ip=0x%016lx\n",
ifa, regs->cr_iip + ipsr->ri); ifa, regs->cr_iip + ipsr->ri);
if (unaligned_dump_stack) if (unaligned_dump_stack)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment