diff options
-rw-r--r-- | tools/perf/util/evlist.c | 47 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 |
2 files changed, 49 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 9d863db3f4b2..5dcd28c79c6e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -355,6 +355,53 @@ int perf_evlist__enable_event(struct perf_evlist *evlist, | |||
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
357 | 357 | ||
358 | static int perf_evlist__enable_event_cpu(struct perf_evlist *evlist, | ||
359 | struct perf_evsel *evsel, int cpu) | ||
360 | { | ||
361 | int thread, err; | ||
362 | int nr_threads = perf_evlist__nr_threads(evlist, evsel); | ||
363 | |||
364 | if (!evsel->fd) | ||
365 | return -EINVAL; | ||
366 | |||
367 | for (thread = 0; thread < nr_threads; thread++) { | ||
368 | err = ioctl(FD(evsel, cpu, thread), | ||
369 | PERF_EVENT_IOC_ENABLE, 0); | ||
370 | if (err) | ||
371 | return err; | ||
372 | } | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int perf_evlist__enable_event_thread(struct perf_evlist *evlist, | ||
377 | struct perf_evsel *evsel, | ||
378 | int thread) | ||
379 | { | ||
380 | int cpu, err; | ||
381 | int nr_cpus = cpu_map__nr(evlist->cpus); | ||
382 | |||
383 | if (!evsel->fd) | ||
384 | return -EINVAL; | ||
385 | |||
386 | for (cpu = 0; cpu < nr_cpus; cpu++) { | ||
387 | err = ioctl(FD(evsel, cpu, thread), PERF_EVENT_IOC_ENABLE, 0); | ||
388 | if (err) | ||
389 | return err; | ||
390 | } | ||
391 | return 0; | ||
392 | } | ||
393 | |||
394 | int perf_evlist__enable_event_idx(struct perf_evlist *evlist, | ||
395 | struct perf_evsel *evsel, int idx) | ||
396 | { | ||
397 | bool per_cpu_mmaps = !cpu_map__empty(evlist->cpus); | ||
398 | |||
399 | if (per_cpu_mmaps) | ||
400 | return perf_evlist__enable_event_cpu(evlist, evsel, idx); | ||
401 | else | ||
402 | return perf_evlist__enable_event_thread(evlist, evsel, idx); | ||
403 | } | ||
404 | |||
358 | static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) | 405 | static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) |
359 | { | 406 | { |
360 | int nr_cpus = cpu_map__nr(evlist->cpus); | 407 | int nr_cpus = cpu_map__nr(evlist->cpus); |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index e0084f90c271..106de53a6a74 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -122,6 +122,8 @@ int perf_evlist__disable_event(struct perf_evlist *evlist, | |||
122 | struct perf_evsel *evsel); | 122 | struct perf_evsel *evsel); |
123 | int perf_evlist__enable_event(struct perf_evlist *evlist, | 123 | int perf_evlist__enable_event(struct perf_evlist *evlist, |
124 | struct perf_evsel *evsel); | 124 | struct perf_evsel *evsel); |
125 | int perf_evlist__enable_event_idx(struct perf_evlist *evlist, | ||
126 | struct perf_evsel *evsel, int idx); | ||
125 | 127 | ||
126 | void perf_evlist__set_selected(struct perf_evlist *evlist, | 128 | void perf_evlist__set_selected(struct perf_evlist *evlist, |
127 | struct perf_evsel *evsel); | 129 | struct perf_evsel *evsel); |