summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-12 01:30:02 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-22 22:56:28 +0100
commit5c581041cf97aa7980b442de81ddea8273d6dcde (patch)
treeceb2f13de102215d151adf7aaab975bd0db6076b /tools/perf/util
parentperf evsel: Introduce perf_evlist (diff)
downloadlinux-5c581041cf97aa7980b442de81ddea8273d6dcde.tar.xz
linux-5c581041cf97aa7980b442de81ddea8273d6dcde.zip
perf evlist: Adopt the pollfd array
Allocating just the space needed for nr_cpus * nr_threads * nr_evsels, not the MAX_NR_CPUS and counters. LKML-Reference: <new-submission> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evlist.c9
-rw-r--r--tools/perf/util/evlist.h6
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7b4faec23737..2abf949259d0 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1,3 +1,4 @@
+#include <poll.h>
#include "evlist.h"
#include "evsel.h"
#include "util.h"
@@ -28,6 +29,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
void perf_evlist__delete(struct perf_evlist *evlist)
{
perf_evlist__purge(evlist);
+ free(evlist->pollfd);
free(evlist);
}
@@ -51,3 +53,10 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
perf_evlist__add(evlist, evsel);
return 0;
}
+
+int perf_evlist__alloc_pollfd(struct perf_evlist *evlist, int ncpus, int nthreads)
+{
+ int nfds = ncpus * nthreads * evlist->nr_entries;
+ evlist->pollfd = malloc(sizeof(struct pollfd) * nfds);
+ return evlist->pollfd != NULL ? 0 : -ENOMEM;
+}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 48db91a8abf3..a7d7e122e3c6 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -3,9 +3,13 @@
#include <linux/list.h>
+struct pollfd;
+
struct perf_evlist {
struct list_head entries;
int nr_entries;
+ int nr_fds;
+ struct pollfd *pollfd;
};
struct perf_evsel;
@@ -16,4 +20,6 @@ void perf_evlist__delete(struct perf_evlist *evlist);
void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
int perf_evlist__add_default(struct perf_evlist *evlist);
+int perf_evlist__alloc_pollfd(struct perf_evlist *evlist, int ncpus, int nthreads);
+
#endif /* __PERF_EVLIST_H */