alpha: use __ratelimit
PATCH 1/1 alpha: use __ratelimit
Replace open-coded rate limiting logic with __ratelimit().
--- arch/alpha/kernel/traps.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
arch/alpha/kernel/traps.c +3 -7
@@ -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>
@@ -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;
Signature · 1 line
1.6.0.6
PATCH 1/1 ia64: use __ratelimit
Replace open-coded rate limiting logic with __ratelimit().
--- arch/ia64/kernel/irq_ia64.c | 9 +++------ arch/ia64/kernel/unaligned.c | 24 +++++------------------- 2 files changed, 8 insertions(+), 25 deletions(-)
arch/ia64/kernel/irq_ia64.c +3 -6
@@ -30,6 +30,7 @@#include <linux/threads.h> #include <linux/bitops.h> #include <linux/irq.h> +#include <linux/ratelimit.h> #include <asm/delay.h> #include <asm/intrinsics.h>
@@ -468,13 +469,9 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs) sp =ia64_getreg (_IA64_REG_SP);if ((sp - bsp) <1024 ) { -static unsigned char count; -static long last_time; + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5); -if (time_after (jiffies, last_time +5 *HZ )) - count =0 ; -if (++count <5 ) { - last_time = jiffies; +if (__ratelimit (&ratelimit)) {printk ("ia64_handle_irq: DANGER: less than " "1KB of free stack space!!\n" "(bsp=0x%lx, sp=%lx)\n" , bsp, sp);
arch/ia64/kernel/unaligned.c +5 -19
@@ -17,6 +17,7 @@#include <linux/kernel.h> #include <linux/sched.h> #include <linux/tty.h> +#include <linux/ratelimit.h> #include <asm/intrinsics.h> #include <asm/processor.h>
@@ -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 * 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 -* either... +* pace it with jiffies. */ -static int -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 ; - -} +static DEFINE_RATELIMIT_STATE(logging_rate_limit, 5 * HZ, 5);void 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 && !(current->thread.flags &IA64_THREAD_UAC_NOPRINT ) && -within_logging_rate_limit ()) +__ratelimit (&logging_rate_limit)) {char buf[200 ];/* comm[] is at most 16 bytes... */ size_t len;
@@ -1370,7 +1356,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) } } }else { -if (within_logging_rate_limit ()) { +if (__ratelimit (&logging_rate_limit)) {printk (KERN_WARNING "kernel unaligned access to 0x%016lx, ip=0x%016lx\n" , ifa, regs->cr_iip + ipsr->ri);if (unaligned_dump_stack)
Signature · 1 line
1.6.0.6
PATCH 1/1 parisc: use __ratelimit
In reply to Akinobu MitaReplace open-coded rate limiting logic with __ratelimit().
--- arch/parisc/kernel/unaligned.c | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-)
arch/parisc/kernel/unaligned.c +4 -10
@@ -25,6 +25,7 @@#include <linux/module.h> #include <linux/sched.h> #include <linux/signal.h> +#include <linux/ratelimit.h> #include <asm/uaccess.h> /* #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) { -static unsigned long unaligned_count =0 ; -static unsigned long last_time =0 ; + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);unsigned long newbase =R1 (regs->iir)?regs->gr[R1 (regs->iir)]:0 ;int modify =0 ;int ret =ERR_NOTHANDLED ;
@@ -460,14 +460,8 @@ void handle_unaligned(struct pt_regs *regs) goto force_sigbus; } -if (unaligned_count >5 && -time_after (jiffies, last_time +5 *HZ )) { - unaligned_count =0 ; - last_time = jiffies; - } - -if (!(current->thread.flags &PARISC_UAC_NOPRINT ) - && ++unaligned_count <5 ) { +if (!(current->thread.flags &PARISC_UAC_NOPRINT ) && +__ratelimit (&ratelimit)) {char buf[256 ];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 ]);
Signature · 1 line
1.6.0.6
Re: [PATCH] parisc: use __ratelimit
Quoted 2 lines · Akinobu Mita
Replace open-coded rate limiting logic with
__ratelimit().
Thanks, I'll apply this.
regards, Kyle
PATCH 1/1 sparc: use __ratelimit
In reply to Akinobu MitaReplace open-coded rate limiting logic with __ratelimit().
--- arch/sparc/kernel/unaligned_64.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
arch/sparc/kernel/unaligned_64.c +3 -6
@@ -21,6 +21,7 @@#include <linux/smp.h> #include <linux/bitops.h> #include <linux/perf_event.h> +#include <linux/ratelimit.h> #include <asm/fpumacro.h> enum direction {
@@ -274,13 +275,9 @@ static void kernel_mna_trap_fault(int fixup_tstate_asi)static void log_unaligned (struct pt_regs *regs) { -static unsigned long count, last_time; + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5); -if (time_after (jiffies, last_time +5 *HZ )) - count =0 ; -if (count <5 ) { - last_time = jiffies; - count++; +if (__ratelimit (&ratelimit)) {printk ("Kernel unaligned access at TPC[%lx] %pS\n" , regs->tpc, (void *) regs->tpc); }
Signature · 1 line
1.6.0.6
Re: [PATCH] sparc: use __ratelimit
From: Akinobu Mita <[email protected]>
Date: Sun, 28 Feb 2010 19:58:17 +0900
Quoted 3 lines
Replace open-coded rate limiting logic with
__ratelimit().Signed-off-by Akinobu Mita <[email protected]>
Applied, thanks.
PATCH 1/1 powerpc: use __ratelimit
In reply to Akinobu MitaReplace open-coded rate limiting logic with __ratelimit().
--- arch/powerpc/platforms/iseries/pci.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
arch/powerpc/platforms/iseries/pci.c +3 -7
@@ -31,6 +31,7 @@#include <linux/module.h> #include <linux/pci.h> #include <linux/of.h> +#include <linux/ratelimit.h> #include <asm/types.h> #include <asm/io.h>
@@ -583,14 +584,9 @@ static inline struct device_node *xlate_iomm_address( orig_addr = (unsigned long __force )addr;if ((orig_addr <BASE_IO_MEMORY ) || (orig_addr >= max_io_memory)) { -static unsigned long last_jiffies; -static int num_printed; + static DEFINE_RATELIMIT_STATE(ratelimit, 60 * HZ, 10); -if (time_after (jiffies, last_jiffies +60 *HZ )) { - last_jiffies = jiffies; - num_printed =0 ; - } -if (num_printed++ <10 ) +if (__ratelimit (&ratelimit))printk (KERN_ERR "iSeries_%s: invalid access at IO address %p\n" , func, addr);
Signature · 1 line
1.6.0.6
Quoted 1 line · Akinobu Mita
Replace open-coded rate limiting logic with
__ratelimit().
Perhaps printk_ratelimited?
2010/3/1 Joe Perches <[email protected]>:
Quoted 4 lines · Akinobu Mita
Quoted 1 line
Replace open-coded rate limiting logic with
__ratelimit().Perhaps
printk_ratelimited?
This patch is cleanup only and no functionnal change (it does not change the rate limit interval and burst).
But using printk_ratelimited() changes the burst count from 5 to 10. It may not be big difference but I'm not sure...
Quoted 36 lines · Akinobu Mita
Replace open-coded rate limiting logic with
__ratelimit().Signed-off-by Akinobu Mita <[email protected]>Cc Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc Matt Turner <[email protected]>---
arch/alpha/kernel/traps.c | 10 +++-------1 files changed, 3 insertions(+), 7 deletions(-)arch/alpha/kernel/traps.c +2
-2@@ -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>@@ -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. */
Quoted 16 lines
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))
gotogive_sigbus;
--
1.6.0.6
Thanks, applied.
Matt
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html