aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-record.c8
-rw-r--r--tools/perf/builtin-stat.c11
-rw-r--r--tools/perf/tests/attr/test-record-group14
-rw-r--r--tools/perf/tests/attr/test-stat-group16
-rw-r--r--tools/perf/tests/open-syscall-tp-fields.c2
-rw-r--r--tools/perf/util/evlist.c6
-rw-r--r--tools/perf/util/evsel.c8
-rw-r--r--tools/perf/util/evsel.h3
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];
129static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS]; 129static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS];
130static struct stats walltime_nsecs_stats; 130static struct stats walltime_nsecs_stats;
131 131
132static int create_perf_stat_counter(struct perf_evsel *evsel, 132static 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)
272static int __run_perf_stat(int argc __maybe_unused, const char **argv) 271static 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
15sample_type=327 15sample_type=327
16mmap=0 16mmap=0
17comm=0 17comm=0
18# TODO this is disabled for --group option, enabled otherwise 18enable_on_exec=0
19# check why..
20enable_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
11fd=2 11fd=2
12group_fd=1 12group_fd=1
13config=1 13config=1
14# TODO both disabled and enable_on_exec are disabled for --group option, 14disabled=0
15# enabled otherwise, check why.. 15enable_on_exec=0
16disabled=1
17enable_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,
52void perf_evlist__config_attrs(struct perf_evlist *evlist, 52void 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
407void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts, 407void 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
495int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) 493int 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);
92void perf_evsel__delete(struct perf_evsel *evsel); 92void perf_evsel__delete(struct perf_evsel *evsel);
93 93
94void perf_evsel__config(struct perf_evsel *evsel, 94void 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
98bool perf_evsel__is_cache_op_valid(u8 type, u8 op); 97bool perf_evsel__is_cache_op_valid(u8 type, u8 op);
99 98