Skip to content

Commit 5f34278

Browse files
ahunter6acmel
authored andcommitted
perf evlist: Move leader-sampling configuration
Move leader-sampling configuration in preparation for adding support for leader sampling with AUX area events. Committer notes: It only makes sense when configuring an evsel that is part of an evlist, so the only case where it is called outside perf_evlist__config(), in some 'perf test' entry, is safe, and even there we should just use perf_evlist__config(), but since in that case we have just one evsel in the evlist, it is equivalent. Also fixed up this problem: util/record.c: In function ‘perf_evlist__config’: util/record.c:223:3: error: too many arguments to function ‘perf_evsel__config_leader_sampling’ 223 | perf_evsel__config_leader_sampling(evsel, evlist); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ util/record.c:170:13: note: declared here 170 | static void perf_evsel__config_leader_sampling(struct evsel *evsel) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lore.kernel.org/lkml/20200401101613.6201-14-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent e12ee9f commit 5f34278

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

tools/perf/util/evsel.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,25 +1002,6 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
10021002
}
10031003
}
10041004

1005-
/*
1006-
* Disable sampling for all group members other
1007-
* than leader in case leader 'leads' the sampling.
1008-
*/
1009-
if ((leader != evsel) && leader->sample_read) {
1010-
attr->freq = 0;
1011-
attr->sample_freq = 0;
1012-
attr->sample_period = 0;
1013-
attr->write_backward = 0;
1014-
1015-
/*
1016-
* We don't get sample for slave events, we make them
1017-
* when delivering group leader sample. Set the slave
1018-
* event to follow the master sample_type to ease up
1019-
* report.
1020-
*/
1021-
attr->sample_type = leader->core.attr.sample_type;
1022-
}
1023-
10241005
if (opts->no_samples)
10251006
attr->sample_freq = 0;
10261007

tools/perf/util/record.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@ bool perf_can_aux_sample(void)
167167
return true;
168168
}
169169

170+
static void perf_evsel__config_leader_sampling(struct evsel *evsel)
171+
{
172+
struct perf_event_attr *attr = &evsel->core.attr;
173+
struct evsel *leader = evsel->leader;
174+
175+
/*
176+
* Disable sampling for all group members other
177+
* than leader in case leader 'leads' the sampling.
178+
*/
179+
if (leader != evsel && leader->sample_read) {
180+
attr->freq = 0;
181+
attr->sample_freq = 0;
182+
attr->sample_period = 0;
183+
attr->write_backward = 0;
184+
185+
/*
186+
* We don't get sample for slave events, we make them
187+
* when delivering group leader sample. Set the slave
188+
* event to follow the master sample_type to ease up
189+
* report.
190+
*/
191+
attr->sample_type = leader->core.attr.sample_type;
192+
}
193+
}
194+
170195
void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
171196
struct callchain_param *callchain)
172197
{
@@ -193,6 +218,10 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
193218
evsel->core.attr.comm_exec = 1;
194219
}
195220

221+
/* Configure leader sampling here now that the sample type is known */
222+
evlist__for_each_entry(evlist, evsel)
223+
perf_evsel__config_leader_sampling(evsel);
224+
196225
if (opts->full_auxtrace) {
197226
/*
198227
* Need to be able to synthesize and parse selected events with

0 commit comments

Comments
 (0)