Skip to content

Commit 35a52a1

Browse files
mopsfeldermpe
authored andcommitted
powerpc/traps: Use an explicit ratelimit state for show_signal_msg()
Replace printk_ratelimited() by printk() and a default rate limit burst to limit displaying unhandled signals messages. This will allow us to call print_vma_addr() in a future patch, which does not work with printk_ratelimited(). Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 658b0f9 commit 35a52a1

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

arch/powerpc/kernel/traps.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ void user_single_step_siginfo(struct task_struct *tsk,
301301
info->si_addr = (void __user *)regs->nip;
302302
}
303303

304+
static bool show_unhandled_signals_ratelimited(void)
305+
{
306+
static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
307+
DEFAULT_RATELIMIT_BURST);
308+
return show_unhandled_signals && __ratelimit(&rs);
309+
}
310+
304311
static void show_signal_msg(int signr, struct pt_regs *regs, int code,
305312
unsigned long addr)
306313
{
@@ -309,11 +316,15 @@ static void show_signal_msg(int signr, struct pt_regs *regs, int code,
309316
const char fmt64[] = KERN_INFO "%s[%d]: unhandled signal %d " \
310317
"at %016lx nip %016lx lr %016lx code %x\n";
311318

312-
if (show_unhandled_signals && unhandled_signal(current, signr)) {
313-
printk_ratelimited(regs->msr & MSR_64BIT ? fmt64 : fmt32,
314-
current->comm, current->pid, signr,
315-
addr, regs->nip, regs->link, code);
316-
}
319+
if (!show_unhandled_signals_ratelimited())
320+
return;
321+
322+
if (!unhandled_signal(current, signr))
323+
return;
324+
325+
printk(regs->msr & MSR_64BIT ? fmt64 : fmt32,
326+
current->comm, current->pid, signr,
327+
addr, regs->nip, regs->link, code);
317328
}
318329

319330
void _exception_pkey(int signr, struct pt_regs *regs, int code,

0 commit comments

Comments
 (0)