diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-11-12 12:34:00 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-14 14:51:50 -0500 |
commit | cac21425578abddc4e9f529845832a57ba27ce0f (patch) | |
tree | 78e6795bc2c7e86ac8aed3cb25381714845ebe32 /tools/perf | |
parent | 6064803313bad9ae4cae233a9d56678adb2b6e7c (diff) |
perf tools: Fix attributes for '{}' defined event groups
Fixing events attributes for groups defined via '{}'.
Currently 'enable_on_exec' attribute in record command and both
'disabled ' and 'enable_on_exec' attributes in stat command are set
based on the 'group' option. This eliminates proper setup for '{}'
defined groups as they don't set 'group' option.
Making above attributes values based on the 'evsel->leader' as this is
common to both group definition.
Moving perf_evlist__set_leader call within builtin-record ahead
perf_evlist__config_attrs call, because the latter needs possible group
leader links in place.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1352741644-16809-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-record.c | 8 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 11 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-group1 | 4 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-stat-group1 | 6 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall-tp-fields.c | 2 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 8 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 3 |
8 files changed, 20 insertions, 28 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 5783c3225116..371702785d68 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -230,11 +230,15 @@ static int perf_record__open(struct perf_record *rec) | |||
230 | struct perf_record_opts *opts = &rec->opts; | 230 | struct perf_record_opts *opts = &rec->opts; |
231 | int rc = 0; | 231 | int rc = 0; |
232 | 232 | ||
233 | perf_evlist__config_attrs(evlist, opts); | 233 | /* |
234 | 234 | * Set the evsel leader links before we configure attributes, | |
235 | * since some might depend on this info. | ||
236 | */ | ||
235 | if (opts->group) | 237 | if (opts->group) |
236 | perf_evlist__set_leader(evlist); | 238 | perf_evlist__set_leader(evlist); |
237 | 239 | ||
240 | perf_evlist__config_attrs(evlist, opts); | ||
241 | |||
238 | list_for_each_entry(pos, &evlist->entries, node) { | 242 | list_for_each_entry(pos, &evlist->entries, node) { |
239 | struct perf_event_attr *attr = &pos->attr; | 243 | struct perf_event_attr *attr = &pos->attr; |
240 | /* | 244 | /* |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 6888960ef8b8..557081e0c6d9 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -129,8 +129,7 @@ static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS]; | |||
129 | static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS]; | 129 | static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS]; |
130 | static struct stats walltime_nsecs_stats; | 130 | static struct stats walltime_nsecs_stats; |
131 | 131 | ||
132 | static int create_perf_stat_counter(struct perf_evsel *evsel, | 132 | static int create_perf_stat_counter(struct perf_evsel *evsel) |
133 | struct perf_evsel *first) | ||
134 | { | 133 | { |
135 | struct perf_event_attr *attr = &evsel->attr; | 134 | struct perf_event_attr *attr = &evsel->attr; |
136 | bool exclude_guest_missing = false; | 135 | bool exclude_guest_missing = false; |
@@ -153,7 +152,7 @@ retry: | |||
153 | return 0; | 152 | return 0; |
154 | } | 153 | } |
155 | 154 | ||
156 | if (!perf_target__has_task(&target) && (!group || evsel == first)) { | 155 | if (!perf_target__has_task(&target) && (!evsel->leader)) { |
157 | attr->disabled = 1; | 156 | attr->disabled = 1; |
158 | attr->enable_on_exec = 1; | 157 | attr->enable_on_exec = 1; |
159 | } | 158 | } |
@@ -272,7 +271,7 @@ static int read_counter(struct perf_evsel *counter) | |||
272 | static int __run_perf_stat(int argc __maybe_unused, const char **argv) | 271 | static int __run_perf_stat(int argc __maybe_unused, const char **argv) |
273 | { | 272 | { |
274 | unsigned long long t0, t1; | 273 | unsigned long long t0, t1; |
275 | struct perf_evsel *counter, *first; | 274 | struct perf_evsel *counter; |
276 | int status = 0; | 275 | int status = 0; |
277 | int child_ready_pipe[2], go_pipe[2]; | 276 | int child_ready_pipe[2], go_pipe[2]; |
278 | const bool forks = (argc > 0); | 277 | const bool forks = (argc > 0); |
@@ -332,10 +331,8 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv) | |||
332 | if (group) | 331 | if (group) |
333 | perf_evlist__set_leader(evsel_list); | 332 | perf_evlist__set_leader(evsel_list); |
334 | 333 | ||
335 | first = perf_evlist__first(evsel_list); | ||
336 | |||
337 | list_for_each_entry(counter, &evsel_list->entries, node) { | 334 | list_for_each_entry(counter, &evsel_list->entries, node) { |
338 | if (create_perf_stat_counter(counter, first) < 0) { | 335 | if (create_perf_stat_counter(counter) < 0) { |
339 | /* | 336 | /* |
340 | * PPC returns ENXIO for HW counters until 2.6.37 | 337 | * PPC returns ENXIO for HW counters until 2.6.37 |
341 | * (behavior changed with commit b0a873e). | 338 | * (behavior changed with commit b0a873e). |
diff --git a/tools/perf/tests/attr/test-record-group1 b/tools/perf/tests/attr/test-record-group1 index 39bf8609538c..013572f23605 100644 --- a/tools/perf/tests/attr/test-record-group1 +++ b/tools/perf/tests/attr/test-record-group1 | |||
@@ -15,6 +15,4 @@ config=1 | |||
15 | sample_type=327 | 15 | sample_type=327 |
16 | mmap=0 | 16 | mmap=0 |
17 | comm=0 | 17 | comm=0 |
18 | # TODO this is disabled for --group option, enabled otherwise | 18 | enable_on_exec=0 |
19 | # check why.. | ||
20 | enable_on_exec=1 | ||
diff --git a/tools/perf/tests/attr/test-stat-group1 b/tools/perf/tests/attr/test-stat-group1 index 5ae2718de864..2a1f86e4a904 100644 --- a/tools/perf/tests/attr/test-stat-group1 +++ b/tools/perf/tests/attr/test-stat-group1 | |||
@@ -11,7 +11,5 @@ group_fd=-1 | |||
11 | fd=2 | 11 | fd=2 |
12 | group_fd=1 | 12 | group_fd=1 |
13 | config=1 | 13 | config=1 |
14 | # TODO both disabled and enable_on_exec are disabled for --group option, | 14 | disabled=0 |
15 | # enabled otherwise, check why.. | 15 | enable_on_exec=0 |
16 | disabled=1 | ||
17 | enable_on_exec=1 | ||
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c index b05b6a6f01af..1c52fdc1164e 100644 --- a/tools/perf/tests/open-syscall-tp-fields.c +++ b/tools/perf/tests/open-syscall-tp-fields.c | |||
@@ -41,7 +41,7 @@ int test__syscall_open_tp_fields(void) | |||
41 | goto out_delete_evlist; | 41 | goto out_delete_evlist; |
42 | } | 42 | } |
43 | 43 | ||
44 | perf_evsel__config(evsel, &opts, evsel); | 44 | perf_evsel__config(evsel, &opts); |
45 | 45 | ||
46 | evlist->threads->map[0] = getpid(); | 46 | evlist->threads->map[0] = getpid(); |
47 | 47 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index a41dc4a5c2de..04acae0ce697 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -52,15 +52,13 @@ struct perf_evlist *perf_evlist__new(struct cpu_map *cpus, | |||
52 | void perf_evlist__config_attrs(struct perf_evlist *evlist, | 52 | void perf_evlist__config_attrs(struct perf_evlist *evlist, |
53 | struct perf_record_opts *opts) | 53 | struct perf_record_opts *opts) |
54 | { | 54 | { |
55 | struct perf_evsel *evsel, *first; | 55 | struct perf_evsel *evsel; |
56 | 56 | ||
57 | if (evlist->cpus->map[0] < 0) | 57 | if (evlist->cpus->map[0] < 0) |
58 | opts->no_inherit = true; | 58 | opts->no_inherit = true; |
59 | 59 | ||
60 | first = perf_evlist__first(evlist); | ||
61 | |||
62 | list_for_each_entry(evsel, &evlist->entries, node) { | 60 | list_for_each_entry(evsel, &evlist->entries, node) { |
63 | perf_evsel__config(evsel, opts, first); | 61 | perf_evsel__config(evsel, opts); |
64 | 62 | ||
65 | if (evlist->nr_entries > 1) | 63 | if (evlist->nr_entries > 1) |
66 | evsel->attr.sample_type |= PERF_SAMPLE_ID; | 64 | evsel->attr.sample_type |= PERF_SAMPLE_ID; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 618d41140abd..6d4a5f6ed75a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -404,8 +404,8 @@ const char *perf_evsel__name(struct perf_evsel *evsel) | |||
404 | return evsel->name ?: "unknown"; | 404 | return evsel->name ?: "unknown"; |
405 | } | 405 | } |
406 | 406 | ||
407 | void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts, | 407 | void perf_evsel__config(struct perf_evsel *evsel, |
408 | struct perf_evsel *first) | 408 | struct perf_record_opts *opts) |
409 | { | 409 | { |
410 | struct perf_event_attr *attr = &evsel->attr; | 410 | struct perf_event_attr *attr = &evsel->attr; |
411 | int track = !evsel->idx; /* only the first counter needs these */ | 411 | int track = !evsel->idx; /* only the first counter needs these */ |
@@ -486,10 +486,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts, | |||
486 | attr->mmap = track; | 486 | attr->mmap = track; |
487 | attr->comm = track; | 487 | attr->comm = track; |
488 | 488 | ||
489 | if (perf_target__none(&opts->target) && | 489 | if (perf_target__none(&opts->target) && (!evsel->leader)) |
490 | (!opts->group || evsel == first)) { | ||
491 | attr->enable_on_exec = 1; | 490 | attr->enable_on_exec = 1; |
492 | } | ||
493 | } | 491 | } |
494 | 492 | ||
495 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) | 493 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 6f94d6dea00f..32d7ec78dedc 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -92,8 +92,7 @@ void perf_evsel__exit(struct perf_evsel *evsel); | |||
92 | void perf_evsel__delete(struct perf_evsel *evsel); | 92 | void perf_evsel__delete(struct perf_evsel *evsel); |
93 | 93 | ||
94 | void perf_evsel__config(struct perf_evsel *evsel, | 94 | void perf_evsel__config(struct perf_evsel *evsel, |
95 | struct perf_record_opts *opts, | 95 | struct perf_record_opts *opts); |
96 | struct perf_evsel *first); | ||
97 | 96 | ||
98 | bool perf_evsel__is_cache_op_valid(u8 type, u8 op); | 97 | bool perf_evsel__is_cache_op_valid(u8 type, u8 op); |
99 | 98 | ||