diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-12 19:39:13 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-22 16:56:29 -0500 |
commit | 70db7533caef02350ec8d6852e589491bca3a951 (patch) | |
tree | 463dadbec60d585cb8c1de84b230378010d5c8b5 /tools/perf/util/evsel.h | |
parent | 115d2d8963a426670ac3ce983fc4c4e001703943 (diff) |
perf evlist: Move the mmap array from perf_evsel
Adopting the new model used in 'perf record', where we don't have a map
per thread per cpu, instead we have an mmap per cpu, established on the
first fd for that cpu and ask the kernel using the
PERF_EVENT_IOC_SET_OUTPUT ioctl to send events for the other fds on that
cpu for the one with the mmap.
The methods moved from perf_evsel to perf_evlist, but for easing review
they were modified in place, in evsel.c, the next patch will move the
migrated methods to evlist.c.
With this 'perf top' now uses the same mmap model used by 'perf record'
and the next patches will make 'perf record' use these new routines,
establishing a common codebase for both tools.
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.h')
-rw-r--r-- | tools/perf/util/evsel.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index c8fbef299436..667ee4e2e35e 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -24,14 +24,25 @@ struct perf_counts { | |||
24 | struct perf_counts_values cpu[]; | 24 | struct perf_counts_values cpu[]; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | struct perf_evsel; | ||
28 | |||
29 | /* | ||
30 | * Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are | ||
31 | * more than one entry in the evlist. | ||
32 | */ | ||
33 | struct perf_sample_id { | ||
34 | struct hlist_node node; | ||
35 | u64 id; | ||
36 | struct perf_evsel *evsel; | ||
37 | }; | ||
38 | |||
27 | struct perf_evsel { | 39 | struct perf_evsel { |
28 | struct list_head node; | 40 | struct list_head node; |
29 | struct perf_event_attr attr; | 41 | struct perf_event_attr attr; |
30 | char *filter; | 42 | char *filter; |
31 | struct xyarray *fd; | 43 | struct xyarray *fd; |
32 | struct xyarray *mmap; | 44 | struct xyarray *id; |
33 | struct perf_counts *counts; | 45 | struct perf_counts *counts; |
34 | size_t mmap_len; | ||
35 | int idx; | 46 | int idx; |
36 | void *priv; | 47 | void *priv; |
37 | }; | 48 | }; |
@@ -44,9 +55,11 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx); | |||
44 | void perf_evsel__delete(struct perf_evsel *evsel); | 55 | void perf_evsel__delete(struct perf_evsel *evsel); |
45 | 56 | ||
46 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); | 57 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); |
58 | int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); | ||
47 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); | 59 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); |
48 | int perf_evsel__alloc_mmap(struct perf_evsel *evsel, int ncpus, int nthreads); | 60 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist, int ncpus); |
49 | void perf_evsel__free_fd(struct perf_evsel *evsel); | 61 | void perf_evsel__free_fd(struct perf_evsel *evsel); |
62 | void perf_evsel__free_id(struct perf_evsel *evsel); | ||
50 | void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); | 63 | void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); |
51 | 64 | ||
52 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, | 65 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, |
@@ -55,10 +68,9 @@ int perf_evsel__open_per_thread(struct perf_evsel *evsel, | |||
55 | struct thread_map *threads, bool group, bool inherit); | 68 | struct thread_map *threads, bool group, bool inherit); |
56 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 69 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
57 | struct thread_map *threads, bool group, bool inherit); | 70 | struct thread_map *threads, bool group, bool inherit); |
58 | int perf_evsel__mmap(struct perf_evsel *evsel, struct cpu_map *cpus, | 71 | int perf_evlist__mmap(struct perf_evlist *evlist, struct cpu_map *cpus, |
59 | struct thread_map *threads, int pages, | 72 | struct thread_map *threads, int pages, bool overwrite); |
60 | struct perf_evlist *evlist); | 73 | void perf_evlist__munmap(struct perf_evlist *evlist, int ncpus); |
61 | void perf_evsel__munmap(struct perf_evsel *evsel, int ncpus, int nthreads); | ||
62 | 74 | ||
63 | #define perf_evsel__match(evsel, t, c) \ | 75 | #define perf_evsel__match(evsel, t, c) \ |
64 | (evsel->attr.type == PERF_TYPE_##t && \ | 76 | (evsel->attr.type == PERF_TYPE_##t && \ |