perf evlist: Avoid frequency mode for the dummy event
Ian Rogers
reviewerPATCH 1/1 perf evlist: Avoid frequency mode for the dummy event
Dummy events are created with an attribute where the period and freq are zero. evsel__config will then see the uninitialized values and initialize them in evsel__default_freq_period. As fequency mode is used by default the dummy event would be set to use frequency mode. However, this has no effect on the dummy event but does cause unnecessary timers/interrupts. Avoid this overhead by setting the period to 1 for dummy events.
evlist__add_aux_dummy calls evlist__add_dummy then sets freq=0 and period=1. This isn't necessary after this change and so the setting is removed.
Fixes 5bae0250237f ("perf evlist: Introduce perf_evlist__new_dummy constructor")
Reported-by Stephane Eranian <[email protected]>
Signed-off-by Ian Rogers <[email protected]>
--- tools/perf/util/evlist.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/evlist.c +3 -2
@@ -251,6 +251,9 @@ static struct evsel *evlist__dummy_event(struct evlist *evlist) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_DUMMY, .size = sizeof(attr), /* to capture ABI version */ + /* Avoid frequency mode for dummy events to avoid associated timers. */ + .freq = 0, + .sample_period = 1, };return evsel__new_idx (&attr, evlist->core.nr_entries);
@@ -277,8 +280,6 @@ struct evsel *evlist__add_aux_dummy(struct evlist *evlist, bool system_wide) evsel->core.attr.exclude_kernel =1 ; evsel->core.attr.exclude_guest =1 ; evsel->core.attr.exclude_hv =1 ; - evsel->core.attr.freq =0 ; - evsel->core.attr.sample_period =1 ; evsel->core.system_wide = system_wide; evsel->no_aux_samples = true; evsel->name =strdup ("dummy:u" );
Signature · 1 line
2.42.0.459.ge4e396fd5e-goog