|
19 | 19 | #include <linux/kallsyms.h>
|
20 | 20 | #include <linux/security.h>
|
21 | 21 | #include <linux/seq_file.h>
|
22 |
| -#include <linux/notifier.h> |
23 | 22 | #include <linux/irqflags.h>
|
24 | 23 | #include <linux/debugfs.h>
|
25 | 24 | #include <linux/tracefs.h>
|
@@ -9876,40 +9875,40 @@ static __init int tracer_init_tracefs(void)
|
9876 | 9875 |
|
9877 | 9876 | fs_initcall(tracer_init_tracefs);
|
9878 | 9877 |
|
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); |
9886 | 9880 |
|
9887 | 9881 | 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, |
9891 | 9884 | };
|
9892 | 9885 |
|
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 |
| - |
9908 | 9886 | 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, |
9911 | 9889 | };
|
9912 | 9890 |
|
| 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 | + |
9913 | 9912 | /*
|
9914 | 9913 | * printk is set to max of 1024, we really don't need it that big.
|
9915 | 9914 | * Nothing should be printing 1000 characters anyway.
|
|
0 commit comments