perf evlist: Add toggle_enable() method
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 2b56bcfb6f4bb0aa0813b6ee1dde8f5b23fce5d4 Gitweb: http://git.kernel.org/tip/2b56bcfb6f4bb0aa0813b6ee1dde8f5b23fce5d4 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 17 Jun 2015 16:40:26 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 17 Jun 2015 16:40:26 -0300
perf evlist: Add toggle_enable() method
For an upcoming feature in 'perf top' we will have a hotkey to enable/disable events, so remember if the events in the list are enabled or disabled and allows toggling this state using a new method.
Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/evlist.c | 9 +++++++++ tools/perf/util/evlist.h | 2 ++ 2 files changed, 11 insertions(+)
tools/perf/util/evlist.c +9 -0
@@ -297,6 +297,8 @@ void perf_evlist__disable(struct perf_evlist *evlist) PERF_EVENT_IOC_DISABLE, 0); } } + + evlist->enabled = false; }void perf_evlist__enable (struct perf_evlist *evlist)
@@ -316,6 +318,13 @@ void perf_evlist__enable(struct perf_evlist *evlist) PERF_EVENT_IOC_ENABLE, 0); } } + + evlist->enabled = true; +} + +void perf_evlist__toggle_enable (struct perf_evlist *evlist) +{ + (evlist->enabled ? perf_evlist__disable : perf_evlist__enable)(evlist); } int perf_evlist__disable_event(struct perf_evlist *evlist,
tools/perf/util/evlist.h +2 -0
@@ -41,6 +41,7 @@ struct perf_evlist {int nr_groups;int nr_mmaps;bool overwrite; +bool enabled;size_t mmap_len;int id_pos;int is_pos;
@@ -139,6 +140,7 @@ void perf_evlist__munmap(struct perf_evlist *evlist);void perf_evlist__disable (struct perf_evlist *evlist);void perf_evlist__enable (struct perf_evlist *evlist); +void perf_evlist__toggle_enable (struct perf_evlist *evlist);int perf_evlist__disable_event (struct perf_evlist *evlist,struct perf_evsel *evsel);