Skip to content

Commit ce4326d

Browse files
David Sharpacmel
authored andcommitted
perf record: Set PERF_RECORD_PERIOD if attr->freq is set.
evsel__config() would only set PERF_RECORD_PERIOD if it set attr->freq from perf record options. When it is set by libpfm events, it would not get set. This changes evsel__config to see if attr->freq is set outside of whether or not it changes attr->freq itself. Signed-off-by: David Sharp <dhsharp@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrii Nakryiko <andriin@fb.com> Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Fastabend <john.fastabend@gmail.com> Cc: KP Singh <kpsingh@chromium.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Song Liu <songliubraving@fb.com> Cc: Stephane Eranian <eranian@google.com> Cc: Yonghong Song <yhs@fb.com> Cc: david sharp <dhsharp@google.com> Link: http://lore.kernel.org/lkml/20200912025655.1337192-2-irogers@google.com Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent d2c7350 commit ce4326d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/perf/util/evsel.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,18 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
979979
if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
980980
opts->user_interval != ULLONG_MAX)) {
981981
if (opts->freq) {
982-
evsel__set_sample_bit(evsel, PERIOD);
983982
attr->freq = 1;
984983
attr->sample_freq = opts->freq;
985984
} else {
986985
attr->sample_period = opts->default_interval;
987986
}
988987
}
988+
/*
989+
* If attr->freq was set (here or earlier), ask for period
990+
* to be sampled.
991+
*/
992+
if (attr->freq)
993+
evsel__set_sample_bit(evsel, PERIOD);
989994

990995
if (opts->no_samples)
991996
attr->sample_freq = 0;

0 commit comments

Comments
 (0)