aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-10-20 08:04:41 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-10-22 11:37:45 -0400
commitb7e8452b860c299f342a012922bdd9ab8f2bb722 (patch)
treebc5d86371df6c86237836ec0b62294bca7f86bb9
parent2fda5ada07f36f6cde39a52e7f05d86ea8ffdc33 (diff)
perf evsel: Mark a evsel as disabled when asking the kernel do disable it
Because there may be more such events in the ring buffer that should be discarded when an app decides to stop considering them. At some point we'll do this with eBPF, this way we stop them at origin, before they are placed in the ring buffer. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-uzufuxws4hufigx07ue1dpv6@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/evlist.c2
-rw-r--r--tools/perf/util/evsel.c23
-rw-r--r--tools/perf/util/evsel.h1
3 files changed, 19 insertions, 7 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index be440df29615..e88e6f9b1463 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -358,7 +358,7 @@ void perf_evlist__disable(struct perf_evlist *evlist)
358 struct perf_evsel *pos; 358 struct perf_evsel *pos;
359 359
360 evlist__for_each_entry(evlist, pos) { 360 evlist__for_each_entry(evlist, pos) {
361 if (!perf_evsel__is_group_leader(pos) || !pos->fd) 361 if (pos->disabled || !perf_evsel__is_group_leader(pos) || !pos->fd)
362 continue; 362 continue;
363 perf_evsel__disable(pos); 363 perf_evsel__disable(pos);
364 } 364 }
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 7e95ec1c19a8..6d187059a373 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1207,16 +1207,27 @@ int perf_evsel__append_addr_filter(struct perf_evsel *evsel, const char *filter)
1207 1207
1208int perf_evsel__enable(struct perf_evsel *evsel) 1208int perf_evsel__enable(struct perf_evsel *evsel)
1209{ 1209{
1210 return perf_evsel__run_ioctl(evsel, 1210 int err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, 0);
1211 PERF_EVENT_IOC_ENABLE, 1211
1212 0); 1212 if (!err)
1213 evsel->disabled = false;
1214
1215 return err;
1213} 1216}
1214 1217
1215int perf_evsel__disable(struct perf_evsel *evsel) 1218int perf_evsel__disable(struct perf_evsel *evsel)
1216{ 1219{
1217 return perf_evsel__run_ioctl(evsel, 1220 int err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, 0);
1218 PERF_EVENT_IOC_DISABLE, 1221 /*
1219 0); 1222 * We mark it disabled here so that tools that disable a event can
1223 * ignore events after they disable it. I.e. the ring buffer may have
1224 * already a few more events queued up before the kernel got the stop
1225 * request.
1226 */
1227 if (!err)
1228 evsel->disabled = true;
1229
1230 return err;
1220} 1231}
1221 1232
1222int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads) 1233int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads)
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index ad5d615c6db6..4ef50f157b50 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -122,6 +122,7 @@ struct perf_evsel {
122 bool snapshot; 122 bool snapshot;
123 bool supported; 123 bool supported;
124 bool needs_swap; 124 bool needs_swap;
125 bool disabled;
125 bool no_aux_samples; 126 bool no_aux_samples;
126 bool immediate; 127 bool immediate;
127 bool system_wide; 128 bool system_wide;