[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170824162737.7813-4-jolsa@kernel.org>
Date: Thu, 24 Aug 2017 18:27:30 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <andi@...stfloor.org>,
Mark Rutland <mark.rutland@....com>
Subject: [PATCH 03/10] perf: Make sure we read only scheduled events
Adding leader's state check into perf_output_read_group
to ensure we read only leader, which is scheduled in.
Similar check is already there for siblings.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
kernel/events/core.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 30e30e94ea32..9a2791afe051 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5760,6 +5760,11 @@ void perf_event__output_id_sample(struct perf_event *event,
__perf_event__output_id_sample(handle, sample);
}
+static bool can_read(struct perf_event *event)
+{
+ return event->state == PERF_EVENT_STATE_ACTIVE;
+}
+
static void perf_output_read_one(struct perf_output_handle *handle,
struct perf_event *event,
u64 enabled, u64 running)
@@ -5800,7 +5805,7 @@ static void perf_output_read_group(struct perf_output_handle *handle,
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
values[n++] = running;
- if (leader != event)
+ if ((leader != event) && can_read(leader))
leader->pmu->read(leader);
values[n++] = perf_event_count(leader);
@@ -5812,8 +5817,7 @@ static void perf_output_read_group(struct perf_output_handle *handle,
list_for_each_entry(sub, &leader->sibling_list, group_entry) {
n = 0;
- if ((sub != event) &&
- (sub->state == PERF_EVENT_STATE_ACTIVE))
+ if ((sub != event) && can_read(sub))
sub->pmu->read(sub);
values[n++] = perf_event_count(sub);
--
2.9.5
Powered by blists - more mailing lists