Skip to content

Commit 3606c0e

Browse files
German Gomezacmel
authored andcommitted
perf evsel: Override attr->sample_period for non-libpfm4 events
A previous patch preventing "attr->sample_period" values from being overridden in pfm events changed a related behaviour in arm-spe. Before said patch: perf record -c 10000 -e arm_spe_0// -- sleep 1 Would yield an SPE event with period=10000. After the patch, the period in "-c 10000" was being ignored because the arm-spe code initializes sample_period to a non-zero value. This patch restores the previous behaviour for non-libpfm4 events. Fixes: ae5dcc8 (“perf record: Prevent override of attr->sample_period for libpfm4 events”) Reported-by: Chase Conklin <chase.conklin@arm.com> Signed-off-by: German Gomez <german.gomez@arm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Fastabend <john.fastabend@gmail.com> Cc: KP Singh <kpsingh@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Song Liu <songliubraving@fb.com> Cc: Stephane Eranian <eranian@google.com> Cc: Yonghong Song <yhs@fb.com> Cc: bpf@vger.kernel.org Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20220118144054.2541-1-german.gomez@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 24ead7c commit 3606c0e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tools/perf/util/evsel.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,17 @@ void __weak arch_evsel__fixup_new_cycles(struct perf_event_attr *attr __maybe_un
10641064
{
10651065
}
10661066

1067+
static void evsel__set_default_freq_period(struct record_opts *opts,
1068+
struct perf_event_attr *attr)
1069+
{
1070+
if (opts->freq) {
1071+
attr->freq = 1;
1072+
attr->sample_freq = opts->freq;
1073+
} else {
1074+
attr->sample_period = opts->default_interval;
1075+
}
1076+
}
1077+
10671078
/*
10681079
* The enable_on_exec/disabled value strategy:
10691080
*
@@ -1130,14 +1141,12 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
11301141
* We default some events to have a default interval. But keep
11311142
* it a weak assumption overridable by the user.
11321143
*/
1133-
if (!attr->sample_period) {
1134-
if (opts->freq) {
1135-
attr->freq = 1;
1136-
attr->sample_freq = opts->freq;
1137-
} else {
1138-
attr->sample_period = opts->default_interval;
1139-
}
1140-
}
1144+
if ((evsel->is_libpfm_event && !attr->sample_period) ||
1145+
(!evsel->is_libpfm_event && (!attr->sample_period ||
1146+
opts->user_freq != UINT_MAX ||
1147+
opts->user_interval != ULLONG_MAX)))
1148+
evsel__set_default_freq_period(opts, attr);
1149+
11411150
/*
11421151
* If attr->freq was set (here or earlier), ask for period
11431152
* to be sampled.

0 commit comments

Comments
 (0)