summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2019-08-06 13:21:53 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-09-25 09:51:49 -0300
commit31f67fc462a9e5df3b900924c2bf649c7bc63af8 (patch)
tree87cc835c17edfd51fc8ce898528d159587f40dc2 /tools/perf/util
parent379dd98c3d77de920f09f1933592982d200e076a (diff)
downloadlinux-31f67fc462a9e5df3b900924c2bf649c7bc63af8.tar.gz
linux-31f67fc462a9e5df3b900924c2bf649c7bc63af8.tar.bz2
linux-31f67fc462a9e5df3b900924c2bf649c7bc63af8.zip
libperf: Add perf_evlist__alloc_pollfd() function
Move perf_evlist__alloc_pollfd() from tools/perf to libperf, it will be used in the following patches. 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 <a.p.zijlstra@chello.nl> Link: http://lore.kernel.org/lkml/20190913132355.21634-37-jolsa@kernel.org [ Added api/fd/array.h include to the lib/evlist.c file ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evlist.c23
-rw-r--r--tools/perf/util/evlist.h1
2 files changed, 1 insertions, 23 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 6069fb52661f..c47f23e7f3c8 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -398,27 +398,6 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,
return perf_evlist__enable_event_thread(evlist, evsel, idx);
}
-int perf_evlist__alloc_pollfd(struct evlist *evlist)
-{
- int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
- int nr_threads = perf_thread_map__nr(evlist->core.threads);
- int nfds = 0;
- struct evsel *evsel;
-
- evlist__for_each_entry(evlist, evsel) {
- if (evsel->core.system_wide)
- nfds += nr_cpus;
- else
- nfds += nr_cpus * nr_threads;
- }
-
- if (fdarray__available_entries(&evlist->core.pollfd) < nfds &&
- fdarray__grow(&evlist->core.pollfd, nfds) < 0)
- return -ENOMEM;
-
- return 0;
-}
-
static int __perf_evlist__add_pollfd(struct evlist *evlist, int fd,
struct mmap *map, short revent)
{
@@ -944,7 +923,7 @@ 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) < 0)
+ if (evlist->core.pollfd.entries == NULL && perf_evlist__alloc_pollfd(&evlist->core) < 0)
return -ENOMEM;
evlist->core.mmap_len = evlist__mmap_size(pages);
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 80b3361613e5..bebbaa9b6325 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -142,7 +142,6 @@ perf_evlist__find_tracepoint_by_name(struct evlist *evlist,
const char *name);
int perf_evlist__add_pollfd(struct evlist *evlist, int fd);
-int perf_evlist__alloc_pollfd(struct evlist *evlist);
int perf_evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
int perf_evlist__poll(struct evlist *evlist, int timeout);