perf tools: Do not disable members of group event
authorNamhyung Kim <namhyung.kim@lge.com>
Fri, 16 Mar 2012 08:42:20 +0000 (17:42 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 16 Mar 2012 19:29:33 +0000 (16:29 -0300)
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.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1331887340-32448-2-git-send-email-namhyung.kim@lge.com
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h

index 159263d17c2d31926672454004748b3583fe6f78..1986d8051bd16a9f133159545fb7083df3511d76 100644 (file)
@@ -51,13 +51,15 @@ 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_evsel *evsel;
+       struct perf_evsel *evsel, *first;
 
        if (evlist->cpus->map[0] < 0)
                opts->no_inherit = true;
 
+       first = list_entry(evlist->entries.next, struct perf_evsel, node);
+
        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;
index f421f7cbc0d34871a3ed7d58f064b1538547fc12..0221700075c54c20c916089877fc1e4aa88a0330 100644 (file)
@@ -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 */
@@ -134,7 +135,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
        attr->mmap = track;
        attr->comm = track;
 
-       if (!opts->target_pid && !opts->target_tid && !opts->system_wide) {
+       if (!opts->target_pid && !opts->target_tid && !opts->system_wide &&
+           (!opts->group || evsel == first)) {
                attr->disabled = 1;
                attr->enable_on_exec = 1;
        }
index 326b8e4d503579cb7306e8c05d82d95e957aa2d3..3158ca3d69a14bee73036472f03899244fe9c4ad 100644 (file)
@@ -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);