Skip to content

Commit

Permalink
libperf: Introduce perf_evlist__exit()
Browse files Browse the repository at this point in the history
Add the perf_evlist__exit() function, so far it's not exported and added
only for internal use for perf and libperf.

USe it to release cpus/threads and pollfd array.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191007125344.14268-25-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Oct 10, 2019
1 parent 230662e commit 93dd6e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
12 changes: 11 additions & 1 deletion tools/perf/lib/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,23 @@ perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *prev)
return next;
}

void perf_evlist__exit(struct perf_evlist *evlist)
{
perf_cpu_map__put(evlist->cpus);
perf_thread_map__put(evlist->threads);
evlist->cpus = NULL;
evlist->threads = NULL;
fdarray__exit(&evlist->pollfd);
}

void perf_evlist__delete(struct perf_evlist *evlist)
{
if (evlist == NULL)
return;

perf_evlist__munmap(evlist);
fdarray__exit(&evlist->pollfd);
perf_evlist__close(evlist);
perf_evlist__exit(evlist);
free(evlist);
}

Expand Down
2 changes: 2 additions & 0 deletions tools/perf/lib/include/internal/evlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist,
struct perf_evlist_mmap_ops *ops,
struct perf_mmap_param *mp);

void perf_evlist__exit(struct perf_evlist *evlist);

/**
* __perf_evlist__for_each_entry - iterate thru all the evsels
* @list: list_head instance to iterate
Expand Down
6 changes: 1 addition & 5 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void evlist__exit(struct evlist *evlist)
{
zfree(&evlist->mmap);
zfree(&evlist->overwrite_mmap);
fdarray__exit(&evlist->core.pollfd);
perf_evlist__exit(&evlist->core);
}

void evlist__delete(struct evlist *evlist)
Expand All @@ -148,10 +148,6 @@ void evlist__delete(struct evlist *evlist)

evlist__munmap(evlist);
evlist__close(evlist);
perf_cpu_map__put(evlist->core.cpus);
perf_thread_map__put(evlist->core.threads);
evlist->core.cpus = NULL;
evlist->core.threads = NULL;
evlist__purge(evlist);
evlist__exit(evlist);
free(evlist);
Expand Down

0 comments on commit 93dd6e2

Please sign in to comment.