Skip to content

Commit 86dca36

Browse files
murzinvctmarinas
authored andcommitted
arm64: use private ratelimit state along with show_unhandled_signals
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>
1 parent 9e793ab commit 86dca36

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

arch/arm64/include/asm/system_misc.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <linux/compiler.h>
2424
#include <linux/linkage.h>
2525
#include <linux/irqflags.h>
26+
#include <linux/signal.h>
27+
#include <linux/ratelimit.h>
2628
#include <linux/reboot.h>
2729

2830
struct pt_regs;
@@ -43,6 +45,17 @@ extern void __show_regs(struct pt_regs *);
4345

4446
extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
4547

48+
#define show_unhandled_signals_ratelimited() \
49+
({ \
50+
static DEFINE_RATELIMIT_STATE(_rs, \
51+
DEFAULT_RATELIMIT_INTERVAL, \
52+
DEFAULT_RATELIMIT_BURST); \
53+
bool __show_ratelimited = false; \
54+
if (show_unhandled_signals && __ratelimit(&_rs)) \
55+
__show_ratelimited = true; \
56+
__show_ratelimited; \
57+
})
58+
4659
#define UDBG_UNDEFINED (1 << 0)
4760
#define UDBG_SYSCALL (1 << 1)
4861
#define UDBG_BADABORT (1 << 2)

arch/arm64/kernel/traps.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
335335
if (call_undef_hook(regs) == 0)
336336
return;
337337

338-
if (show_unhandled_signals && unhandled_signal(current, SIGILL) &&
339-
printk_ratelimit()) {
338+
if (show_unhandled_signals_ratelimited() && unhandled_signal(current, SIGILL)) {
340339
pr_info("%s[%d]: undefined instruction: pc=%p\n",
341340
current->comm, task_pid_nr(current), pc);
342341
dump_instr(KERN_INFO, regs);
@@ -363,7 +362,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs)
363362
}
364363
#endif
365364

366-
if (show_unhandled_signals && printk_ratelimit()) {
365+
if (show_unhandled_signals_ratelimited()) {
367366
pr_info("%s[%d]: syscall %d\n", current->comm,
368367
task_pid_nr(current), (int)regs->syscallno);
369368
dump_instr("", regs);

arch/arm64/mm/fault.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr,
115115
{
116116
struct siginfo si;
117117

118-
if (show_unhandled_signals && unhandled_signal(tsk, sig) &&
119-
printk_ratelimit()) {
118+
if (show_unhandled_signals_ratelimited() && unhandled_signal(tsk, sig)) {
120119
pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n",
121120
tsk->comm, task_pid_nr(tsk), fault_name(esr), sig,
122121
addr, esr);

0 commit comments

Comments
 (0)