blob: c989583141029d3a42c699766e9abd28fb87b39d [file] [log] [blame]
Xiao Guangrongb8f46c52010-02-03 11:53:14 +08001#define _FILE_OFFSET_BITS 64
2
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02003#include <linux/kernel.h>
4
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -02005#include <byteswap.h>
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02006#include <unistd.h>
7#include <sys/types.h>
Arnaldo Carvalho de Meloa41794c2010-05-18 18:29:23 -03008#include <sys/mman.h>
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02009
10#include "session.h"
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -020011#include "sort.h"
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020012#include "util.h"
13
14static int perf_session__open(struct perf_session *self, bool force)
15{
16 struct stat input_stat;
17
Tom Zanussi8dc58102010-04-01 23:59:15 -050018 if (!strcmp(self->filename, "-")) {
19 self->fd_pipe = true;
20 self->fd = STDIN_FILENO;
21
22 if (perf_header__read(self, self->fd) < 0)
23 pr_err("incompatible file format");
24
25 return 0;
26 }
27
Xiao Guangrongf887f302010-02-04 16:46:42 +080028 self->fd = open(self->filename, O_RDONLY);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020029 if (self->fd < 0) {
Andy Isaacson0f2c3de2010-06-11 20:36:15 -070030 int err = errno;
31
32 pr_err("failed to open %s: %s", self->filename, strerror(err));
33 if (err == ENOENT && !strcmp(self->filename, "perf.data"))
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020034 pr_err(" (try 'perf record' first)");
35 pr_err("\n");
36 return -errno;
37 }
38
39 if (fstat(self->fd, &input_stat) < 0)
40 goto out_close;
41
42 if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) {
43 pr_err("file %s not owned by current user or root\n",
44 self->filename);
45 goto out_close;
46 }
47
48 if (!input_stat.st_size) {
49 pr_info("zero-sized file (%s), nothing to do!\n",
50 self->filename);
51 goto out_close;
52 }
53
Tom Zanussi8dc58102010-04-01 23:59:15 -050054 if (perf_header__read(self, self->fd) < 0) {
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020055 pr_err("incompatible file format");
56 goto out_close;
57 }
58
59 self->size = input_stat.st_size;
60 return 0;
61
62out_close:
63 close(self->fd);
64 self->fd = -1;
65 return -1;
66}
67
Tom Zanussi8dc58102010-04-01 23:59:15 -050068void perf_session__update_sample_type(struct perf_session *self)
69{
70 self->sample_type = perf_header__sample_type(&self->header);
71}
72
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080073int perf_session__create_kernel_maps(struct perf_session *self)
74{
Arnaldo Carvalho de Melod118f8b2010-05-10 12:51:05 -030075 int ret = machine__create_kernel_maps(&self->host_machine);
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080076
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080077 if (ret >= 0)
Arnaldo Carvalho de Melod118f8b2010-05-10 12:51:05 -030078 ret = machines__create_guest_kernel_maps(&self->machines);
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080079 return ret;
80}
81
Arnaldo Carvalho de Melo076c6e452010-08-02 18:18:28 -030082static void perf_session__destroy_kernel_maps(struct perf_session *self)
83{
84 machine__destroy_kernel_maps(&self->host_machine);
85 machines__destroy_guest_kernel_maps(&self->machines);
86}
87
Tom Zanussi454c4072010-05-01 01:41:20 -050088struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe)
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020089{
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020090 size_t len = filename ? strlen(filename) + 1 : 0;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020091 struct perf_session *self = zalloc(sizeof(*self) + len);
92
93 if (self == NULL)
94 goto out;
95
96 if (perf_header__init(&self->header) < 0)
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020097 goto out_free;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020098
99 memcpy(self->filename, filename, len);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -0200100 self->threads = RB_ROOT;
Arnaldo Carvalho de Melo720a3ae2010-06-17 08:37:44 -0300101 INIT_LIST_HEAD(&self->dead_threads);
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300102 self->hists_tree = RB_ROOT;
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -0200103 self->last_match = NULL;
Thomas Gleixner55b44622010-11-30 17:49:46 +0000104 /*
105 * On 64bit we can mmap the data file in one go. No need for tiny mmap
106 * slices. On 32bit we use 32MB.
107 */
108#if BITS_PER_LONG == 64
109 self->mmap_window = ULLONG_MAX;
110#else
111 self->mmap_window = 32 * 1024 * 1024ULL;
112#endif
Arnaldo Carvalho de Melo23346f22010-04-27 21:17:50 -0300113 self->machines = RB_ROOT;
Tom Zanussi454c4072010-05-01 01:41:20 -0500114 self->repipe = repipe;
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000115 INIT_LIST_HEAD(&self->ordered_samples.samples);
Arnaldo Carvalho de Melo1f626bc2010-05-09 19:57:08 -0300116 machine__init(&self->host_machine, "", HOST_KERNEL_ID);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200117
Arnaldo Carvalho de Melo64abebf72010-01-27 21:05:52 -0200118 if (mode == O_RDONLY) {
119 if (perf_session__open(self, force) < 0)
120 goto out_delete;
121 } else if (mode == O_WRONLY) {
122 /*
123 * In O_RDONLY mode this will be performed when reading the
124 * kernel MMAP event, in event__process_mmap().
125 */
126 if (perf_session__create_kernel_maps(self) < 0)
127 goto out_delete;
128 }
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200129
Tom Zanussi8dc58102010-04-01 23:59:15 -0500130 perf_session__update_sample_type(self);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200131out:
132 return self;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200133out_free:
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200134 free(self);
135 return NULL;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200136out_delete:
137 perf_session__delete(self);
138 return NULL;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200139}
140
Arnaldo Carvalho de Melod65a4582010-07-30 18:31:28 -0300141static void perf_session__delete_dead_threads(struct perf_session *self)
142{
143 struct thread *n, *t;
144
145 list_for_each_entry_safe(t, n, &self->dead_threads, node) {
146 list_del(&t->node);
147 thread__delete(t);
148 }
149}
150
151static void perf_session__delete_threads(struct perf_session *self)
152{
153 struct rb_node *nd = rb_first(&self->threads);
154
155 while (nd) {
156 struct thread *t = rb_entry(nd, struct thread, rb_node);
157
158 rb_erase(&t->rb_node, &self->threads);
159 nd = rb_next(nd);
160 thread__delete(t);
161 }
162}
163
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200164void perf_session__delete(struct perf_session *self)
165{
166 perf_header__exit(&self->header);
Arnaldo Carvalho de Melo076c6e452010-08-02 18:18:28 -0300167 perf_session__destroy_kernel_maps(self);
Arnaldo Carvalho de Melod65a4582010-07-30 18:31:28 -0300168 perf_session__delete_dead_threads(self);
169 perf_session__delete_threads(self);
170 machine__exit(&self->host_machine);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200171 close(self->fd);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200172 free(self);
173}
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200174
Arnaldo Carvalho de Melo720a3ae2010-06-17 08:37:44 -0300175void perf_session__remove_thread(struct perf_session *self, struct thread *th)
176{
Arnaldo Carvalho de Melo70597f22010-08-02 18:59:28 -0300177 self->last_match = NULL;
Arnaldo Carvalho de Melo720a3ae2010-06-17 08:37:44 -0300178 rb_erase(&th->rb_node, &self->threads);
179 /*
180 * We may have references to this thread, for instance in some hist_entry
181 * instances, so just move them to a separate list.
182 */
183 list_add_tail(&th->node, &self->dead_threads);
184}
185
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200186static bool symbol__match_parent_regex(struct symbol *sym)
187{
188 if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
189 return 1;
190
191 return 0;
192}
193
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -0300194struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
195 struct thread *thread,
196 struct ip_callchain *chain,
197 struct symbol **parent)
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200198{
199 u8 cpumode = PERF_RECORD_MISC_USER;
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200200 unsigned int i;
Arnaldo Carvalho de Meload5b2172010-04-02 10:04:18 -0300201 struct map_symbol *syms = calloc(chain->nr, sizeof(*syms));
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200202
Arnaldo Carvalho de Meload5b2172010-04-02 10:04:18 -0300203 if (!syms)
204 return NULL;
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200205
206 for (i = 0; i < chain->nr; i++) {
207 u64 ip = chain->ips[i];
208 struct addr_location al;
209
210 if (ip >= PERF_CONTEXT_MAX) {
211 switch (ip) {
212 case PERF_CONTEXT_HV:
213 cpumode = PERF_RECORD_MISC_HYPERVISOR; break;
214 case PERF_CONTEXT_KERNEL:
215 cpumode = PERF_RECORD_MISC_KERNEL; break;
216 case PERF_CONTEXT_USER:
217 cpumode = PERF_RECORD_MISC_USER; break;
218 default:
219 break;
220 }
221 continue;
222 }
223
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800224 al.filtered = false;
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200225 thread__find_addr_location(thread, self, cpumode,
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800226 MAP__FUNCTION, thread->pid, ip, &al, NULL);
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200227 if (al.sym != NULL) {
228 if (sort__has_parent && !*parent &&
229 symbol__match_parent_regex(al.sym))
230 *parent = al.sym;
Arnaldo Carvalho de Melod599db32009-12-15 20:04:42 -0200231 if (!symbol_conf.use_callchain)
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200232 break;
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -0300233 syms[i].map = al.map;
234 syms[i].sym = al.sym;
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -0200235 }
236 }
237
238 return syms;
239}
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200240
241static int process_event_stub(event_t *event __used,
242 struct perf_session *session __used)
243{
244 dump_printf(": unhandled!\n");
245 return 0;
246}
247
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200248static int process_finished_round_stub(event_t *event __used,
249 struct perf_session *session __used,
250 struct perf_event_ops *ops __used)
251{
252 dump_printf(": unhandled!\n");
253 return 0;
254}
255
256static int process_finished_round(event_t *event,
257 struct perf_session *session,
258 struct perf_event_ops *ops);
259
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200260static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
261{
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200262 if (handler->sample == NULL)
263 handler->sample = process_event_stub;
264 if (handler->mmap == NULL)
265 handler->mmap = process_event_stub;
266 if (handler->comm == NULL)
267 handler->comm = process_event_stub;
268 if (handler->fork == NULL)
269 handler->fork = process_event_stub;
270 if (handler->exit == NULL)
271 handler->exit = process_event_stub;
272 if (handler->lost == NULL)
Arnaldo Carvalho de Melo37982ba2010-11-26 18:31:54 -0200273 handler->lost = event__process_lost;
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200274 if (handler->read == NULL)
275 handler->read = process_event_stub;
276 if (handler->throttle == NULL)
277 handler->throttle = process_event_stub;
278 if (handler->unthrottle == NULL)
279 handler->unthrottle = process_event_stub;
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500280 if (handler->attr == NULL)
281 handler->attr = process_event_stub;
Tom Zanussicd19a032010-04-01 23:59:20 -0500282 if (handler->event_type == NULL)
283 handler->event_type = process_event_stub;
Tom Zanussi92155452010-04-01 23:59:21 -0500284 if (handler->tracing_data == NULL)
285 handler->tracing_data = process_event_stub;
Tom Zanussic7929e42010-04-01 23:59:22 -0500286 if (handler->build_id == NULL)
287 handler->build_id = process_event_stub;
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200288 if (handler->finished_round == NULL) {
289 if (handler->ordered_samples)
290 handler->finished_round = process_finished_round;
291 else
292 handler->finished_round = process_finished_round_stub;
293 }
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200294}
295
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200296void mem_bswap_64(void *src, int byte_size)
297{
298 u64 *m = src;
299
300 while (byte_size > 0) {
301 *m = bswap_64(*m);
302 byte_size -= sizeof(u64);
303 ++m;
304 }
305}
306
307static void event__all64_swap(event_t *self)
308{
309 struct perf_event_header *hdr = &self->header;
310 mem_bswap_64(hdr + 1, self->header.size - sizeof(*hdr));
311}
312
313static void event__comm_swap(event_t *self)
314{
315 self->comm.pid = bswap_32(self->comm.pid);
316 self->comm.tid = bswap_32(self->comm.tid);
317}
318
319static void event__mmap_swap(event_t *self)
320{
321 self->mmap.pid = bswap_32(self->mmap.pid);
322 self->mmap.tid = bswap_32(self->mmap.tid);
323 self->mmap.start = bswap_64(self->mmap.start);
324 self->mmap.len = bswap_64(self->mmap.len);
325 self->mmap.pgoff = bswap_64(self->mmap.pgoff);
326}
327
328static void event__task_swap(event_t *self)
329{
330 self->fork.pid = bswap_32(self->fork.pid);
331 self->fork.tid = bswap_32(self->fork.tid);
332 self->fork.ppid = bswap_32(self->fork.ppid);
333 self->fork.ptid = bswap_32(self->fork.ptid);
334 self->fork.time = bswap_64(self->fork.time);
335}
336
337static void event__read_swap(event_t *self)
338{
339 self->read.pid = bswap_32(self->read.pid);
340 self->read.tid = bswap_32(self->read.tid);
341 self->read.value = bswap_64(self->read.value);
342 self->read.time_enabled = bswap_64(self->read.time_enabled);
343 self->read.time_running = bswap_64(self->read.time_running);
344 self->read.id = bswap_64(self->read.id);
345}
346
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500347static void event__attr_swap(event_t *self)
348{
349 size_t size;
350
351 self->attr.attr.type = bswap_32(self->attr.attr.type);
352 self->attr.attr.size = bswap_32(self->attr.attr.size);
353 self->attr.attr.config = bswap_64(self->attr.attr.config);
354 self->attr.attr.sample_period = bswap_64(self->attr.attr.sample_period);
355 self->attr.attr.sample_type = bswap_64(self->attr.attr.sample_type);
356 self->attr.attr.read_format = bswap_64(self->attr.attr.read_format);
357 self->attr.attr.wakeup_events = bswap_32(self->attr.attr.wakeup_events);
358 self->attr.attr.bp_type = bswap_32(self->attr.attr.bp_type);
359 self->attr.attr.bp_addr = bswap_64(self->attr.attr.bp_addr);
360 self->attr.attr.bp_len = bswap_64(self->attr.attr.bp_len);
361
362 size = self->header.size;
363 size -= (void *)&self->attr.id - (void *)self;
364 mem_bswap_64(self->attr.id, size);
365}
366
Tom Zanussicd19a032010-04-01 23:59:20 -0500367static void event__event_type_swap(event_t *self)
368{
369 self->event_type.event_type.event_id =
370 bswap_64(self->event_type.event_type.event_id);
371}
372
Tom Zanussi92155452010-04-01 23:59:21 -0500373static void event__tracing_data_swap(event_t *self)
374{
375 self->tracing_data.size = bswap_32(self->tracing_data.size);
376}
377
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200378typedef void (*event__swap_op)(event_t *self);
379
380static event__swap_op event__swap_ops[] = {
381 [PERF_RECORD_MMAP] = event__mmap_swap,
382 [PERF_RECORD_COMM] = event__comm_swap,
383 [PERF_RECORD_FORK] = event__task_swap,
384 [PERF_RECORD_EXIT] = event__task_swap,
385 [PERF_RECORD_LOST] = event__all64_swap,
386 [PERF_RECORD_READ] = event__read_swap,
387 [PERF_RECORD_SAMPLE] = event__all64_swap,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500388 [PERF_RECORD_HEADER_ATTR] = event__attr_swap,
Tom Zanussicd19a032010-04-01 23:59:20 -0500389 [PERF_RECORD_HEADER_EVENT_TYPE] = event__event_type_swap,
Tom Zanussi92155452010-04-01 23:59:21 -0500390 [PERF_RECORD_HEADER_TRACING_DATA] = event__tracing_data_swap,
Tom Zanussic7929e42010-04-01 23:59:22 -0500391 [PERF_RECORD_HEADER_BUILD_ID] = NULL,
Tom Zanussi8dc58102010-04-01 23:59:15 -0500392 [PERF_RECORD_HEADER_MAX] = NULL,
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200393};
394
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200395struct sample_queue {
396 u64 timestamp;
Thomas Gleixner28990f72010-11-30 17:49:35 +0000397 event_t *event;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200398 struct list_head list;
399};
400
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200401static void flush_sample_queue(struct perf_session *s,
402 struct perf_event_ops *ops)
403{
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000404 struct ordered_samples *os = &s->ordered_samples;
405 struct list_head *head = &os->samples;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200406 struct sample_queue *tmp, *iter;
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000407 u64 limit = os->next_flush;
408 u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200409
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200410 if (!ops->ordered_samples || !limit)
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200411 return;
412
413 list_for_each_entry_safe(iter, tmp, head, list) {
414 if (iter->timestamp > limit)
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000415 break;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200416
Thomas Gleixner28990f72010-11-30 17:49:35 +0000417 ops->sample(iter->event, s);
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200418
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000419 os->last_flush = iter->timestamp;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200420 list_del(&iter->list);
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200421 free(iter);
422 }
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000423
424 if (list_empty(head)) {
425 os->last_sample = NULL;
426 } else if (last_ts <= limit) {
427 os->last_sample =
428 list_entry(head->prev, struct sample_queue, list);
429 }
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200430}
431
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200432/*
433 * When perf record finishes a pass on every buffers, it records this pseudo
434 * event.
435 * We record the max timestamp t found in the pass n.
436 * Assuming these timestamps are monotonic across cpus, we know that if
437 * a buffer still has events with timestamps below t, they will be all
438 * available and then read in the pass n + 1.
439 * Hence when we start to read the pass n + 2, we can safely flush every
440 * events with timestamps below t.
441 *
442 * ============ PASS n =================
443 * CPU 0 | CPU 1
444 * |
445 * cnt1 timestamps | cnt2 timestamps
446 * 1 | 2
447 * 2 | 3
448 * - | 4 <--- max recorded
449 *
450 * ============ PASS n + 1 ==============
451 * CPU 0 | CPU 1
452 * |
453 * cnt1 timestamps | cnt2 timestamps
454 * 3 | 5
455 * 4 | 6
456 * 5 | 7 <---- max recorded
457 *
458 * Flush every events below timestamp 4
459 *
460 * ============ PASS n + 2 ==============
461 * CPU 0 | CPU 1
462 * |
463 * cnt1 timestamps | cnt2 timestamps
464 * 6 | 8
465 * 7 | 9
466 * - | 10
467 *
468 * Flush every events below timestamp 7
469 * etc...
470 */
471static int process_finished_round(event_t *event __used,
472 struct perf_session *session,
473 struct perf_event_ops *ops)
474{
475 flush_sample_queue(session, ops);
476 session->ordered_samples.next_flush = session->ordered_samples.max_timestamp;
477
478 return 0;
479}
480
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200481/* The queue is ordered by time */
482static void __queue_sample_event(struct sample_queue *new,
483 struct perf_session *s)
484{
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000485 struct ordered_samples *os = &s->ordered_samples;
486 struct sample_queue *sample = os->last_sample;
487 u64 timestamp = new->timestamp;
488 struct list_head *p;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200489
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000490 os->last_sample = new;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200491
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000492 if (!sample) {
493 list_add(&new->list, &os->samples);
494 os->max_timestamp = timestamp;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200495 return;
496 }
497
498 /*
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000499 * last_sample might point to some random place in the list as it's
500 * the last queued event. We expect that the new event is close to
501 * this.
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200502 */
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000503 if (sample->timestamp <= timestamp) {
504 while (sample->timestamp <= timestamp) {
505 p = sample->list.next;
506 if (p == &os->samples) {
507 list_add_tail(&new->list, &os->samples);
508 os->max_timestamp = timestamp;
509 return;
510 }
511 sample = list_entry(p, struct sample_queue, list);
512 }
513 list_add_tail(&new->list, &sample->list);
514 } else {
515 while (sample->timestamp > timestamp) {
516 p = sample->list.prev;
517 if (p == &os->samples) {
518 list_add(&new->list, &os->samples);
519 return;
520 }
521 sample = list_entry(p, struct sample_queue, list);
522 }
523 list_add(&new->list, &sample->list);
524 }
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200525}
526
527static int queue_sample_event(event_t *event, struct sample_data *data,
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200528 struct perf_session *s)
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200529{
530 u64 timestamp = data->time;
531 struct sample_queue *new;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200532
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200533 if (timestamp < s->ordered_samples.last_flush) {
534 printf("Warning: Timestamp below last timeslice flush\n");
535 return -EINVAL;
536 }
537
538 new = malloc(sizeof(*new));
539 if (!new)
540 return -ENOMEM;
541
542 new->timestamp = timestamp;
Thomas Gleixnerfe174202010-11-30 17:49:49 +0000543 new->event = event;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200544
545 __queue_sample_event(new, s);
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200546
547 return 0;
548}
549
550static int perf_session__process_sample(event_t *event, struct perf_session *s,
551 struct perf_event_ops *ops)
552{
553 struct sample_data data;
554
555 if (!ops->ordered_samples)
556 return ops->sample(event, s);
557
558 bzero(&data, sizeof(struct sample_data));
559 event__parse_sample(event, s->sample_type, &data);
560
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200561 queue_sample_event(event, &data, s);
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200562
563 return 0;
564}
565
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200566static int perf_session__process_event(struct perf_session *self,
567 event_t *event,
568 struct perf_event_ops *ops,
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000569 u64 file_offset)
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200570{
571 trace_event(event);
572
Tom Zanussi8dc58102010-04-01 23:59:15 -0500573 if (event->header.type < PERF_RECORD_HEADER_MAX) {
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200574 dump_printf("%#Lx [%#x]: PERF_RECORD_%s",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000575 file_offset, event->header.size,
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200576 event__name[event->header.type]);
Arnaldo Carvalho de Melocee75ac2010-05-14 13:16:55 -0300577 hists__inc_nr_events(&self->hists, event->header.type);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200578 }
579
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200580 if (self->header.needs_swap && event__swap_ops[event->header.type])
581 event__swap_ops[event->header.type](event);
582
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200583 switch (event->header.type) {
584 case PERF_RECORD_SAMPLE:
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200585 return perf_session__process_sample(event, self, ops);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200586 case PERF_RECORD_MMAP:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200587 return ops->mmap(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200588 case PERF_RECORD_COMM:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200589 return ops->comm(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200590 case PERF_RECORD_FORK:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200591 return ops->fork(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200592 case PERF_RECORD_EXIT:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200593 return ops->exit(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200594 case PERF_RECORD_LOST:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200595 return ops->lost(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200596 case PERF_RECORD_READ:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200597 return ops->read(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200598 case PERF_RECORD_THROTTLE:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200599 return ops->throttle(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200600 case PERF_RECORD_UNTHROTTLE:
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -0200601 return ops->unthrottle(event, self);
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500602 case PERF_RECORD_HEADER_ATTR:
603 return ops->attr(event, self);
Tom Zanussicd19a032010-04-01 23:59:20 -0500604 case PERF_RECORD_HEADER_EVENT_TYPE:
605 return ops->event_type(event, self);
Tom Zanussi92155452010-04-01 23:59:21 -0500606 case PERF_RECORD_HEADER_TRACING_DATA:
607 /* setup for reading amidst mmap */
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000608 lseek(self->fd, file_offset, SEEK_SET);
Tom Zanussi92155452010-04-01 23:59:21 -0500609 return ops->tracing_data(event, self);
Tom Zanussic7929e42010-04-01 23:59:22 -0500610 case PERF_RECORD_HEADER_BUILD_ID:
611 return ops->build_id(event, self);
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200612 case PERF_RECORD_FINISHED_ROUND:
613 return ops->finished_round(event, self, ops);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200614 default:
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -0300615 ++self->hists.stats.nr_unknown_events;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200616 return -1;
617 }
618}
619
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200620void perf_event_header__bswap(struct perf_event_header *self)
621{
622 self->type = bswap_32(self->type);
623 self->misc = bswap_16(self->misc);
624 self->size = bswap_16(self->size);
625}
626
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200627static struct thread *perf_session__register_idle_thread(struct perf_session *self)
628{
629 struct thread *thread = perf_session__findnew(self, 0);
630
631 if (thread == NULL || thread__set_comm(thread, "swapper")) {
632 pr_err("problem inserting idle task.\n");
633 thread = NULL;
634 }
635
636 return thread;
637}
638
Tom Zanussi8dc58102010-04-01 23:59:15 -0500639int do_read(int fd, void *buf, size_t size)
640{
641 void *buf_start = buf;
642
643 while (size) {
644 int ret = read(fd, buf, size);
645
646 if (ret <= 0)
647 return ret;
648
649 size -= ret;
650 buf += ret;
651 }
652
653 return buf - buf_start;
654}
655
656#define session_done() (*(volatile int *)(&session_done))
657volatile int session_done;
658
659static int __perf_session__process_pipe_events(struct perf_session *self,
660 struct perf_event_ops *ops)
661{
662 event_t event;
663 uint32_t size;
664 int skip = 0;
665 u64 head;
666 int err;
667 void *p;
668
669 perf_event_ops__fill_defaults(ops);
670
671 head = 0;
672more:
673 err = do_read(self->fd, &event, sizeof(struct perf_event_header));
674 if (err <= 0) {
675 if (err == 0)
676 goto done;
677
678 pr_err("failed to read event header\n");
679 goto out_err;
680 }
681
682 if (self->header.needs_swap)
683 perf_event_header__bswap(&event.header);
684
685 size = event.header.size;
686 if (size == 0)
687 size = 8;
688
689 p = &event;
690 p += sizeof(struct perf_event_header);
691
Tom Zanussi794e43b2010-05-05 00:27:40 -0500692 if (size - sizeof(struct perf_event_header)) {
693 err = do_read(self->fd, p,
694 size - sizeof(struct perf_event_header));
695 if (err <= 0) {
696 if (err == 0) {
697 pr_err("unexpected end of event stream\n");
698 goto done;
699 }
Tom Zanussi8dc58102010-04-01 23:59:15 -0500700
Tom Zanussi794e43b2010-05-05 00:27:40 -0500701 pr_err("failed to read event data\n");
702 goto out_err;
703 }
Tom Zanussi8dc58102010-04-01 23:59:15 -0500704 }
705
706 if (size == 0 ||
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000707 (skip = perf_session__process_event(self, &event, ops, head)) < 0) {
Tom Zanussi8dc58102010-04-01 23:59:15 -0500708 dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n",
709 head, event.header.size, event.header.type);
710 /*
711 * assume we lost track of the stream, check alignment, and
712 * increment a single u64 in the hope to catch on again 'soon'.
713 */
714 if (unlikely(head & 7))
715 head &= ~7ULL;
716
717 size = 8;
718 }
719
720 head += size;
721
722 dump_printf("\n%#Lx [%#x]: event: %d\n",
723 head, event.header.size, event.header.type);
724
725 if (skip > 0)
726 head += skip;
727
728 if (!session_done())
729 goto more;
730done:
731 err = 0;
732out_err:
733 return err;
734}
735
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000736int __perf_session__process_events(struct perf_session *session,
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -0200737 u64 data_offset, u64 data_size,
738 u64 file_size, struct perf_event_ops *ops)
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200739{
Thomas Gleixner55b44622010-11-30 17:49:46 +0000740 u64 head, page_offset, file_offset, file_pos, progress_next;
Thomas Gleixnerfe174202010-11-30 17:49:49 +0000741 int err, mmap_prot, mmap_flags, map_idx = 0;
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000742 struct ui_progress *progress;
Thomas Gleixner55b44622010-11-30 17:49:46 +0000743 size_t page_size, mmap_size;
Thomas Gleixnerfe174202010-11-30 17:49:49 +0000744 char *buf, *mmaps[8];
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200745 event_t *event;
746 uint32_t size;
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000747
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200748 perf_event_ops__fill_defaults(ops);
749
Arnaldo Carvalho de Melo1b759622010-01-14 18:30:04 -0200750 page_size = sysconf(_SC_PAGESIZE);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200751
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000752 page_offset = page_size * (data_offset / page_size);
753 file_offset = page_offset;
754 head = data_offset - page_offset;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200755
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000756 if (data_offset + data_size < file_size)
757 file_size = data_offset + data_size;
758
Thomas Gleixner55b44622010-11-30 17:49:46 +0000759 progress_next = file_size / 16;
760 progress = ui_progress__new("Processing events...", file_size);
761 if (progress == NULL)
762 return -1;
763
764 mmap_size = session->mmap_window;
765 if (mmap_size > file_size)
766 mmap_size = file_size;
767
Thomas Gleixnerfe174202010-11-30 17:49:49 +0000768 memset(mmaps, 0, sizeof(mmaps));
769
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200770 mmap_prot = PROT_READ;
771 mmap_flags = MAP_SHARED;
772
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000773 if (session->header.needs_swap) {
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200774 mmap_prot |= PROT_WRITE;
775 mmap_flags = MAP_PRIVATE;
776 }
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200777remap:
Thomas Gleixner55b44622010-11-30 17:49:46 +0000778 buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, session->fd,
779 file_offset);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200780 if (buf == MAP_FAILED) {
781 pr_err("failed to mmap file\n");
782 err = -errno;
783 goto out_err;
784 }
Thomas Gleixnerfe174202010-11-30 17:49:49 +0000785 mmaps[map_idx] = buf;
786 map_idx = (map_idx + 1) & (ARRAY_SIZE(mmaps) - 1);
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000787 file_pos = file_offset + head;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200788
789more:
790 event = (event_t *)(buf + head);
791
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000792 if (session->header.needs_swap)
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200793 perf_event_header__bswap(&event->header);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200794 size = event->header.size;
795 if (size == 0)
796 size = 8;
797
Thomas Gleixner55b44622010-11-30 17:49:46 +0000798 if (head + event->header.size >= mmap_size) {
Thomas Gleixnerfe174202010-11-30 17:49:49 +0000799 if (mmaps[map_idx]) {
800 munmap(mmaps[map_idx], mmap_size);
801 mmaps[map_idx] = NULL;
802 }
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200803
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000804 page_offset = page_size * (head / page_size);
805 file_offset += page_offset;
806 head -= page_offset;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200807 goto remap;
808 }
809
810 size = event->header.size;
811
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200812 dump_printf("\n%#Lx [%#x]: event: %d\n",
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000813 file_pos, event->header.size, event->header.type);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200814
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000815 if (size == 0 ||
816 perf_session__process_event(session, event, ops, file_pos) < 0) {
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200817 dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000818 file_offset + head, event->header.size,
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200819 event->header.type);
820 /*
821 * assume we lost track of the stream, check alignment, and
822 * increment a single u64 in the hope to catch on again 'soon'.
823 */
824 if (unlikely(head & 7))
825 head &= ~7ULL;
826
827 size = 8;
828 }
829
830 head += size;
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000831 file_pos += size;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200832
Thomas Gleixner55b44622010-11-30 17:49:46 +0000833 if (file_pos >= progress_next) {
834 progress_next += file_size / 16;
835 ui_progress__update(progress, file_pos);
836 }
837
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000838 if (file_pos < file_size)
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200839 goto more;
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000840
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200841 err = 0;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200842 /* do the final flush for ordered samples */
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000843 session->ordered_samples.next_flush = ULLONG_MAX;
844 flush_sample_queue(session, ops);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200845out_err:
Arnaldo Carvalho de Melo5f4d3f82010-03-26 21:16:22 -0300846 ui_progress__delete(progress);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200847
848 if (ops->lost == event__process_lost &&
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000849 session->hists.stats.total_lost != 0) {
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200850 ui__warning("Processed %Lu events and LOST %Lu!\n\n"
851 "Check IO/CPU overload!\n\n",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000852 session->hists.stats.total_period,
853 session->hists.stats.total_lost);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200854 }
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000855
856 if (session->hists.stats.nr_unknown_events != 0) {
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200857 ui__warning("Found %u unknown events!\n\n"
858 "Is this an older tool processing a perf.data "
859 "file generated by a more recent tool?\n\n"
860 "If that is not the case, consider "
861 "reporting to linux-kernel@vger.kernel.org.\n\n",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000862 session->hists.stats.nr_unknown_events);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200863 }
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000864
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200865 return err;
866}
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200867
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -0200868int perf_session__process_events(struct perf_session *self,
869 struct perf_event_ops *ops)
870{
871 int err;
872
873 if (perf_session__register_idle_thread(self) == NULL)
874 return -ENOMEM;
875
Tom Zanussi8dc58102010-04-01 23:59:15 -0500876 if (!self->fd_pipe)
877 err = __perf_session__process_events(self,
878 self->header.data_offset,
879 self->header.data_size,
880 self->size, ops);
881 else
882 err = __perf_session__process_pipe_events(self, ops);
Dave Martin88ca8952010-07-27 11:46:12 -0300883
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -0200884 return err;
885}
886
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200887bool perf_session__has_traces(struct perf_session *self, const char *msg)
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200888{
889 if (!(self->sample_type & PERF_SAMPLE_RAW)) {
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200890 pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg);
891 return false;
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200892 }
893
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200894 return true;
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200895}
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200896
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800897int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200898 const char *symbol_name,
899 u64 addr)
900{
901 char *bracket;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -0200902 enum map_type i;
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800903 struct ref_reloc_sym *ref;
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200904
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800905 ref = zalloc(sizeof(struct ref_reloc_sym));
906 if (ref == NULL)
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200907 return -ENOMEM;
908
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800909 ref->name = strdup(symbol_name);
910 if (ref->name == NULL) {
911 free(ref);
912 return -ENOMEM;
913 }
914
915 bracket = strchr(ref->name, ']');
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200916 if (bracket)
917 *bracket = '\0';
918
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800919 ref->addr = addr;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -0200920
921 for (i = 0; i < MAP__NR_TYPES; ++i) {
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800922 struct kmap *kmap = map__kmap(maps[i]);
923 kmap->ref_reloc_sym = ref;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -0200924 }
925
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200926 return 0;
927}
Arnaldo Carvalho de Melo1f626bc2010-05-09 19:57:08 -0300928
929size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp)
930{
931 return __dsos__fprintf(&self->host_machine.kernel_dsos, fp) +
932 __dsos__fprintf(&self->host_machine.user_dsos, fp) +
933 machines__fprintf_dsos(&self->machines, fp);
934}
Arnaldo Carvalho de Melof8690972010-05-19 13:41:23 -0300935
936size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
937 bool with_hits)
938{
939 size_t ret = machine__fprintf_dsos_buildid(&self->host_machine, fp, with_hits);
940 return ret + machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
941}