arm64: use private ratelimit state along with show_unhandled_signals
authorVladimir Murzin <vladimir.murzin@arm.com>
Fri, 19 Jun 2015 14:28:03 +0000 (15:28 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 19 Jun 2015 15:26:15 +0000 (16:26 +0100)
printk_ratelimit() shares the ratelimiting state with other callers what
may lead to scenarios where at the time we want to print out debug
information we already limited, so nothing appears in the dmesg - this
makes exception-trace quite poor helper in debugging.

Additionally, we have imbalance with some messages limited with global
ratelimit state and other messages limited with their private state
defined via pr_*_ratelimited().

To address this inconsistency show_unhandled_signals_ratelimited()
macro is introduced and caller sites are converted to use it.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/system_misc.h
arch/arm64/kernel/traps.c
arch/arm64/mm/fault.c

index 659fbf5925de23f360affcaabbd1fe19aa8dc2a4..57f110bea6a82897520d435da21a920960fb7a2b 100644 (file)
@@ -23,6 +23,8 @@
 #include <linux/compiler.h>
 #include <linux/linkage.h>
 #include <linux/irqflags.h>
 #include <linux/compiler.h>
 #include <linux/linkage.h>
 #include <linux/irqflags.h>
+#include <linux/signal.h>
+#include <linux/ratelimit.h>
 #include <linux/reboot.h>
 
 struct pt_regs;
 #include <linux/reboot.h>
 
 struct pt_regs;
@@ -43,6 +45,17 @@ extern void __show_regs(struct pt_regs *);
 
 extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
 
 extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
+#define show_unhandled_signals_ratelimited()                           \
+({                                                                     \
+       static DEFINE_RATELIMIT_STATE(_rs,                              \
+                                     DEFAULT_RATELIMIT_INTERVAL,       \
+                                     DEFAULT_RATELIMIT_BURST);         \
+       bool __show_ratelimited = false;                                \
+       if (show_unhandled_signals && __ratelimit(&_rs))                \
+               __show_ratelimited = true;                              \
+       __show_ratelimited;                                             \
+})
+
 #define UDBG_UNDEFINED (1 << 0)
 #define UDBG_SYSCALL   (1 << 1)
 #define UDBG_BADABORT  (1 << 2)
 #define UDBG_UNDEFINED (1 << 0)
 #define UDBG_SYSCALL   (1 << 1)
 #define UDBG_BADABORT  (1 << 2)
index 1ef2940df13c5e95e9d1e8b333b96354dc786411..a12251c074a8298435cc5d10d7361f87a0c0b128 100644 (file)
@@ -335,8 +335,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
        if (call_undef_hook(regs) == 0)
                return;
 
        if (call_undef_hook(regs) == 0)
                return;
 
-       if (show_unhandled_signals && unhandled_signal(current, SIGILL) &&
-           printk_ratelimit()) {
+       if (show_unhandled_signals_ratelimited() && unhandled_signal(current, SIGILL)) {
                pr_info("%s[%d]: undefined instruction: pc=%p\n",
                        current->comm, task_pid_nr(current), pc);
                dump_instr(KERN_INFO, regs);
                pr_info("%s[%d]: undefined instruction: pc=%p\n",
                        current->comm, task_pid_nr(current), pc);
                dump_instr(KERN_INFO, regs);
@@ -363,7 +362,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs)
        }
 #endif
 
        }
 #endif
 
-       if (show_unhandled_signals && printk_ratelimit()) {
+       if (show_unhandled_signals_ratelimited()) {
                pr_info("%s[%d]: syscall %d\n", current->comm,
                        task_pid_nr(current), (int)regs->syscallno);
                dump_instr("", regs);
                pr_info("%s[%d]: syscall %d\n", current->comm,
                        task_pid_nr(current), (int)regs->syscallno);
                dump_instr("", regs);
index e8c608c893cfb08a3aea776210e5b0c58f2d5d95..66bd92ab6f7be33616ab05fbf5c32c0a6106ef25 100644 (file)
@@ -115,8 +115,7 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr,
 {
        struct siginfo si;
 
 {
        struct siginfo si;
 
-       if (show_unhandled_signals && unhandled_signal(tsk, sig) &&
-           printk_ratelimit()) {
+       if (show_unhandled_signals_ratelimited() && unhandled_signal(tsk, sig)) {
                pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n",
                        tsk->comm, task_pid_nr(tsk), fault_name(esr), sig,
                        addr, esr);
                pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n",
                        tsk->comm, task_pid_nr(tsk), fault_name(esr), sig,
                        addr, esr);