[PATCH 17/30] tracing: Improve panic/die notifiers
Sergei Shtylyov
sergei.shtylyov at gmail.com
Fri Apr 29 02:22:44 PDT 2022
Hello!
On 4/28/22 1:49 AM, Guilherme G. Piccoli wrote:
> Currently the tracing dump_on_oops feature is implemented
> through separate notifiers, one for die/oops and the other
> for panic. With the addition of panic notifier "id", this
> patch makes use of such "id" to unify both functions.
>
> It also comments the function and changes the priority of the
> notifier blocks, in order they run early compared to other
> notifiers, to prevent useless trace data (like the callback
> names for the other notifiers). Finally, we also removed an
> unnecessary header inclusion.
>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli at igalia.com>
> ---
> kernel/trace/trace.c | 57 +++++++++++++++++++++++++-------------------
> 1 file changed, 32 insertions(+), 25 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index f4de111fa18f..c1d8a3622ccc 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
[...]
> @@ -9767,38 +9766,46 @@ static __init int tracer_init_tracefs(void)
>
> fs_initcall(tracer_init_tracefs);
>
> -static int trace_panic_handler(struct notifier_block *this,
> - unsigned long event, void *unused)
> +/*
> + * The idea is to execute the following die/panic callback early, in order
> + * to avoid showing irrelevant information in the trace (like other panic
> + * notifier functions); we are the 2nd to run, after hung_task/rcu_stall
> + * warnings get disabled (to prevent potential log flooding).
> + */
> +static int trace_die_panic_handler(struct notifier_block *self,
> + unsigned long ev, void *unused)
> {
> - if (ftrace_dump_on_oops)
> + int do_dump;
bool?
> +
> + if (!ftrace_dump_on_oops)
> + return NOTIFY_DONE;
> +
> + switch (ev) {
> + case DIE_OOPS:
> + do_dump = 1;
> + break;
> + case PANIC_NOTIFIER:
> + do_dump = 1;
> + break;
Why not:
case DIE_OOPS:
case PANIC_NOTIFIER:
do_dump = 1;
break;
> + default:
> + do_dump = 0;
> + break;
> + }
> +
> + if (do_dump)
> ftrace_dump(ftrace_dump_on_oops);
> - return NOTIFY_OK;
> +
> + return NOTIFY_DONE;
> }
[...]
MBR, Sergey
More information about the kexec
mailing list