diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-04 20:29:39 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-06 11:10:45 -0500 |
commit | 3d3b5e95997208067c963923db90ed1517565d14 (patch) | |
tree | bd48dc7bd13bd8532c795064a1aa1c74ce74d587 | |
parent | 60098917c06d154d06ce030c125266eab9e60768 (diff) |
perf evlist: Split perf_evlist__id_hash
The previous situation was to receive an fd from where to read the event
ID.
Spin off a routine for when we have the ID handy, not having to read it
from some fd.
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>
-rw-r--r-- | tools/perf/util/evlist.c | 28 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 3 |
2 files changed, 21 insertions, 10 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 030ae7f05e03..190c64c6e266 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -106,12 +106,24 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd) | |||
106 | evlist->nr_fds++; | 106 | evlist->nr_fds++; |
107 | } | 107 | } |
108 | 108 | ||
109 | static int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, | 109 | void perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, |
110 | int cpu, int thread, int fd) | 110 | int cpu, int thread, u64 id) |
111 | { | ||
112 | int hash; | ||
113 | struct perf_sample_id *sid = SID(evsel, cpu, thread); | ||
114 | |||
115 | sid->id = id; | ||
116 | sid->evsel = evsel; | ||
117 | hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS); | ||
118 | hlist_add_head(&sid->node, &evlist->heads[hash]); | ||
119 | } | ||
120 | |||
121 | static int perf_evlist__id_hash_fd(struct perf_evlist *evlist, | ||
122 | struct perf_evsel *evsel, | ||
123 | int cpu, int thread, int fd) | ||
111 | { | 124 | { |
112 | struct perf_sample_id *sid; | ||
113 | u64 read_data[4] = { 0, }; | 125 | u64 read_data[4] = { 0, }; |
114 | int hash, id_idx = 1; /* The first entry is the counter value */ | 126 | int id_idx = 1; /* The first entry is the counter value */ |
115 | 127 | ||
116 | if (!(evsel->attr.read_format & PERF_FORMAT_ID) || | 128 | if (!(evsel->attr.read_format & PERF_FORMAT_ID) || |
117 | read(fd, &read_data, sizeof(read_data)) == -1) | 129 | read(fd, &read_data, sizeof(read_data)) == -1) |
@@ -122,11 +134,7 @@ static int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *e | |||
122 | if (evsel->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) | 134 | if (evsel->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) |
123 | ++id_idx; | 135 | ++id_idx; |
124 | 136 | ||
125 | sid = SID(evsel, cpu, thread); | 137 | perf_evlist__id_hash(evlist, evsel, cpu, thread, read_data[id_idx]); |
126 | sid->id = read_data[id_idx]; | ||
127 | sid->evsel = evsel; | ||
128 | hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS); | ||
129 | hlist_add_head(&sid->node, &evlist->heads[hash]); | ||
130 | return 0; | 138 | return 0; |
131 | } | 139 | } |
132 | 140 | ||
@@ -300,7 +308,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) | |||
300 | goto out_unmap; | 308 | goto out_unmap; |
301 | 309 | ||
302 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | 310 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && |
303 | perf_evlist__id_hash(evlist, evsel, cpu, thread, fd) < 0) | 311 | perf_evlist__id_hash_fd(evlist, evsel, cpu, thread, fd) < 0) |
304 | goto out_unmap; | 312 | goto out_unmap; |
305 | } | 313 | } |
306 | } | 314 | } |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index b75805aeb7e4..078d51256085 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -38,6 +38,9 @@ void perf_evlist__delete(struct perf_evlist *evlist); | |||
38 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); | 38 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); |
39 | int perf_evlist__add_default(struct perf_evlist *evlist); | 39 | int perf_evlist__add_default(struct perf_evlist *evlist); |
40 | 40 | ||
41 | void perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, | ||
42 | int cpu, int thread, u64 id); | ||
43 | |||
41 | int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); | 44 | int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); |
42 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); | 45 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); |
43 | 46 | ||