diff options
-rw-r--r-- | tools/perf/util/evsel.c | 21 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8f1016186d57..960394ea1e3a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -634,15 +634,15 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) | |||
634 | return evsel->fd != NULL ? 0 : -ENOMEM; | 634 | return evsel->fd != NULL ? 0 : -ENOMEM; |
635 | } | 635 | } |
636 | 636 | ||
637 | int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads, | 637 | static int perf_evsel__run_ioctl(struct perf_evsel *evsel, int ncpus, int nthreads, |
638 | const char *filter) | 638 | int ioc, void *arg) |
639 | { | 639 | { |
640 | int cpu, thread; | 640 | int cpu, thread; |
641 | 641 | ||
642 | for (cpu = 0; cpu < ncpus; cpu++) { | 642 | for (cpu = 0; cpu < ncpus; cpu++) { |
643 | for (thread = 0; thread < nthreads; thread++) { | 643 | for (thread = 0; thread < nthreads; thread++) { |
644 | int fd = FD(evsel, cpu, thread), | 644 | int fd = FD(evsel, cpu, thread), |
645 | err = ioctl(fd, PERF_EVENT_IOC_SET_FILTER, filter); | 645 | err = ioctl(fd, ioc, arg); |
646 | 646 | ||
647 | if (err) | 647 | if (err) |
648 | return err; | 648 | return err; |
@@ -652,6 +652,21 @@ int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads, | |||
652 | return 0; | 652 | return 0; |
653 | } | 653 | } |
654 | 654 | ||
655 | int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads, | ||
656 | const char *filter) | ||
657 | { | ||
658 | return perf_evsel__run_ioctl(evsel, ncpus, nthreads, | ||
659 | PERF_EVENT_IOC_SET_FILTER, | ||
660 | (void *)filter); | ||
661 | } | ||
662 | |||
663 | int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads) | ||
664 | { | ||
665 | return perf_evsel__run_ioctl(evsel, ncpus, nthreads, | ||
666 | PERF_EVENT_IOC_ENABLE, | ||
667 | 0); | ||
668 | } | ||
669 | |||
655 | int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads) | 670 | int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads) |
656 | { | 671 | { |
657 | evsel->sample_id = xyarray__new(ncpus, nthreads, sizeof(struct perf_sample_id)); | 672 | evsel->sample_id = xyarray__new(ncpus, nthreads, sizeof(struct perf_sample_id)); |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 5edc625b6ecd..532a5f925da0 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -146,6 +146,7 @@ void perf_evsel__set_sample_id(struct perf_evsel *evsel); | |||
146 | 146 | ||
147 | int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads, | 147 | int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads, |
148 | const char *filter); | 148 | const char *filter); |
149 | int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads); | ||
149 | 150 | ||
150 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, | 151 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, |
151 | struct cpu_map *cpus); | 152 | struct cpu_map *cpus); |