blob: 752577fdb16ef78f2ad65d9752c0da16d54866a5 [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 Gleixner55b446292010-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 Melo55aa640f2009-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 Melo55aa640f2009-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);
421 free(iter->event);
422 free(iter);
423 }
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000424
425 if (list_empty(head)) {
426 os->last_sample = NULL;
427 } else if (last_ts <= limit) {
428 os->last_sample =
429 list_entry(head->prev, struct sample_queue, list);
430 }
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200431}
432
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200433/*
434 * When perf record finishes a pass on every buffers, it records this pseudo
435 * event.
436 * We record the max timestamp t found in the pass n.
437 * Assuming these timestamps are monotonic across cpus, we know that if
438 * a buffer still has events with timestamps below t, they will be all
439 * available and then read in the pass n + 1.
440 * Hence when we start to read the pass n + 2, we can safely flush every
441 * events with timestamps below t.
442 *
443 * ============ PASS n =================
444 * CPU 0 | CPU 1
445 * |
446 * cnt1 timestamps | cnt2 timestamps
447 * 1 | 2
448 * 2 | 3
449 * - | 4 <--- max recorded
450 *
451 * ============ PASS n + 1 ==============
452 * CPU 0 | CPU 1
453 * |
454 * cnt1 timestamps | cnt2 timestamps
455 * 3 | 5
456 * 4 | 6
457 * 5 | 7 <---- max recorded
458 *
459 * Flush every events below timestamp 4
460 *
461 * ============ PASS n + 2 ==============
462 * CPU 0 | CPU 1
463 * |
464 * cnt1 timestamps | cnt2 timestamps
465 * 6 | 8
466 * 7 | 9
467 * - | 10
468 *
469 * Flush every events below timestamp 7
470 * etc...
471 */
472static int process_finished_round(event_t *event __used,
473 struct perf_session *session,
474 struct perf_event_ops *ops)
475{
476 flush_sample_queue(session, ops);
477 session->ordered_samples.next_flush = session->ordered_samples.max_timestamp;
478
479 return 0;
480}
481
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200482/* The queue is ordered by time */
483static void __queue_sample_event(struct sample_queue *new,
484 struct perf_session *s)
485{
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000486 struct ordered_samples *os = &s->ordered_samples;
487 struct sample_queue *sample = os->last_sample;
488 u64 timestamp = new->timestamp;
489 struct list_head *p;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200490
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000491 os->last_sample = new;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200492
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000493 if (!sample) {
494 list_add(&new->list, &os->samples);
495 os->max_timestamp = timestamp;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200496 return;
497 }
498
499 /*
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000500 * last_sample might point to some random place in the list as it's
501 * the last queued event. We expect that the new event is close to
502 * this.
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200503 */
Thomas Gleixnera1225de2010-11-30 17:49:33 +0000504 if (sample->timestamp <= timestamp) {
505 while (sample->timestamp <= timestamp) {
506 p = sample->list.next;
507 if (p == &os->samples) {
508 list_add_tail(&new->list, &os->samples);
509 os->max_timestamp = timestamp;
510 return;
511 }
512 sample = list_entry(p, struct sample_queue, list);
513 }
514 list_add_tail(&new->list, &sample->list);
515 } else {
516 while (sample->timestamp > timestamp) {
517 p = sample->list.prev;
518 if (p == &os->samples) {
519 list_add(&new->list, &os->samples);
520 return;
521 }
522 sample = list_entry(p, struct sample_queue, list);
523 }
524 list_add(&new->list, &sample->list);
525 }
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200526}
527
528static int queue_sample_event(event_t *event, struct sample_data *data,
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200529 struct perf_session *s)
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200530{
531 u64 timestamp = data->time;
532 struct sample_queue *new;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200533
534
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200535 if (timestamp < s->ordered_samples.last_flush) {
536 printf("Warning: Timestamp below last timeslice flush\n");
537 return -EINVAL;
538 }
539
540 new = malloc(sizeof(*new));
541 if (!new)
542 return -ENOMEM;
543
544 new->timestamp = timestamp;
545
546 new->event = malloc(event->header.size);
547 if (!new->event) {
548 free(new);
549 return -ENOMEM;
550 }
551
552 memcpy(new->event, event, event->header.size);
553
554 __queue_sample_event(new, s);
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200555
556 return 0;
557}
558
559static int perf_session__process_sample(event_t *event, struct perf_session *s,
560 struct perf_event_ops *ops)
561{
562 struct sample_data data;
563
564 if (!ops->ordered_samples)
565 return ops->sample(event, s);
566
567 bzero(&data, sizeof(struct sample_data));
568 event__parse_sample(event, s->sample_type, &data);
569
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200570 queue_sample_event(event, &data, s);
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200571
572 return 0;
573}
574
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200575static int perf_session__process_event(struct perf_session *self,
576 event_t *event,
577 struct perf_event_ops *ops,
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000578 u64 file_offset)
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200579{
580 trace_event(event);
581
Tom Zanussi8dc58102010-04-01 23:59:15 -0500582 if (event->header.type < PERF_RECORD_HEADER_MAX) {
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200583 dump_printf("%#Lx [%#x]: PERF_RECORD_%s",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000584 file_offset, event->header.size,
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200585 event__name[event->header.type]);
Arnaldo Carvalho de Melocee75ac2010-05-14 13:16:55 -0300586 hists__inc_nr_events(&self->hists, event->header.type);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200587 }
588
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200589 if (self->header.needs_swap && event__swap_ops[event->header.type])
590 event__swap_ops[event->header.type](event);
591
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200592 switch (event->header.type) {
593 case PERF_RECORD_SAMPLE:
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200594 return perf_session__process_sample(event, self, ops);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200595 case PERF_RECORD_MMAP:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200596 return ops->mmap(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200597 case PERF_RECORD_COMM:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200598 return ops->comm(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200599 case PERF_RECORD_FORK:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200600 return ops->fork(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200601 case PERF_RECORD_EXIT:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200602 return ops->exit(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200603 case PERF_RECORD_LOST:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200604 return ops->lost(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200605 case PERF_RECORD_READ:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200606 return ops->read(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200607 case PERF_RECORD_THROTTLE:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200608 return ops->throttle(event, self);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200609 case PERF_RECORD_UNTHROTTLE:
Arnaldo Carvalho de Melo55aa640f2009-12-27 21:37:05 -0200610 return ops->unthrottle(event, self);
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500611 case PERF_RECORD_HEADER_ATTR:
612 return ops->attr(event, self);
Tom Zanussicd19a032010-04-01 23:59:20 -0500613 case PERF_RECORD_HEADER_EVENT_TYPE:
614 return ops->event_type(event, self);
Tom Zanussi92155452010-04-01 23:59:21 -0500615 case PERF_RECORD_HEADER_TRACING_DATA:
616 /* setup for reading amidst mmap */
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000617 lseek(self->fd, file_offset, SEEK_SET);
Tom Zanussi92155452010-04-01 23:59:21 -0500618 return ops->tracing_data(event, self);
Tom Zanussic7929e42010-04-01 23:59:22 -0500619 case PERF_RECORD_HEADER_BUILD_ID:
620 return ops->build_id(event, self);
Frederic Weisbeckerd6b17be2010-05-03 15:14:33 +0200621 case PERF_RECORD_FINISHED_ROUND:
622 return ops->finished_round(event, self, ops);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200623 default:
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -0300624 ++self->hists.stats.nr_unknown_events;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200625 return -1;
626 }
627}
628
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200629void perf_event_header__bswap(struct perf_event_header *self)
630{
631 self->type = bswap_32(self->type);
632 self->misc = bswap_16(self->misc);
633 self->size = bswap_16(self->size);
634}
635
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200636static struct thread *perf_session__register_idle_thread(struct perf_session *self)
637{
638 struct thread *thread = perf_session__findnew(self, 0);
639
640 if (thread == NULL || thread__set_comm(thread, "swapper")) {
641 pr_err("problem inserting idle task.\n");
642 thread = NULL;
643 }
644
645 return thread;
646}
647
Tom Zanussi8dc58102010-04-01 23:59:15 -0500648int do_read(int fd, void *buf, size_t size)
649{
650 void *buf_start = buf;
651
652 while (size) {
653 int ret = read(fd, buf, size);
654
655 if (ret <= 0)
656 return ret;
657
658 size -= ret;
659 buf += ret;
660 }
661
662 return buf - buf_start;
663}
664
665#define session_done() (*(volatile int *)(&session_done))
666volatile int session_done;
667
668static int __perf_session__process_pipe_events(struct perf_session *self,
669 struct perf_event_ops *ops)
670{
671 event_t event;
672 uint32_t size;
673 int skip = 0;
674 u64 head;
675 int err;
676 void *p;
677
678 perf_event_ops__fill_defaults(ops);
679
680 head = 0;
681more:
682 err = do_read(self->fd, &event, sizeof(struct perf_event_header));
683 if (err <= 0) {
684 if (err == 0)
685 goto done;
686
687 pr_err("failed to read event header\n");
688 goto out_err;
689 }
690
691 if (self->header.needs_swap)
692 perf_event_header__bswap(&event.header);
693
694 size = event.header.size;
695 if (size == 0)
696 size = 8;
697
698 p = &event;
699 p += sizeof(struct perf_event_header);
700
Tom Zanussi794e43b2010-05-05 00:27:40 -0500701 if (size - sizeof(struct perf_event_header)) {
702 err = do_read(self->fd, p,
703 size - sizeof(struct perf_event_header));
704 if (err <= 0) {
705 if (err == 0) {
706 pr_err("unexpected end of event stream\n");
707 goto done;
708 }
Tom Zanussi8dc58102010-04-01 23:59:15 -0500709
Tom Zanussi794e43b2010-05-05 00:27:40 -0500710 pr_err("failed to read event data\n");
711 goto out_err;
712 }
Tom Zanussi8dc58102010-04-01 23:59:15 -0500713 }
714
715 if (size == 0 ||
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000716 (skip = perf_session__process_event(self, &event, ops, head)) < 0) {
Tom Zanussi8dc58102010-04-01 23:59:15 -0500717 dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n",
718 head, event.header.size, event.header.type);
719 /*
720 * assume we lost track of the stream, check alignment, and
721 * increment a single u64 in the hope to catch on again 'soon'.
722 */
723 if (unlikely(head & 7))
724 head &= ~7ULL;
725
726 size = 8;
727 }
728
729 head += size;
730
731 dump_printf("\n%#Lx [%#x]: event: %d\n",
732 head, event.header.size, event.header.type);
733
734 if (skip > 0)
735 head += skip;
736
737 if (!session_done())
738 goto more;
739done:
740 err = 0;
741out_err:
742 return err;
743}
744
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000745int __perf_session__process_events(struct perf_session *session,
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -0200746 u64 data_offset, u64 data_size,
747 u64 file_size, struct perf_event_ops *ops)
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200748{
Thomas Gleixner55b446292010-11-30 17:49:46 +0000749 u64 head, page_offset, file_offset, file_pos, progress_next;
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200750 int err, mmap_prot, mmap_flags;
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000751 struct ui_progress *progress;
Thomas Gleixner55b446292010-11-30 17:49:46 +0000752 size_t page_size, mmap_size;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200753 event_t *event;
754 uint32_t size;
755 char *buf;
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000756
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200757 perf_event_ops__fill_defaults(ops);
758
Arnaldo Carvalho de Melo1b759622010-01-14 18:30:04 -0200759 page_size = sysconf(_SC_PAGESIZE);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200760
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000761 page_offset = page_size * (data_offset / page_size);
762 file_offset = page_offset;
763 head = data_offset - page_offset;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200764
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000765 if (data_offset + data_size < file_size)
766 file_size = data_offset + data_size;
767
Thomas Gleixner55b446292010-11-30 17:49:46 +0000768 progress_next = file_size / 16;
769 progress = ui_progress__new("Processing events...", file_size);
770 if (progress == NULL)
771 return -1;
772
773 mmap_size = session->mmap_window;
774 if (mmap_size > file_size)
775 mmap_size = file_size;
776
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200777 mmap_prot = PROT_READ;
778 mmap_flags = MAP_SHARED;
779
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000780 if (session->header.needs_swap) {
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200781 mmap_prot |= PROT_WRITE;
782 mmap_flags = MAP_PRIVATE;
783 }
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200784remap:
Thomas Gleixner55b446292010-11-30 17:49:46 +0000785 buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, session->fd,
786 file_offset);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200787 if (buf == MAP_FAILED) {
788 pr_err("failed to mmap file\n");
789 err = -errno;
790 goto out_err;
791 }
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000792 file_pos = file_offset + head;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200793
794more:
795 event = (event_t *)(buf + head);
796
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000797 if (session->header.needs_swap)
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200798 perf_event_header__bswap(&event->header);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200799 size = event->header.size;
800 if (size == 0)
801 size = 8;
802
Thomas Gleixner55b446292010-11-30 17:49:46 +0000803 if (head + event->header.size >= mmap_size) {
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200804 int munmap_ret;
805
Thomas Gleixner55b446292010-11-30 17:49:46 +0000806 munmap_ret = munmap(buf, mmap_size);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200807 assert(munmap_ret == 0);
808
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000809 page_offset = page_size * (head / page_size);
810 file_offset += page_offset;
811 head -= page_offset;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200812 goto remap;
813 }
814
815 size = event->header.size;
816
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200817 dump_printf("\n%#Lx [%#x]: event: %d\n",
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000818 file_pos, event->header.size, event->header.type);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200819
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000820 if (size == 0 ||
821 perf_session__process_event(session, event, ops, file_pos) < 0) {
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -0200822 dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000823 file_offset + head, event->header.size,
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200824 event->header.type);
825 /*
826 * assume we lost track of the stream, check alignment, and
827 * increment a single u64 in the hope to catch on again 'soon'.
828 */
829 if (unlikely(head & 7))
830 head &= ~7ULL;
831
832 size = 8;
833 }
834
835 head += size;
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000836 file_pos += size;
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200837
Thomas Gleixner55b446292010-11-30 17:49:46 +0000838 if (file_pos >= progress_next) {
839 progress_next += file_size / 16;
840 ui_progress__update(progress, file_pos);
841 }
842
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000843 if (file_pos < file_size)
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200844 goto more;
Thomas Gleixnerd6513282010-11-30 17:49:44 +0000845
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200846 err = 0;
Frederic Weisbeckerc61e52e2010-04-24 00:04:12 +0200847 /* do the final flush for ordered samples */
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000848 session->ordered_samples.next_flush = ULLONG_MAX;
849 flush_sample_queue(session, ops);
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200850out_err:
Arnaldo Carvalho de Melo5f4d3f82010-03-26 21:16:22 -0300851 ui_progress__delete(progress);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200852
853 if (ops->lost == event__process_lost &&
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000854 session->hists.stats.total_lost != 0) {
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200855 ui__warning("Processed %Lu events and LOST %Lu!\n\n"
856 "Check IO/CPU overload!\n\n",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000857 session->hists.stats.total_period,
858 session->hists.stats.total_lost);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200859 }
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000860
861 if (session->hists.stats.nr_unknown_events != 0) {
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200862 ui__warning("Found %u unknown events!\n\n"
863 "Is this an older tool processing a perf.data "
864 "file generated by a more recent tool?\n\n"
865 "If that is not the case, consider "
866 "reporting to linux-kernel@vger.kernel.org.\n\n",
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000867 session->hists.stats.nr_unknown_events);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -0200868 }
Thomas Gleixner0331ee02010-11-30 17:49:38 +0000869
Arnaldo Carvalho de Melo06aae5902009-12-27 21:36:59 -0200870 return err;
871}
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200872
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -0200873int perf_session__process_events(struct perf_session *self,
874 struct perf_event_ops *ops)
875{
876 int err;
877
878 if (perf_session__register_idle_thread(self) == NULL)
879 return -ENOMEM;
880
Tom Zanussi8dc58102010-04-01 23:59:15 -0500881 if (!self->fd_pipe)
882 err = __perf_session__process_events(self,
883 self->header.data_offset,
884 self->header.data_size,
885 self->size, ops);
886 else
887 err = __perf_session__process_pipe_events(self, ops);
Dave Martin88ca8952010-07-27 11:46:12 -0300888
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -0200889 return err;
890}
891
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200892bool perf_session__has_traces(struct perf_session *self, const char *msg)
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200893{
894 if (!(self->sample_type & PERF_SAMPLE_RAW)) {
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200895 pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg);
896 return false;
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200897 }
898
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -0200899 return true;
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -0200900}
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200901
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800902int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200903 const char *symbol_name,
904 u64 addr)
905{
906 char *bracket;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -0200907 enum map_type i;
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800908 struct ref_reloc_sym *ref;
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200909
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800910 ref = zalloc(sizeof(struct ref_reloc_sym));
911 if (ref == NULL)
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200912 return -ENOMEM;
913
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800914 ref->name = strdup(symbol_name);
915 if (ref->name == NULL) {
916 free(ref);
917 return -ENOMEM;
918 }
919
920 bracket = strchr(ref->name, ']');
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200921 if (bracket)
922 *bracket = '\0';
923
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800924 ref->addr = addr;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -0200925
926 for (i = 0; i < MAP__NR_TYPES; ++i) {
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800927 struct kmap *kmap = map__kmap(maps[i]);
928 kmap->ref_reloc_sym = ref;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -0200929 }
930
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -0200931 return 0;
932}
Arnaldo Carvalho de Melo1f626bc2010-05-09 19:57:08 -0300933
934size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp)
935{
936 return __dsos__fprintf(&self->host_machine.kernel_dsos, fp) +
937 __dsos__fprintf(&self->host_machine.user_dsos, fp) +
938 machines__fprintf_dsos(&self->machines, fp);
939}
Arnaldo Carvalho de Melof8690972010-05-19 13:41:23 -0300940
941size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
942 bool with_hits)
943{
944 size_t ret = machine__fprintf_dsos_buildid(&self->host_machine, fp, with_hits);
945 return ret + machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
946}