diff options
Diffstat (limited to 'tools')
-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 | ||