diff options
author | Andi Kleen <ak@linux.intel.com> | 2013-08-02 20:41:10 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-08-07 16:35:28 -0400 |
commit | e2407bef968d64a28465561832686636d3380bf9 (patch) | |
tree | 416249ed0b2fc49d7e9e906b3357ee0872f1b74e /tools/perf/util/evsel.c | |
parent | 5c6974f49832a55edc9ca744323778947c104ca0 (diff) |
perf evsel: Add support for enabling counters
Add support for enabling already set up counters by using an
ioctl. I share some code with the filter setup.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1375490473-1503-3-git-send-email-andi@firstfloor.org
[ Fixed up 'err' variable indentation ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 21 |
1 files changed, 18 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)); |