Skip to content

Commit 49c0ae8

Browse files
olsajiriacmel
authored andcommitted
perf evsel: Fix period/freq terms setup
Stephane reported that we don't set properly PERIOD sample type for events with period term defined. Before: $ perf record -e cpu/cpu-cycles,period=1000/u ls $ perf evlist -v cpu/cpu-cycles,period=1000/u: ... sample_type: IP|TID|TIME|PERIOD, ... After: $ perf record -e cpu/cpu-cycles,period=1000/u ls $ perf evlist -v cpu/cpu-cycles,period=1000/u: ... sample_type: IP|TID|TIME, ... Setting PERIOD sample type based on period term setup. Committer note: When we use -c or a period=N term in the event definition, then we don't need to ask the kernel, for this event, via perf_event_attr.sample_type |= PERF_SAMPLE_PERIOD, to put the event period in each sample for this event, as we know it already, it is in perf_event_attr.sample_period. Reported-by: Stephane Eranian <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Tested-by: Stephane Eranian <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Ahern <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 4053717 commit 49c0ae8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/perf/util/evsel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,14 @@ static void apply_config_terms(struct perf_evsel *evsel,
745745
if (!(term->weak && opts->user_interval != ULLONG_MAX)) {
746746
attr->sample_period = term->val.period;
747747
attr->freq = 0;
748+
perf_evsel__reset_sample_bit(evsel, PERIOD);
748749
}
749750
break;
750751
case PERF_EVSEL__CONFIG_TERM_FREQ:
751752
if (!(term->weak && opts->user_freq != UINT_MAX)) {
752753
attr->sample_freq = term->val.freq;
753754
attr->freq = 1;
755+
perf_evsel__set_sample_bit(evsel, PERIOD);
754756
}
755757
break;
756758
case PERF_EVSEL__CONFIG_TERM_TIME:

0 commit comments

Comments
 (0)