aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evlist.c19
-rw-r--r--tools/perf/util/evlist.h1
2 files changed, 13 insertions, 7 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 5b012b8d7a14..1344fbd2472e 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -721,10 +721,20 @@ void perf_evlist__set_selected(struct perf_evlist *evlist,
721 evlist->selected = evsel; 721 evlist->selected = evsel;
722} 722}
723 723
724void perf_evlist__close(struct perf_evlist *evlist)
725{
726 struct perf_evsel *evsel;
727 int ncpus = cpu_map__nr(evlist->cpus);
728 int nthreads = thread_map__nr(evlist->threads);
729
730 list_for_each_entry_reverse(evsel, &evlist->entries, node)
731 perf_evsel__close(evsel, ncpus, nthreads);
732}
733
724int perf_evlist__open(struct perf_evlist *evlist) 734int perf_evlist__open(struct perf_evlist *evlist)
725{ 735{
726 struct perf_evsel *evsel; 736 struct perf_evsel *evsel;
727 int err, ncpus, nthreads; 737 int err;
728 738
729 list_for_each_entry(evsel, &evlist->entries, node) { 739 list_for_each_entry(evsel, &evlist->entries, node) {
730 err = perf_evsel__open(evsel, evlist->cpus, evlist->threads); 740 err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
@@ -734,12 +744,7 @@ int perf_evlist__open(struct perf_evlist *evlist)
734 744
735 return 0; 745 return 0;
736out_err: 746out_err:
737 ncpus = cpu_map__nr(evlist->cpus); 747 perf_evlist__close(evlist);
738 nthreads = thread_map__nr(evlist->threads);
739
740 list_for_each_entry_reverse(evsel, &evlist->entries, node)
741 perf_evsel__close(evsel, ncpus, nthreads);
742
743 errno = -err; 748 errno = -err;
744 return err; 749 return err;
745} 750}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index c096da7d6d58..0583d36252be 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -81,6 +81,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
81union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); 81union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
82 82
83int perf_evlist__open(struct perf_evlist *evlist); 83int perf_evlist__open(struct perf_evlist *evlist);
84void perf_evlist__close(struct perf_evlist *evlist);
84 85
85void perf_evlist__config(struct perf_evlist *evlist, 86void perf_evlist__config(struct perf_evlist *evlist,
86 struct perf_record_opts *opts); 87 struct perf_record_opts *opts);