[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190729112126.6554b141@gandalf.local.home>
Date: Mon, 29 Jul 2019 11:21:26 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Eiichi Tsukata <devel@...ukata.com>
Cc: joel@...lfernandes.org, paulmck@...ux.vnet.ibm.com,
tglx@...utronix.de, peterz@...radead.org, mingo@...hat.com,
fweisbec@...il.com, luto@...capital.net,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tracing: Prevent RCU EQS breakage in preemptirq events
On Mon, 29 Jul 2019 10:07:34 +0900
Eiichi Tsukata <devel@...ukata.com> wrote:
> If context tracking is enabled, causing page fault in preemptirq
> irq_enable or irq_disable events triggers the following RCU EQS warning.
>
> Reproducer:
>
> // CONFIG_PREEMPTIRQ_EVENTS=y
> // CONFIG_CONTEXT_TRACKING=y
> // CONFIG_RCU_EQS_DEBUG=y
> # echo 1 > events/preemptirq/irq_disable/enable
> # echo 1 > options/userstacktrace
So the problem is only with userstacktrace enabled?
> }
> diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptirq.c
> index 4d8e99fdbbbe..031b51cb94d0 100644
> --- a/kernel/trace/trace_preemptirq.c
> +++ b/kernel/trace/trace_preemptirq.c
> @@ -10,6 +10,7 @@
> #include <linux/module.h>
> #include <linux/ftrace.h>
> #include <linux/kprobes.h>
> +#include <linux/context_tracking.h>
> #include "trace.h"
>
> #define CREATE_TRACE_POINTS
> @@ -49,9 +50,14 @@ NOKPROBE_SYMBOL(trace_hardirqs_off);
>
> __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
> {
> + enum ctx_state prev_state;
> +
> if (this_cpu_read(tracing_irq_cpu)) {
> - if (!in_nmi())
> + if (!in_nmi()) {
This is a very high fast path (for tracing irqs off and such). Instead
of adding a check here for a case that is seldom used (userstacktrace
and tracing irqs on/off). Move this to surround the userstack trace
code.
-- Steve
> + prev_state = exception_enter();
> trace_irq_enable_rcuidle(CALLER_ADDR0, caller_addr);
> + exception_exit(prev_state);
> + }
> tracer_hardirqs_on(CALLER_ADDR0, caller_addr);
> this_cpu_write(tracing_irq_cpu, 0);
> }
> @@ -63,11 +69,16 @@ NOKPROBE_SYMBOL(trace_hardirqs_on_caller);
>
> __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
> {
> + enum ctx_state prev_state;
> +
> if (!this_cpu_read(tracing_irq_cpu)) {
> this_cpu_write(tracing_irq_cpu, 1);
> tracer_hardirqs_off(CALLER_ADDR0, caller_addr);
> - if (!in_nmi())
> + if (!in_nmi()) {
> + prev_state = exception_enter();
> trace_irq_disable_rcuidle(CALLER_ADDR0, caller_addr);
> + exception_exit(prev_state);
> + }
> }
>
> lockdep_hardirqs_off(CALLER_ADDR0);
Powered by blists - more mailing lists