diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-03 13:39:04 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-03 13:39:04 -0500 |
commit | 69aad6f1ee69546dea8535ab8f3da9f445d57328 (patch) | |
tree | b328ec140a6a90703a049fcc661d623025d7e81f /tools/perf/util/evsel.c | |
parent | 56f4c400349157289b474a3fd49ee96acab0a4d7 (diff) |
perf tools: Introduce event selectors
Out of ad-hoc code and global arrays with hard coded sizes.
This is the first step on having a library that will be first
used on regression tests in the 'perf test' tool.
[acme@felicio linux]$ size /tmp/perf.before
text data bss dec hex filename
1273776 97384 5104416 6475576 62cf38 /tmp/perf.before
[acme@felicio linux]$ size /tmp/perf.new
text data bss dec hex filename
1275422 97416 1392416 2765254 2a31c6 /tmp/perf.new
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>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c new file mode 100644 index 000000000000..6539ec912c70 --- /dev/null +++ b/tools/perf/util/evsel.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include "evsel.h" | ||
2 | #include "util.h" | ||
3 | |||
4 | struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx) | ||
5 | { | ||
6 | struct perf_evsel *evsel = zalloc(sizeof(*evsel)); | ||
7 | |||
8 | if (evsel != NULL) { | ||
9 | evsel->idx = idx; | ||
10 | evsel->attr.type = type; | ||
11 | evsel->attr.config = config; | ||
12 | INIT_LIST_HEAD(&evsel->node); | ||
13 | } | ||
14 | |||
15 | return evsel; | ||
16 | } | ||
17 | |||
18 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) | ||
19 | { | ||
20 | evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int)); | ||
21 | return evsel->fd != NULL ? 0 : -ENOMEM; | ||
22 | } | ||
23 | |||
24 | void perf_evsel__free_fd(struct perf_evsel *evsel) | ||
25 | { | ||
26 | xyarray__delete(evsel->fd); | ||
27 | evsel->fd = NULL; | ||
28 | } | ||
29 | |||
30 | void perf_evsel__delete(struct perf_evsel *evsel) | ||
31 | { | ||
32 | assert(list_empty(&evsel->node)); | ||
33 | xyarray__delete(evsel->fd); | ||
34 | free(evsel); | ||
35 | } | ||