diff options
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r-- | tools/perf/util/evlist.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 190c64c6e26..d852cefa20d 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/hash.h> | 19 | #include <linux/hash.h> |
20 | 20 | ||
21 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | 21 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
22 | #define SID(e, x, y) xyarray__entry(e->id, x, y) | 22 | #define SID(e, x, y) xyarray__entry(e->sample_id, x, y) |
23 | 23 | ||
24 | void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, | 24 | void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, |
25 | struct thread_map *threads) | 25 | struct thread_map *threads) |
@@ -106,8 +106,9 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd) | |||
106 | evlist->nr_fds++; | 106 | evlist->nr_fds++; |
107 | } | 107 | } |
108 | 108 | ||
109 | void perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, | 109 | static void perf_evlist__id_hash(struct perf_evlist *evlist, |
110 | int cpu, int thread, u64 id) | 110 | struct perf_evsel *evsel, |
111 | int cpu, int thread, u64 id) | ||
111 | { | 112 | { |
112 | int hash; | 113 | int hash; |
113 | struct perf_sample_id *sid = SID(evsel, cpu, thread); | 114 | struct perf_sample_id *sid = SID(evsel, cpu, thread); |
@@ -118,9 +119,16 @@ void perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, | |||
118 | hlist_add_head(&sid->node, &evlist->heads[hash]); | 119 | hlist_add_head(&sid->node, &evlist->heads[hash]); |
119 | } | 120 | } |
120 | 121 | ||
121 | static int perf_evlist__id_hash_fd(struct perf_evlist *evlist, | 122 | void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel, |
122 | struct perf_evsel *evsel, | 123 | int cpu, int thread, u64 id) |
123 | int cpu, int thread, int fd) | 124 | { |
125 | perf_evlist__id_hash(evlist, evsel, cpu, thread, id); | ||
126 | evsel->id[evsel->ids++] = id; | ||
127 | } | ||
128 | |||
129 | static int perf_evlist__id_add_fd(struct perf_evlist *evlist, | ||
130 | struct perf_evsel *evsel, | ||
131 | int cpu, int thread, int fd) | ||
124 | { | 132 | { |
125 | u64 read_data[4] = { 0, }; | 133 | u64 read_data[4] = { 0, }; |
126 | int id_idx = 1; /* The first entry is the counter value */ | 134 | int id_idx = 1; /* The first entry is the counter value */ |
@@ -134,7 +142,7 @@ static int perf_evlist__id_hash_fd(struct perf_evlist *evlist, | |||
134 | if (evsel->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) | 142 | if (evsel->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) |
135 | ++id_idx; | 143 | ++id_idx; |
136 | 144 | ||
137 | perf_evlist__id_hash(evlist, evsel, cpu, thread, read_data[id_idx]); | 145 | perf_evlist__id_add(evlist, evsel, cpu, thread, read_data[id_idx]); |
138 | return 0; | 146 | return 0; |
139 | } | 147 | } |
140 | 148 | ||
@@ -292,7 +300,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) | |||
292 | 300 | ||
293 | list_for_each_entry(evsel, &evlist->entries, node) { | 301 | list_for_each_entry(evsel, &evlist->entries, node) { |
294 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | 302 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && |
295 | evsel->id == NULL && | 303 | evsel->sample_id == NULL && |
296 | perf_evsel__alloc_id(evsel, cpus->nr, threads->nr) < 0) | 304 | perf_evsel__alloc_id(evsel, cpus->nr, threads->nr) < 0) |
297 | return -ENOMEM; | 305 | return -ENOMEM; |
298 | 306 | ||
@@ -308,7 +316,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) | |||
308 | goto out_unmap; | 316 | goto out_unmap; |
309 | 317 | ||
310 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | 318 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && |
311 | perf_evlist__id_hash_fd(evlist, evsel, cpu, thread, fd) < 0) | 319 | perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0) |
312 | goto out_unmap; | 320 | goto out_unmap; |
313 | } | 321 | } |
314 | } | 322 | } |