Skip to content

Commit

Permalink
libperf: Move the pollfd allocation from tools/perf to libperf
Browse files Browse the repository at this point in the history
It's needed in libperf only, so move it to the perf_evlist__mmap_ops()
function.

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-24-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 285aaea commit 230662e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tools/perf/lib/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void perf_evlist__init(struct perf_evlist *evlist)
INIT_HLIST_HEAD(&evlist->heads[i]);
INIT_LIST_HEAD(&evlist->entries);
evlist->nr_entries = 0;
fdarray__init(&evlist->pollfd, 64);
}

static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
Expand Down Expand Up @@ -114,6 +115,7 @@ void perf_evlist__delete(struct perf_evlist *evlist)
return;

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

Expand Down Expand Up @@ -525,6 +527,9 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist,
return -ENOMEM;
}

if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0)
return -ENOMEM;

if (perf_cpu_map__empty(cpus))
return mmap_per_thread(evlist, ops, mp);

Expand Down
4 changes: 0 additions & 4 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
{
perf_evlist__init(&evlist->core);
perf_evlist__set_maps(&evlist->core, cpus, threads);
fdarray__init(&evlist->core.pollfd, 64);
evlist->workload.pid = -1;
evlist->bkw_mmap_state = BKW_MMAP_NOTREADY;
}
Expand Down Expand Up @@ -829,9 +828,6 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
if (!evlist->mmap)
return -ENOMEM;

if (evlist->core.pollfd.entries == NULL && perf_evlist__alloc_pollfd(&evlist->core) < 0)
return -ENOMEM;

evlist->core.mmap_len = evlist__mmap_size(pages);
pr_debug("mmap size %zuB\n", evlist->core.mmap_len);
mp.core.mask = evlist->core.mmap_len - page_size - 1;
Expand Down

0 comments on commit 230662e

Please sign in to comment.