mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung.kim@lge.com>
Cc: Namhyung Kim <namhyung@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 11/11] perf record: Fix event grouping on forked task
Date: Mon, 13 Feb 2012 16:42:33 -0200	[thread overview]
Message-ID: <20120213184233.GK15955@infradead.org> (raw)
In-Reply-To: <1329118064-9412-12-git-send-email-namhyung.kim@lge.com>

Em Mon, Feb 13, 2012 at 04:27:43PM +0900, Namhyung Kim escreveu:
> When event group is enabled for forked task (i.e. no target task/cpu
> was specified) all events were disabled and marked ->enable_on_exec.
> However they wouldn't be counted at all since only group leader will
> be enabled on exec actually.
> 
> In contrast to perf stat, perf record doesn't have a real problem
> as it enables all the event before proceeding. But it needs to be
> fixed anyway IMHO.
> 
> Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
> ---
>  tools/perf/builtin-record.c |    2 +-
>  tools/perf/builtin-test.c   |    2 +-
>  tools/perf/util/evlist.c    |    5 +++--
>  tools/perf/util/evlist.h    |    3 ++-
>  tools/perf/util/evsel.c     |    5 +++--
>  tools/perf/util/evsel.h     |    3 ++-
>  6 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index fbf71edd31ba..a65b0a5a81ea 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -183,7 +183,7 @@ static void perf_record__open(struct perf_record *rec)
>  
>  	first = list_entry(evlist->entries.next, struct perf_evsel, node);
>  
> -	perf_evlist__config_attrs(evlist, opts);
> +	perf_evlist__config_attrs(evlist, opts, first);

No need to pass the first entry in the evlist, since we can find it at
perf_evlist__config_attrs using:

  list_entry(evlist->entries.next, struct perf_evsel, node);

That way you reduce the patch size by not touching all the callers of
perf_evlist__config_attrs.

- Arnaldo
  
>  	list_for_each_entry(pos, &evlist->entries, node) {
>  		struct perf_event_attr *attr = &pos->attr;
> diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
> index 91a6eba000f2..b72b12aedd29 100644
> --- a/tools/perf/builtin-test.c
> +++ b/tools/perf/builtin-test.c
> @@ -1083,7 +1083,7 @@ static int test__PERF_RECORD(void)
>  	evsel->attr.sample_type |= PERF_SAMPLE_CPU;
>  	evsel->attr.sample_type |= PERF_SAMPLE_TID;
>  	evsel->attr.sample_type |= PERF_SAMPLE_TIME;
> -	perf_evlist__config_attrs(evlist, &opts);
> +	perf_evlist__config_attrs(evlist, &opts, evsel);
>  
>  	err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask,
>  					    &cpu_mask_size);
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index aa0418034d82..7ab81906c1aa 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -49,7 +49,8 @@ struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
>  }
>  
>  void perf_evlist__config_attrs(struct perf_evlist *evlist,
> -			       struct perf_record_opts *opts)
> +			       struct perf_record_opts *opts,
> +			       struct perf_evsel *first)
>  {
>  	struct perf_evsel *evsel;
>  
> @@ -57,7 +58,7 @@ void perf_evlist__config_attrs(struct perf_evlist *evlist,
>  		opts->no_inherit = true;
>  
>  	list_for_each_entry(evsel, &evlist->entries, node) {
> -		perf_evsel__config(evsel, opts);
> +		perf_evsel__config(evsel, opts, first);
>  
>  		if (evlist->nr_entries > 1)
>  			evsel->attr.sample_type |= PERF_SAMPLE_ID;
> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
> index 7e99ac513893..7ebb6419e8d0 100644
> --- a/tools/perf/util/evlist.h
> +++ b/tools/perf/util/evlist.h
> @@ -81,7 +81,8 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
>  int perf_evlist__open(struct perf_evlist *evlist, bool group);
>  
>  void perf_evlist__config_attrs(struct perf_evlist *evlist,
> -			       struct perf_record_opts *opts);
> +			       struct perf_record_opts *opts,
> +			       struct perf_evsel *first);
>  
>  int perf_evlist__prepare_workload(struct perf_evlist *evlist,
>  				  struct perf_record_opts *opts,
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index e7ddf27f240b..cb5c18b66d06 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -63,7 +63,8 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
>  	return evsel;
>  }
>  
> -void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
> +void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts,
> +			struct perf_evsel *first)
>  {
>  	struct perf_event_attr *attr = &evsel->attr;
>  	int track = !evsel->idx; /* only the first counter needs these */
> @@ -130,7 +131,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
>  	attr->mmap = track;
>  	attr->comm = track;
>  
> -	if (no_target_maps(&opts->maps)) {
> +	if (no_target_maps(&opts->maps) && (!opts->group || evsel == first)) {
>  		attr->disabled = 1;
>  		attr->enable_on_exec = 1;
>  	}
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 326b8e4d5035..3158ca3d69a1 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -80,7 +80,8 @@ void perf_evsel__exit(struct perf_evsel *evsel);
>  void perf_evsel__delete(struct perf_evsel *evsel);
>  
>  void perf_evsel__config(struct perf_evsel *evsel,
> -			struct perf_record_opts *opts);
> +			struct perf_record_opts *opts,
> +			struct perf_evsel *first);
>  
>  int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
>  int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
> -- 
> 1.7.9

      reply	other threads:[~2012-02-13 18:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1329118064-9412-1-git-send-email-namhyung.kim@lge.com>
2012-02-13  7:27 ` [PATCH 01/11] perf tools: Introduce struct perf_maps_opts Namhyung Kim
2012-02-13  7:44   ` [RFC PATCHSET] perf: Fix cpu/thread map and group event handling Namhyung Kim
2012-02-13 18:32   ` [PATCH 01/11] perf tools: Introduce struct perf_maps_opts Arnaldo Carvalho de Melo
2012-02-13 18:50     ` David Ahern
2012-02-13 19:05       ` Arnaldo Carvalho de Melo
2012-02-13 19:19         ` David Ahern
2012-02-13 20:12           ` Arnaldo Carvalho de Melo
2012-02-13  7:27 ` [PATCH 02/11] perf stat: Convert to perf_maps_opts Namhyung Kim
2012-02-13 18:33   ` Arnaldo Carvalho de Melo
2012-02-13  7:27 ` [PATCH 03/11] perf top: " Namhyung Kim
2012-02-13  7:27 ` [PATCH 04/11] perf tools: Introduce check_target_maps() helper Namhyung Kim
2012-02-13 18:36   ` Arnaldo Carvalho de Melo
2012-02-13  7:27 ` [PATCH 05/11] perf tools: Make perf_evlist__create_maps() take struct perf_maps_opts Namhyung Kim
2012-02-13 18:36   ` Arnaldo Carvalho de Melo
2012-02-13  7:27 ` [PATCH 06/11] perf tools: Check more combinations of PID/TID, UID and CPU switches Namhyung Kim
2012-02-13  7:27 ` [PATCH 07/11] perf tools: Fix creation of cpu map Namhyung Kim
2012-02-13  7:27 ` [PATCH 08/11] perf tools: Consolidate target task/cpu checking Namhyung Kim
2012-02-13 18:39   ` Arnaldo Carvalho de Melo
2012-02-13  7:27 ` [PATCH 09/11] perf stat: Use perf_evlist__create_maps Namhyung Kim
2012-02-13 18:40   ` Arnaldo Carvalho de Melo
2012-02-13  7:27 ` [PATCH 10/11] perf stat: Fix event grouping on forked task Namhyung Kim
2012-02-13 18:41   ` Arnaldo Carvalho de Melo
2012-02-14  1:20     ` [PATCH] " Namhyung Kim
2012-02-13  7:27 ` [PATCH 11/11] perf record: " Namhyung Kim
2012-02-13 18:42   ` Arnaldo Carvalho de Melo [this message]

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=20120213184233.GK15955@infradead.org \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.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
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

Powered by JetHome