From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
"Joel Fernandes (Google)" <joel@joelfernandes.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Thomas Gleixner <tglx@linutronix.de>,
"Paul E. McKenney" <paulmck@kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH] tracing/perf: Move rcu_irq_enter/exit_irqson() to perf trace point hook
Date: Tue, 11 Feb 2020 13:21:20 +0100 [thread overview]
Message-ID: <20200211122120.GM14914@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200210170643.3544795d@gandalf.local.home>
On Mon, Feb 10, 2020 at 05:06:43PM -0500, Steven Rostedt wrote:
> diff --git a/include/trace/perf.h b/include/trace/perf.h
> index dbc6c74defc3..1c94ce0cd4e2 100644
> --- a/include/trace/perf.h
> +++ b/include/trace/perf.h
> @@ -39,17 +39,27 @@ perf_trace_##call(void *__data, proto) \
> u64 __count = 1; \
> struct task_struct *__task = NULL; \
> struct hlist_head *head; \
> + bool rcu_watching; \
> int __entry_size; \
> int __data_size; \
> int rctx; \
> \
> + rcu_watching = rcu_is_watching(); \
> + \
> __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
> \
> + if (!rcu_watching) { \
> + /* Can not use RCU if rcu is not watching and in NMI */ \
> + if (in_nmi()) \
> + return; \
> + rcu_irq_enter_irqson(); \
> + } \
> + \
> head = this_cpu_ptr(event_call->perf_events); \
> if (!bpf_prog_array_valid(event_call) && \
> __builtin_constant_p(!__task) && !__task && \
> hlist_empty(head)) \
> - return; \
> + goto out; \
> \
> __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
> sizeof(u64)); \
> @@ -57,7 +67,7 @@ perf_trace_##call(void *__data, proto) \
> \
> entry = perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \
> if (!entry) \
> - return; \
> + goto out; \
> \
> perf_fetch_caller_regs(__regs); \
> \
> @@ -68,6 +78,9 @@ perf_trace_##call(void *__data, proto) \
> perf_trace_run_bpf_submit(entry, __entry_size, rctx, \
> event_call, __count, __regs, \
> head, __task); \
> +out: \
> + if (!rcu_watching) \
> + rcu_irq_exit_irqson(); \
> }
It is probably okay to move that into perf_tp_event(), then this:
> /*
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 1694a6b57ad8..3e6f07b62515 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -719,6 +719,7 @@ void rcu_irq_exit_irqson(void)
> rcu_irq_exit();
> local_irq_restore(flags);
> }
> +EXPORT_SYMBOL_GPL(rcu_irq_exit_irqson);
>
> /*
> * Exit an RCU extended quiescent state, which can be either the
> @@ -890,6 +891,7 @@ void rcu_irq_enter_irqson(void)
> rcu_irq_enter();
> local_irq_restore(flags);
> }
> +EXPORT_SYMBOL_GPL(rcu_irq_enter_irqson);
>
> /*
> * If any sort of urgency was applied to the current CPU (for example,
can go too. Those things really should not be exported.
next prev parent reply other threads:[~2020-02-11 12:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-10 22:06 [PATCH] tracing/perf: Move rcu_irq_enter/exit_irqson() to perf trace point hook Steven Rostedt
2020-02-11 0:30 ` Mathieu Desnoyers
2020-02-11 2:22 ` Steven Rostedt
2020-02-11 2:32 ` joel
2020-02-11 15:19 ` Mathieu Desnoyers
2020-02-11 12:00 ` Peter Zijlstra
2020-02-11 13:03 ` Paul E. McKenney
2020-02-11 13:16 ` Peter Zijlstra
2020-02-11 13:23 ` Paul E. McKenney
2020-02-11 14:10 ` Steven Rostedt
2020-02-11 11:49 ` Peter Zijlstra
2020-02-11 12:59 ` Paul E. McKenney
2020-02-11 13:10 ` Peter Zijlstra
2020-02-11 13:20 ` Paul E. McKenney
2020-02-11 14:05 ` Steven Rostedt
2020-02-11 15:05 ` Peter Zijlstra
2020-02-11 15:29 ` Peter Zijlstra
2020-02-11 16:16 ` Steven Rostedt
2020-02-11 15:06 ` Paul E. McKenney
2020-02-11 15:31 ` Peter Zijlstra
2020-02-11 15:40 ` Paul E. McKenney
2020-02-11 12:21 ` Peter Zijlstra [this message]
2020-02-11 14:10 ` Steven Rostedt
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=20200211122120.GM14914@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@embeddedor.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=paulmck@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).