aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evlist.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-03-04 20:29:39 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-06 11:10:45 -0500
commit3d3b5e95997208067c963923db90ed1517565d14 (patch)
treebd48dc7bd13bd8532c795064a1aa1c74ce74d587 /tools/perf/util/evlist.c
parent60098917c06d154d06ce030c125266eab9e60768 (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>
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r--tools/perf/util/evlist.c28
1 files changed, 18 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
109static int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, 109void 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
121static 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 }