LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>,
	Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH 03/10] perf: Make sure we read only scheduled events
Date: Mon, 28 Aug 2017 21:23:59 +0200
Message-ID: <20170828192359.jfcb55q5remlhfbw@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20170824162737.7813-4-jolsa@kernel.org>

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@kernel.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.

  reply index

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 16:27 [PATCH 00/10] perf: inherit_stat related fixes Jiri Olsa
2017-08-24 16:27 ` [PATCH 01/10] perf/x86: Add warning on proper cpu during event's update Jiri Olsa
2017-08-28 19:24   ` Peter Zijlstra
2017-08-24 16:27 ` [PATCH 02/10] perf: Fix leader for removed sibling event in perf_group_detach Jiri Olsa
2017-08-28 19:23   ` Peter Zijlstra
2017-08-24 16:27 ` [PATCH 03/10] perf: Make sure we read only scheduled events Jiri Olsa
2017-08-28 19:23   ` Peter Zijlstra [this message]
2017-09-01  7:21     ` Jiri Olsa
2017-08-24 16:27 ` [PATCH 04/10] perf record: Set read_format for inherit_stat Jiri Olsa
2017-08-29 21:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-08-24 16:27 ` [PATCH 05/10] perf report: Add dump_read function Jiri Olsa
2017-08-29 21:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-08-24 16:27 ` [PATCH 06/10] perf values: Fix thread index bug Jiri Olsa
2017-08-29 21:21   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-08-24 16:27 ` [PATCH 07/10] perf values: Fix allocation check Jiri Olsa
2017-08-29 21:21   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-08-24 16:27 ` [PATCH 08/10] perf values: Zero value buffers Jiri Olsa
2017-08-29 21:21   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-08-24 16:27 ` [PATCH 09/10] perf report: Group stat values on global event id Jiri Olsa
2017-08-29 21:22   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-08-24 16:27 ` [PATCH 10/10] perf stat: Support inherit/no-inherit terms Jiri Olsa
2017-08-24 16:30   ` Andi Kleen
2017-08-24 16:45     ` Jiri Olsa
2017-08-25 18:57       ` Arnaldo Carvalho de Melo

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=20170828192359.jfcb55q5remlhfbw@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git