Skip to content

Commit ea47666

Browse files
guilhermepiccolirostedt
authored andcommitted
tracing: Improve panic/die notifiers
Currently the tracing dump_on_oops feature is implemented through separate notifiers, one for die/oops and the other for panic; given they have the same functionality, let's unify them. Also improve the function comment and change the priority of the notifier to make it execute earlier, avoiding showing useless trace data (like the callback names for the other notifiers); finally, we also removed an unnecessary header inclusion. Link: https://lkml.kernel.org/r/[email protected] Cc: Petr Mladek <[email protected]> Cc: Sergei Shtylyov <[email protected]> Signed-off-by: Guilherme G. Piccoli <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent d0b24b4 commit ea47666

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

kernel/trace/trace.c

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/kallsyms.h>
2020
#include <linux/security.h>
2121
#include <linux/seq_file.h>
22-
#include <linux/notifier.h>
2322
#include <linux/irqflags.h>
2423
#include <linux/debugfs.h>
2524
#include <linux/tracefs.h>
@@ -9876,40 +9875,40 @@ static __init int tracer_init_tracefs(void)
98769875

98779876
fs_initcall(tracer_init_tracefs);
98789877

9879-
static int trace_panic_handler(struct notifier_block *this,
9880-
unsigned long event, void *unused)
9881-
{
9882-
if (ftrace_dump_on_oops)
9883-
ftrace_dump(ftrace_dump_on_oops);
9884-
return NOTIFY_OK;
9885-
}
9878+
static int trace_die_panic_handler(struct notifier_block *self,
9879+
unsigned long ev, void *unused);
98869880

98879881
static struct notifier_block trace_panic_notifier = {
9888-
.notifier_call = trace_panic_handler,
9889-
.next = NULL,
9890-
.priority = 150 /* priority: INT_MAX >= x >= 0 */
9882+
.notifier_call = trace_die_panic_handler,
9883+
.priority = INT_MAX - 1,
98919884
};
98929885

9893-
static int trace_die_handler(struct notifier_block *self,
9894-
unsigned long val,
9895-
void *data)
9896-
{
9897-
switch (val) {
9898-
case DIE_OOPS:
9899-
if (ftrace_dump_on_oops)
9900-
ftrace_dump(ftrace_dump_on_oops);
9901-
break;
9902-
default:
9903-
break;
9904-
}
9905-
return NOTIFY_OK;
9906-
}
9907-
99089886
static struct notifier_block trace_die_notifier = {
9909-
.notifier_call = trace_die_handler,
9910-
.priority = 200
9887+
.notifier_call = trace_die_panic_handler,
9888+
.priority = INT_MAX - 1,
99119889
};
99129890

9891+
/*
9892+
* The idea is to execute the following die/panic callback early, in order
9893+
* to avoid showing irrelevant information in the trace (like other panic
9894+
* notifier functions); we are the 2nd to run, after hung_task/rcu_stall
9895+
* warnings get disabled (to prevent potential log flooding).
9896+
*/
9897+
static int trace_die_panic_handler(struct notifier_block *self,
9898+
unsigned long ev, void *unused)
9899+
{
9900+
if (!ftrace_dump_on_oops)
9901+
return NOTIFY_DONE;
9902+
9903+
/* The die notifier requires DIE_OOPS to trigger */
9904+
if (self == &trace_die_notifier && ev != DIE_OOPS)
9905+
return NOTIFY_DONE;
9906+
9907+
ftrace_dump(ftrace_dump_on_oops);
9908+
9909+
return NOTIFY_DONE;
9910+
}
9911+
99139912
/*
99149913
* printk is set to max of 1024, we really don't need it that big.
99159914
* Nothing should be printing 1000 characters anyway.

0 commit comments

Comments
 (0)