[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160830072603.GG10168@twins.programming.kicks-ass.net>
Date: Tue, 30 Aug 2016 09:26:03 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Vegard Nossum <vegard.nossum@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Stephane Eranian <eranian@...gle.com>,
Vince Weaver <vincent.weaver@...ne.edu>,
Ingo Molnar <mingo@...nel.org>,
David Carrillo-Cisneros <davidcc@...gle.com>,
"H. Peter Anvin" <hpa@...or.com>, Kan Liang <kan.liang@...el.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Paul Turner <pjt@...gle.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
linux-tip-commits@...r.kernel.org
Subject: Re: [tip:perf/core] perf/core: Check return value of the
perf_event_read() IPI
On Tue, Aug 30, 2016 at 08:47:24AM +0200, Peter Zijlstra wrote:
> If oncpu is not valid, the sched_out that made it invalid will have
> updated the event count and we're good.
>
> All I'll leave is an explicit comment that we've ignored the
> smp_call_function_single() return value on purpose.
Something like so..
---
kernel/events/core.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3f07e6cfc1b6..a35cbc382b2c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3576,12 +3576,21 @@ static int perf_event_read(struct perf_event *event, bool group)
local_cpu = get_cpu();
cpu_to_read = find_cpu_to_read(event, local_cpu);
+
+ /*
+ * Purposely ignore the smp_call_function_single() return
+ * value.
+ *
+ * If event->oncpu isn't a valid CPU it means the event got
+ * scheduled out and that will have updated the event count.
+ *
+ * Therefore, either way, we'll have an up-to-date event count
+ * after this.
+ */
+ (void)smp_call_function_single(cpu_to_read, __perf_event_read, &data, 1);
put_cpu();
- ret = smp_call_function_single(cpu_to_read, __perf_event_read, &data, 1);
- /* The event must have been read from an online CPU: */
- WARN_ON_ONCE(ret);
- ret = ret ? : data.ret;
+ ret = data.ret;
} else if (event->state == PERF_EVENT_STATE_INACTIVE) {
struct perf_event_context *ctx = event->ctx;
unsigned long flags;
Powered by blists - more mailing lists