[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170828192359.jfcb55q5remlhfbw@hirez.programming.kicks-ass.net>
Date: Mon, 28 Aug 2017 21:23:59 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
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: Re: [PATCH 03/10] perf: Make sure we read only scheduled events
On Thu, Aug 24, 2017 at 06:27:30PM +0200, Jiri Olsa wrote:
> 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);
I'm not seeing how this makes sense. Groups should either _all_ be
scheduled or not at all. Please explain.
Powered by blists - more mailing lists