All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] tracing: Make sure RCU is watching before calling a stack trace
Date: Wed, 17 May 2017 20:48:59 -0700	[thread overview]
Message-ID: <20170518034859.GQ3956@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170517220845.17f93eca@gandalf.local.home>

On Wed, May 17, 2017 at 10:08:45PM -0400, Steven Rostedt wrote:
> 
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> 
> As stack tracing now requires "rcu watching", force RCU to be watching when
> recording a stack trace.
> 
> Link: http://lkml.kernel.org/r/20170512172449.879684501@goodmis.org
> 
> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Looks correct to me.

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
>  kernel/trace/trace.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index fcc9a2d..a1b45b4 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -2568,7 +2568,28 @@ static inline void ftrace_trace_stack(struct trace_array *tr,
>  void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
>  		   int pc)
>  {
> -	__ftrace_trace_stack(tr->trace_buffer.buffer, flags, skip, pc, NULL);
> +	struct ring_buffer *buffer = tr->trace_buffer.buffer;
> +
> +	/* When an NMI triggers, RCU is enabled via rcu_nmi_enter() */
> +	if (in_nmi()) {
> +		__ftrace_trace_stack(buffer, flags, skip, pc, NULL);
> +		return;
> +	}
> +
> +	/*
> +	 * It is possible that a function is being traced in a
> +	 * location that RCU is not watching. A call to
> +	 * rcu_irq_enter() will make sure that it is, but there's
> +	 * a few internal rcu functions that could be traced
> +	 * where that wont work either. In those cases, we just
> +	 * do nothing.
> +	 */
> +	if (unlikely(rcu_irq_enter_disabled()))
> +		return;
> +
> +	rcu_irq_enter();
> +	__ftrace_trace_stack(buffer, flags, skip, pc, NULL);
> +	rcu_irq_exit();
>  }
> 
>  /**
> -- 
> 2.9.3
> 

      reply	other threads:[~2017-05-18  3:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18  2:08 [PATCH] tracing: Make sure RCU is watching before calling a stack trace Steven Rostedt
2017-05-18  3:48 ` Paul E. McKenney [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170518034859.GQ3956@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.