perf evlist: Introduce perf_evlist__close()

It's a pair of perf_evlist__open().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1363326533-3310-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Namhyung Kim 2013-03-15 14:48:48 +09:00 committed by Arnaldo Carvalho de Melo
parent 736b05a046
commit a74b4b66cc
2 changed files with 13 additions and 7 deletions

View File

@ -721,10 +721,20 @@ void perf_evlist__set_selected(struct perf_evlist *evlist,
evlist->selected = evsel; evlist->selected = evsel;
} }
void perf_evlist__close(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;
int ncpus = cpu_map__nr(evlist->cpus);
int nthreads = thread_map__nr(evlist->threads);
list_for_each_entry_reverse(evsel, &evlist->entries, node)
perf_evsel__close(evsel, ncpus, nthreads);
}
int perf_evlist__open(struct perf_evlist *evlist) int perf_evlist__open(struct perf_evlist *evlist)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
int err, ncpus, nthreads; int err;
list_for_each_entry(evsel, &evlist->entries, node) { list_for_each_entry(evsel, &evlist->entries, node) {
err = perf_evsel__open(evsel, evlist->cpus, evlist->threads); err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
@ -734,12 +744,7 @@ int perf_evlist__open(struct perf_evlist *evlist)
return 0; return 0;
out_err: out_err:
ncpus = cpu_map__nr(evlist->cpus); perf_evlist__close(evlist);
nthreads = thread_map__nr(evlist->threads);
list_for_each_entry_reverse(evsel, &evlist->entries, node)
perf_evsel__close(evsel, ncpus, nthreads);
errno = -err; errno = -err;
return err; return err;
} }

View File

@ -81,6 +81,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
int perf_evlist__open(struct perf_evlist *evlist); int perf_evlist__open(struct perf_evlist *evlist);
void perf_evlist__close(struct perf_evlist *evlist);
void perf_evlist__config(struct perf_evlist *evlist, void perf_evlist__config(struct perf_evlist *evlist,
struct perf_record_opts *opts); struct perf_record_opts *opts);