Lines Matching +full:event +full:-
1 // SPDX-License-Identifier: GPL-2.0
31 #include "thread-stack.h"
32 #include "sample-raw.h"
43 union perf_event *event,
50 struct perf_data *data = session->data; in perf_session__open()
53 pr_err("incompatible file format (rerun with -v to learn more)\n"); in perf_session__open()
54 return -1; in perf_session__open()
57 if (perf_header__has_feat(&session->header, HEADER_AUXTRACE)) { in perf_session__open()
65 if (perf_header__has_feat(&session->header, HEADER_STAT)) in perf_session__open()
68 if (!evlist__valid_sample_type(session->evlist)) { in perf_session__open()
70 return -1; in perf_session__open()
73 if (!evlist__valid_sample_id_all(session->evlist)) { in perf_session__open()
75 return -1; in perf_session__open()
78 if (!evlist__valid_read_format(session->evlist)) { in perf_session__open()
80 return -1; in perf_session__open()
88 u16 id_hdr_size = evlist__id_hdr_size(session->evlist); in perf_session__set_id_hdr_size()
90 machines__set_id_hdr_size(&session->machines, id_hdr_size); in perf_session__set_id_hdr_size()
95 int ret = machine__create_kernel_maps(&session->machines.host); in perf_session__create_kernel_maps()
98 ret = machines__create_guest_kernel_maps(&session->machines); in perf_session__create_kernel_maps()
104 machines__destroy_kernel_maps(&session->machines); in perf_session__destroy_kernel_maps()
111 evlist__for_each_entry(session->evlist, evsel) { in perf_session__has_comm_exec()
112 if (evsel->core.attr.comm_exec) in perf_session__has_comm_exec()
123 machines__set_comm_exec(&session->machines, comm_exec); in perf_session__set_comm_exec()
127 struct ordered_event *event) in ordered_events__deliver_event() argument
132 return perf_session__deliver_event(session, event->event, in ordered_events__deliver_event()
133 session->tool, event->file_offset, in ordered_events__deliver_event()
134 event->file_path); in ordered_events__deliver_event()
141 int ret = -ENOMEM; in __perf_session__new()
147 session->trace_event_repipe = trace_event_repipe; in __perf_session__new()
148 session->tool = tool; in __perf_session__new()
149 session->decomp_data.zstd_decomp = &session->zstd_data; in __perf_session__new()
150 session->active_decomp = &session->decomp_data; in __perf_session__new()
151 INIT_LIST_HEAD(&session->auxtrace_index); in __perf_session__new()
152 machines__init(&session->machines); in __perf_session__new()
153 ordered_events__init(&session->ordered_events, in __perf_session__new()
156 perf_env__init(&session->header.env); in __perf_session__new()
162 session->data = data; in __perf_session__new()
171 * but not in pipe-mode. in __perf_session__new()
173 if (!data->is_pipe) { in __perf_session__new()
178 evlist__init_trace_event_sample_raw(session->evlist); in __perf_session__new()
181 if (data->is_dir) { in __perf_session__new()
192 session->machines.host.env = &perf_env; in __perf_session__new()
195 session->machines.host.single_address_space = in __perf_session__new()
196 perf_env__single_address_space(session->machines.host.env); in __perf_session__new()
201 * kernel MMAP event, in perf_event__process_mmap(). in __perf_session__new()
208 * In pipe-mode, evlist is empty until PERF_RECORD_HEADER_ATTR is in __perf_session__new()
211 if ((!data || !data->is_pipe) && tool && tool->ordering_requires_timestamps && in __perf_session__new()
212 tool->ordered_events && !evlist__sample_id_all(session->evlist)) { in __perf_session__new()
214 tool->ordered_events = false; in __perf_session__new()
234 next = decomp->next; in perf_decomp__release_events()
235 mmap_len = decomp->mmap_len; in perf_decomp__release_events()
245 auxtrace_index__free(&session->auxtrace_index); in perf_session__delete()
248 perf_decomp__release_events(session->decomp_data.decomp); in perf_session__delete()
249 perf_env__exit(&session->header.env); in perf_session__delete()
250 machines__exit(&session->machines); in perf_session__delete()
251 if (session->data) { in perf_session__delete()
252 if (perf_data__is_read(session->data)) in perf_session__delete()
253 evlist__delete(session->evlist); in perf_session__delete()
254 perf_data__close(session->data); in perf_session__delete()
257 trace_event__cleanup(&session->tevent); in perf_session__delete()
262 static void swap_sample_id_all(union perf_event *event, void *data) in swap_sample_id_all() argument
264 void *end = (void *) event + event->header.size; in swap_sample_id_all()
265 int size = end - data; in swap_sample_id_all()
271 static void perf_event__all64_swap(union perf_event *event, in perf_event__all64_swap() argument
274 struct perf_event_header *hdr = &event->header; in perf_event__all64_swap()
275 mem_bswap_64(hdr + 1, event->header.size - sizeof(*hdr)); in perf_event__all64_swap()
278 static void perf_event__comm_swap(union perf_event *event, bool sample_id_all) in perf_event__comm_swap() argument
280 event->comm.pid = bswap_32(event->comm.pid); in perf_event__comm_swap()
281 event->comm.tid = bswap_32(event->comm.tid); in perf_event__comm_swap()
284 void *data = &event->comm.comm; in perf_event__comm_swap()
287 swap_sample_id_all(event, data); in perf_event__comm_swap()
291 static void perf_event__mmap_swap(union perf_event *event, in perf_event__mmap_swap() argument
294 event->mmap.pid = bswap_32(event->mmap.pid); in perf_event__mmap_swap()
295 event->mmap.tid = bswap_32(event->mmap.tid); in perf_event__mmap_swap()
296 event->mmap.start = bswap_64(event->mmap.start); in perf_event__mmap_swap()
297 event->mmap.len = bswap_64(event->mmap.len); in perf_event__mmap_swap()
298 event->mmap.pgoff = bswap_64(event->mmap.pgoff); in perf_event__mmap_swap()
301 void *data = &event->mmap.filename; in perf_event__mmap_swap()
304 swap_sample_id_all(event, data); in perf_event__mmap_swap()
308 static void perf_event__mmap2_swap(union perf_event *event, in perf_event__mmap2_swap() argument
311 event->mmap2.pid = bswap_32(event->mmap2.pid); in perf_event__mmap2_swap()
312 event->mmap2.tid = bswap_32(event->mmap2.tid); in perf_event__mmap2_swap()
313 event->mmap2.start = bswap_64(event->mmap2.start); in perf_event__mmap2_swap()
314 event->mmap2.len = bswap_64(event->mmap2.len); in perf_event__mmap2_swap()
315 event->mmap2.pgoff = bswap_64(event->mmap2.pgoff); in perf_event__mmap2_swap()
317 if (!(event->header.misc & PERF_RECORD_MISC_MMAP_BUILD_ID)) { in perf_event__mmap2_swap()
318 event->mmap2.maj = bswap_32(event->mmap2.maj); in perf_event__mmap2_swap()
319 event->mmap2.min = bswap_32(event->mmap2.min); in perf_event__mmap2_swap()
320 event->mmap2.ino = bswap_64(event->mmap2.ino); in perf_event__mmap2_swap()
321 event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation); in perf_event__mmap2_swap()
325 void *data = &event->mmap2.filename; in perf_event__mmap2_swap()
328 swap_sample_id_all(event, data); in perf_event__mmap2_swap()
331 static void perf_event__task_swap(union perf_event *event, bool sample_id_all) in perf_event__task_swap() argument
333 event->fork.pid = bswap_32(event->fork.pid); in perf_event__task_swap()
334 event->fork.tid = bswap_32(event->fork.tid); in perf_event__task_swap()
335 event->fork.ppid = bswap_32(event->fork.ppid); in perf_event__task_swap()
336 event->fork.ptid = bswap_32(event->fork.ptid); in perf_event__task_swap()
337 event->fork.time = bswap_64(event->fork.time); in perf_event__task_swap()
340 swap_sample_id_all(event, &event->fork + 1); in perf_event__task_swap()
343 static void perf_event__read_swap(union perf_event *event, bool sample_id_all) in perf_event__read_swap() argument
345 event->read.pid = bswap_32(event->read.pid); in perf_event__read_swap()
346 event->read.tid = bswap_32(event->read.tid); in perf_event__read_swap()
347 event->read.value = bswap_64(event->read.value); in perf_event__read_swap()
348 event->read.time_enabled = bswap_64(event->read.time_enabled); in perf_event__read_swap()
349 event->read.time_running = bswap_64(event->read.time_running); in perf_event__read_swap()
350 event->read.id = bswap_64(event->read.id); in perf_event__read_swap()
353 swap_sample_id_all(event, &event->read + 1); in perf_event__read_swap()
356 static void perf_event__aux_swap(union perf_event *event, bool sample_id_all) in perf_event__aux_swap() argument
358 event->aux.aux_offset = bswap_64(event->aux.aux_offset); in perf_event__aux_swap()
359 event->aux.aux_size = bswap_64(event->aux.aux_size); in perf_event__aux_swap()
360 event->aux.flags = bswap_64(event->aux.flags); in perf_event__aux_swap()
363 swap_sample_id_all(event, &event->aux + 1); in perf_event__aux_swap()
366 static void perf_event__itrace_start_swap(union perf_event *event, in perf_event__itrace_start_swap() argument
369 event->itrace_start.pid = bswap_32(event->itrace_start.pid); in perf_event__itrace_start_swap()
370 event->itrace_start.tid = bswap_32(event->itrace_start.tid); in perf_event__itrace_start_swap()
373 swap_sample_id_all(event, &event->itrace_start + 1); in perf_event__itrace_start_swap()
376 static void perf_event__switch_swap(union perf_event *event, bool sample_id_all) in perf_event__switch_swap() argument
378 if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE) { in perf_event__switch_swap()
379 event->context_switch.next_prev_pid = in perf_event__switch_swap()
380 bswap_32(event->context_switch.next_prev_pid); in perf_event__switch_swap()
381 event->context_switch.next_prev_tid = in perf_event__switch_swap()
382 bswap_32(event->context_switch.next_prev_tid); in perf_event__switch_swap()
386 swap_sample_id_all(event, &event->context_switch + 1); in perf_event__switch_swap()
389 static void perf_event__text_poke_swap(union perf_event *event, bool sample_id_all) in perf_event__text_poke_swap() argument
391 event->text_poke.addr = bswap_64(event->text_poke.addr); in perf_event__text_poke_swap()
392 event->text_poke.old_len = bswap_16(event->text_poke.old_len); in perf_event__text_poke_swap()
393 event->text_poke.new_len = bswap_16(event->text_poke.new_len); in perf_event__text_poke_swap()
396 size_t len = sizeof(event->text_poke.old_len) + in perf_event__text_poke_swap()
397 sizeof(event->text_poke.new_len) + in perf_event__text_poke_swap()
398 event->text_poke.old_len + in perf_event__text_poke_swap()
399 event->text_poke.new_len; in perf_event__text_poke_swap()
400 void *data = &event->text_poke.old_len; in perf_event__text_poke_swap()
403 swap_sample_id_all(event, data); in perf_event__text_poke_swap()
407 static void perf_event__throttle_swap(union perf_event *event, in perf_event__throttle_swap() argument
410 event->throttle.time = bswap_64(event->throttle.time); in perf_event__throttle_swap()
411 event->throttle.id = bswap_64(event->throttle.id); in perf_event__throttle_swap()
412 event->throttle.stream_id = bswap_64(event->throttle.stream_id); in perf_event__throttle_swap()
415 swap_sample_id_all(event, &event->throttle + 1); in perf_event__throttle_swap()
418 static void perf_event__namespaces_swap(union perf_event *event, in perf_event__namespaces_swap() argument
423 event->namespaces.pid = bswap_32(event->namespaces.pid); in perf_event__namespaces_swap()
424 event->namespaces.tid = bswap_32(event->namespaces.tid); in perf_event__namespaces_swap()
425 event->namespaces.nr_namespaces = bswap_64(event->namespaces.nr_namespaces); in perf_event__namespaces_swap()
427 for (i = 0; i < event->namespaces.nr_namespaces; i++) { in perf_event__namespaces_swap()
428 struct perf_ns_link_info *ns = &event->namespaces.link_info[i]; in perf_event__namespaces_swap()
430 ns->dev = bswap_64(ns->dev); in perf_event__namespaces_swap()
431 ns->ino = bswap_64(ns->ino); in perf_event__namespaces_swap()
435 swap_sample_id_all(event, &event->namespaces.link_info[i]); in perf_event__namespaces_swap()
438 static void perf_event__cgroup_swap(union perf_event *event, bool sample_id_all) in perf_event__cgroup_swap() argument
440 event->cgroup.id = bswap_64(event->cgroup.id); in perf_event__cgroup_swap()
443 void *data = &event->cgroup.path; in perf_event__cgroup_swap()
446 swap_sample_id_all(event, data); in perf_event__cgroup_swap()
462 * Bit-fields are allocated from right to left (least to most significant)
463 * on little-endian implementations and from left to right (most to least
464 * significant) on big-endian implementations.
485 attr->type = bswap_32(attr->type); in perf_event__attr_swap()
486 attr->size = bswap_32(attr->size); in perf_event__attr_swap()
489 (attr->size > (offsetof(struct perf_event_attr, f) + \ in perf_event__attr_swap()
490 sizeof(attr->f) * (n))) in perf_event__attr_swap()
494 attr->f = bswap_##sz(attr->f); \ in perf_event__attr_swap()
520 swap_bitfield((u8 *) (&attr->read_format + 1), in perf_event__attr_swap()
528 static void perf_event__hdr_attr_swap(union perf_event *event, in perf_event__hdr_attr_swap() argument
533 perf_event__attr_swap(&event->attr.attr); in perf_event__hdr_attr_swap()
535 size = event->header.size; in perf_event__hdr_attr_swap()
536 size -= perf_record_header_attr_id(event) - (void *)event; in perf_event__hdr_attr_swap()
537 mem_bswap_64(perf_record_header_attr_id(event), size); in perf_event__hdr_attr_swap()
540 static void perf_event__event_update_swap(union perf_event *event, in perf_event__event_update_swap() argument
543 event->event_update.type = bswap_64(event->event_update.type); in perf_event__event_update_swap()
544 event->event_update.id = bswap_64(event->event_update.id); in perf_event__event_update_swap()
547 static void perf_event__event_type_swap(union perf_event *event, in perf_event__event_type_swap() argument
550 event->event_type.event_type.event_id = in perf_event__event_type_swap()
551 bswap_64(event->event_type.event_type.event_id); in perf_event__event_type_swap()
554 static void perf_event__tracing_data_swap(union perf_event *event, in perf_event__tracing_data_swap() argument
557 event->tracing_data.size = bswap_32(event->tracing_data.size); in perf_event__tracing_data_swap()
560 static void perf_event__auxtrace_info_swap(union perf_event *event, in perf_event__auxtrace_info_swap() argument
565 event->auxtrace_info.type = bswap_32(event->auxtrace_info.type); in perf_event__auxtrace_info_swap()
567 size = event->header.size; in perf_event__auxtrace_info_swap()
568 size -= (void *)&event->auxtrace_info.priv - (void *)event; in perf_event__auxtrace_info_swap()
569 mem_bswap_64(event->auxtrace_info.priv, size); in perf_event__auxtrace_info_swap()
572 static void perf_event__auxtrace_swap(union perf_event *event, in perf_event__auxtrace_swap() argument
575 event->auxtrace.size = bswap_64(event->auxtrace.size); in perf_event__auxtrace_swap()
576 event->auxtrace.offset = bswap_64(event->auxtrace.offset); in perf_event__auxtrace_swap()
577 event->auxtrace.reference = bswap_64(event->auxtrace.reference); in perf_event__auxtrace_swap()
578 event->auxtrace.idx = bswap_32(event->auxtrace.idx); in perf_event__auxtrace_swap()
579 event->auxtrace.tid = bswap_32(event->auxtrace.tid); in perf_event__auxtrace_swap()
580 event->auxtrace.cpu = bswap_32(event->auxtrace.cpu); in perf_event__auxtrace_swap()
583 static void perf_event__auxtrace_error_swap(union perf_event *event, in perf_event__auxtrace_error_swap() argument
586 event->auxtrace_error.type = bswap_32(event->auxtrace_error.type); in perf_event__auxtrace_error_swap()
587 event->auxtrace_error.code = bswap_32(event->auxtrace_error.code); in perf_event__auxtrace_error_swap()
588 event->auxtrace_error.cpu = bswap_32(event->auxtrace_error.cpu); in perf_event__auxtrace_error_swap()
589 event->auxtrace_error.pid = bswap_32(event->auxtrace_error.pid); in perf_event__auxtrace_error_swap()
590 event->auxtrace_error.tid = bswap_32(event->auxtrace_error.tid); in perf_event__auxtrace_error_swap()
591 event->auxtrace_error.fmt = bswap_32(event->auxtrace_error.fmt); in perf_event__auxtrace_error_swap()
592 event->auxtrace_error.ip = bswap_64(event->auxtrace_error.ip); in perf_event__auxtrace_error_swap()
593 if (event->auxtrace_error.fmt) in perf_event__auxtrace_error_swap()
594 event->auxtrace_error.time = bswap_64(event->auxtrace_error.time); in perf_event__auxtrace_error_swap()
595 if (event->auxtrace_error.fmt >= 2) { in perf_event__auxtrace_error_swap()
596 event->auxtrace_error.machine_pid = bswap_32(event->auxtrace_error.machine_pid); in perf_event__auxtrace_error_swap()
597 event->auxtrace_error.vcpu = bswap_32(event->auxtrace_error.vcpu); in perf_event__auxtrace_error_swap()
601 static void perf_event__thread_map_swap(union perf_event *event, in perf_event__thread_map_swap() argument
606 event->thread_map.nr = bswap_64(event->thread_map.nr); in perf_event__thread_map_swap()
608 for (i = 0; i < event->thread_map.nr; i++) in perf_event__thread_map_swap()
609 event->thread_map.entries[i].pid = bswap_64(event->thread_map.entries[i].pid); in perf_event__thread_map_swap()
612 static void perf_event__cpu_map_swap(union perf_event *event, in perf_event__cpu_map_swap() argument
615 struct perf_record_cpu_map_data *data = &event->cpu_map.data; in perf_event__cpu_map_swap()
617 data->type = bswap_16(data->type); in perf_event__cpu_map_swap()
619 switch (data->type) { in perf_event__cpu_map_swap()
621 data->cpus_data.nr = bswap_16(data->cpus_data.nr); in perf_event__cpu_map_swap()
623 for (unsigned i = 0; i < data->cpus_data.nr; i++) in perf_event__cpu_map_swap()
624 data->cpus_data.cpu[i] = bswap_16(data->cpus_data.cpu[i]); in perf_event__cpu_map_swap()
627 data->mask32_data.long_size = bswap_16(data->mask32_data.long_size); in perf_event__cpu_map_swap()
629 switch (data->mask32_data.long_size) { in perf_event__cpu_map_swap()
631 data->mask32_data.nr = bswap_16(data->mask32_data.nr); in perf_event__cpu_map_swap()
632 for (unsigned i = 0; i < data->mask32_data.nr; i++) in perf_event__cpu_map_swap()
633 data->mask32_data.mask[i] = bswap_32(data->mask32_data.mask[i]); in perf_event__cpu_map_swap()
636 data->mask64_data.nr = bswap_16(data->mask64_data.nr); in perf_event__cpu_map_swap()
637 for (unsigned i = 0; i < data->mask64_data.nr; i++) in perf_event__cpu_map_swap()
638 data->mask64_data.mask[i] = bswap_64(data->mask64_data.mask[i]); in perf_event__cpu_map_swap()
645 data->range_cpu_data.start_cpu = bswap_16(data->range_cpu_data.start_cpu); in perf_event__cpu_map_swap()
646 data->range_cpu_data.end_cpu = bswap_16(data->range_cpu_data.end_cpu); in perf_event__cpu_map_swap()
653 static void perf_event__stat_config_swap(union perf_event *event, in perf_event__stat_config_swap() argument
658 size = bswap_64(event->stat_config.nr) * sizeof(event->stat_config.data[0]); in perf_event__stat_config_swap()
660 mem_bswap_64(&event->stat_config.nr, size); in perf_event__stat_config_swap()
663 static void perf_event__stat_swap(union perf_event *event, in perf_event__stat_swap() argument
666 event->stat.id = bswap_64(event->stat.id); in perf_event__stat_swap()
667 event->stat.thread = bswap_32(event->stat.thread); in perf_event__stat_swap()
668 event->stat.cpu = bswap_32(event->stat.cpu); in perf_event__stat_swap()
669 event->stat.val = bswap_64(event->stat.val); in perf_event__stat_swap()
670 event->stat.ena = bswap_64(event->stat.ena); in perf_event__stat_swap()
671 event->stat.run = bswap_64(event->stat.run); in perf_event__stat_swap()
674 static void perf_event__stat_round_swap(union perf_event *event, in perf_event__stat_round_swap() argument
677 event->stat_round.type = bswap_64(event->stat_round.type); in perf_event__stat_round_swap()
678 event->stat_round.time = bswap_64(event->stat_round.time); in perf_event__stat_round_swap()
681 static void perf_event__time_conv_swap(union perf_event *event, in perf_event__time_conv_swap() argument
684 event->time_conv.time_shift = bswap_64(event->time_conv.time_shift); in perf_event__time_conv_swap()
685 event->time_conv.time_mult = bswap_64(event->time_conv.time_mult); in perf_event__time_conv_swap()
686 event->time_conv.time_zero = bswap_64(event->time_conv.time_zero); in perf_event__time_conv_swap()
688 if (event_contains(event->time_conv, time_cycles)) { in perf_event__time_conv_swap()
689 event->time_conv.time_cycles = bswap_64(event->time_conv.time_cycles); in perf_event__time_conv_swap()
690 event->time_conv.time_mask = bswap_64(event->time_conv.time_mask); in perf_event__time_conv_swap()
694 typedef void (*perf_event__swap_op)(union perf_event *event,
737 * event.
751 * - | 4 <--- max recorded
759 * 5 | 7 <---- max recorded
769 * - | 10
775 union perf_event *event __maybe_unused, in perf_event__process_finished_round()
783 int perf_session__queue_event(struct perf_session *s, union perf_event *event, in perf_session__queue_event() argument
786 return ordered_events__queue(&s->ordered_events, event, timestamp, file_offset, file_path); in perf_session__queue_event()
791 struct ip_callchain *callchain = sample->callchain; in callchain__lbr_callstack_printf()
792 struct branch_stack *lbr_stack = sample->branch_stack; in callchain__lbr_callstack_printf()
794 u64 kernel_callchain_nr = callchain->nr; in callchain__lbr_callstack_printf()
798 if (callchain->ips[i] == PERF_CONTEXT_USER) in callchain__lbr_callstack_printf()
802 if ((i != kernel_callchain_nr) && lbr_stack->nr) { in callchain__lbr_callstack_printf()
814 * "A"->"B"->"C"->"D". in callchain__lbr_callstack_printf()
816 * "C"->"D", "B"->"C", "A"->"B". in callchain__lbr_callstack_printf()
820 total_nr = i + 1 + lbr_stack->nr + 1; in callchain__lbr_callstack_printf()
827 i, callchain->ips[i]); in callchain__lbr_callstack_printf()
831 for (i = 0; i < lbr_stack->nr; i++) in callchain__lbr_callstack_printf()
841 struct ip_callchain *callchain = sample->callchain; in callchain__printf()
846 printf("... FP chain: nr:%" PRIu64 "\n", callchain->nr); in callchain__printf()
848 for (i = 0; i < callchain->nr; i++) in callchain__printf()
850 i, callchain->ips[i]); in callchain__printf()
858 u64 *branch_stack_cntr = sample->branch_stack_cntr; in branch_stack__printf()
862 printf("%s: nr:%" PRIu64 "\n", "... branch stack", sample->branch_stack->nr); in branch_stack__printf()
866 * B()->C() in branch_stack__printf()
867 * A()->B() in branch_stack__printf()
873 printf("%s: nr:%" PRIu64 "\n", "... branch callstack", sample->branch_stack->nr+1); in branch_stack__printf()
876 for (i = 0; i < sample->branch_stack->nr; i++) { in branch_stack__printf()
880 printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x %s %s\n", in branch_stack__printf()
881 i, e->from, e->to, in branch_stack__printf()
882 (unsigned short)e->flags.cycles, in branch_stack__printf()
883 e->flags.mispred ? "M" : " ", in branch_stack__printf()
884 e->flags.predicted ? "P" : " ", in branch_stack__printf()
885 e->flags.abort ? "A" : " ", in branch_stack__printf()
886 e->flags.in_tx ? "T" : " ", in branch_stack__printf()
887 (unsigned)e->flags.reserved, in branch_stack__printf()
889 e->flags.spec ? branch_spec_desc(e->flags.spec) : ""); in branch_stack__printf()
894 i, e->to, i+1, e->from); in branch_stack__printf()
896 printf("..... %2"PRIu64": %016" PRIx64 "\n", i+1, e->from); in branch_stack__printf()
906 sample->branch_stack->nr, br_cntr_width, br_cntr_nr); in branch_stack__printf()
907 for (i = 0; i < sample->branch_stack->nr; i++) in branch_stack__printf()
919 printf(".... %-5s 0x%016" PRIx64 "\n", in regs_dump__printf()
926 [PERF_SAMPLE_REGS_ABI_32] = "32-bit",
927 [PERF_SAMPLE_REGS_ABI_64] = "64-bit",
932 if (d->abi > PERF_SAMPLE_REGS_ABI_64) in regs_dump_abi()
935 return regs_abi[d->abi]; in regs_dump_abi()
940 u64 mask = regs->mask; in regs__printf()
947 regs_dump__printf(mask, regs->regs, arch); in regs__printf()
952 struct regs_dump *user_regs = &sample->user_regs; in regs_user__printf()
954 if (user_regs->regs) in regs_user__printf()
960 struct regs_dump *intr_regs = &sample->intr_regs; in regs_intr__printf()
962 if (intr_regs->regs) in regs_intr__printf()
969 dump->size, dump->offset); in stack_user__printf()
972 static void evlist__print_tstamp(struct evlist *evlist, union perf_event *event, struct perf_sample… in evlist__print_tstamp() argument
976 if (event->header.type != PERF_RECORD_SAMPLE && in evlist__print_tstamp()
978 fputs("-1 -1 ", stdout); in evlist__print_tstamp()
983 printf("%u ", sample->cpu); in evlist__print_tstamp()
986 printf("%" PRIu64 " ", sample->time); in evlist__print_tstamp()
995 sample->read.time_enabled); in sample_read__printf()
999 sample->read.time_running); in sample_read__printf()
1002 struct sample_read_value *value = sample->read.group.values; in sample_read__printf()
1004 printf(".... group nr %" PRIu64 "\n", sample->read.group.nr); in sample_read__printf()
1006 sample_read_group__for_each(value, sample->read.group.nr, read_format) { in sample_read__printf()
1009 value->id, value->value); in sample_read__printf()
1011 printf(", lost %" PRIu64, value->lost); in sample_read__printf()
1016 sample->read.one.id, sample->read.one.value); in sample_read__printf()
1018 printf(", lost %" PRIu64, sample->read.one.lost); in sample_read__printf()
1023 static void dump_event(struct evlist *evlist, union perf_event *event, in dump_event() argument
1030 printf("\n%#" PRIx64 "@%s [%#x]: event: %d\n", in dump_event()
1031 file_offset, file_path, event->header.size, event->header.type); in dump_event()
1033 trace_event(event); in dump_event()
1034 if (event->header.type == PERF_RECORD_SAMPLE && evlist->trace_event_sample_raw) in dump_event()
1035 evlist->trace_event_sample_raw(evlist, event, sample); in dump_event()
1038 evlist__print_tstamp(evlist, event, sample); in dump_event()
1041 event->header.size, perf_event__name(event->header.type)); in dump_event()
1052 static void dump_sample(struct evsel *evsel, union perf_event *event, in dump_sample() argument
1062 event->header.misc, sample->pid, sample->tid, sample->ip, in dump_sample()
1063 sample->period, sample->addr); in dump_sample()
1065 sample_type = evsel->core.attr.sample_type; in dump_sample()
1080 stack_user__printf(&sample->user_stack); in dump_sample()
1083 printf("... weight: %" PRIu64 "", sample->weight); in dump_sample()
1085 printf(",0x%"PRIx16"", sample->ins_lat); in dump_sample()
1086 printf(",0x%"PRIx16"", sample->p_stage_cyc); in dump_sample()
1092 printf(" . data_src: 0x%"PRIx64"\n", sample->data_src); in dump_sample()
1095 printf(" .. phys_addr: 0x%"PRIx64"\n", sample->phys_addr); in dump_sample()
1098 printf(" .. data page size: %s\n", get_page_size_name(sample->data_page_size, str)); in dump_sample()
1101 printf(" .. code page size: %s\n", get_page_size_name(sample->code_page_size, str)); in dump_sample()
1104 printf("... transaction: %" PRIx64 "\n", sample->transaction); in dump_sample()
1107 sample_read__printf(sample, evsel->core.attr.read_format); in dump_sample()
1110 static void dump_read(struct evsel *evsel, union perf_event *event) in dump_read() argument
1112 struct perf_record_read *read_event = &event->read; in dump_read()
1118 printf(": %d %d %s %" PRI_lu64 "\n", event->read.pid, event->read.tid, in dump_read()
1119 evsel__name(evsel), event->read.value); in dump_read()
1124 read_format = evsel->core.attr.read_format; in dump_read()
1127 printf("... time enabled : %" PRI_lu64 "\n", read_event->time_enabled); in dump_read()
1130 printf("... time running : %" PRI_lu64 "\n", read_event->time_running); in dump_read()
1133 printf("... id : %" PRI_lu64 "\n", read_event->id); in dump_read()
1136 printf("... lost : %" PRI_lu64 "\n", read_event->lost); in dump_read()
1140 union perf_event *event, in machines__find_for_cpumode() argument
1144 ((sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL) || in machines__find_for_cpumode()
1145 (sample->cpumode == PERF_RECORD_MISC_GUEST_USER))) { in machines__find_for_cpumode()
1148 if (sample->machine_pid) in machines__find_for_cpumode()
1149 pid = sample->machine_pid; in machines__find_for_cpumode()
1150 else if (event->header.type == PERF_RECORD_MMAP in machines__find_for_cpumode()
1151 || event->header.type == PERF_RECORD_MMAP2) in machines__find_for_cpumode()
1152 pid = event->mmap.pid; in machines__find_for_cpumode()
1154 pid = sample->pid; in machines__find_for_cpumode()
1166 return &machines->host; in machines__find_for_cpumode()
1171 union perf_event *event, in deliver_sample_value() argument
1176 struct perf_sample_id *sid = evlist__id2sid(evlist, v->id); in deliver_sample_value()
1180 sample->id = v->id; in deliver_sample_value()
1181 sample->period = v->value - sid->period; in deliver_sample_value()
1182 sid->period = v->value; in deliver_sample_value()
1185 if (!sid || sid->evsel == NULL) { in deliver_sample_value()
1186 ++evlist->stats.nr_unknown_id; in deliver_sample_value()
1194 if (!sample->period) in deliver_sample_value()
1197 evsel = container_of(sid->evsel, struct evsel, core); in deliver_sample_value()
1198 return tool->sample(tool, event, sample, evsel, machine); in deliver_sample_value()
1203 union perf_event *event, in deliver_sample_group() argument
1208 int ret = -EINVAL; in deliver_sample_group()
1209 struct sample_read_value *v = sample->read.group.values; in deliver_sample_group()
1211 if (tool->dont_split_sample_group) in deliver_sample_group()
1212 return deliver_sample_value(evlist, tool, event, sample, v, machine); in deliver_sample_group()
1214 sample_read_group__for_each(v, sample->read.group.nr, read_format) { in deliver_sample_group()
1215 ret = deliver_sample_value(evlist, tool, event, sample, v, in deliver_sample_group()
1225 union perf_event *event, struct perf_sample *sample, in evlist__deliver_sample() argument
1229 u64 sample_type = evsel->core.attr.sample_type; in evlist__deliver_sample()
1230 u64 read_format = evsel->core.attr.read_format; in evlist__deliver_sample()
1234 return tool->sample(tool, event, sample, evsel, machine); in evlist__deliver_sample()
1238 return deliver_sample_group(evlist, tool, event, sample, in evlist__deliver_sample()
1241 return deliver_sample_value(evlist, tool, event, sample, in evlist__deliver_sample()
1242 &sample->read.one, machine); in evlist__deliver_sample()
1247 union perf_event *event, in machines__deliver_event() argument
1255 dump_event(evlist, event, file_offset, sample, file_path); in machines__deliver_event()
1257 evsel = evlist__id2evsel(evlist, sample->id); in machines__deliver_event()
1259 machine = machines__find_for_cpumode(machines, event, sample); in machines__deliver_event()
1261 switch (event->header.type) { in machines__deliver_event()
1264 ++evlist->stats.nr_unknown_id; in machines__deliver_event()
1268 ++evlist->stats.nr_unprocessable_samples; in machines__deliver_event()
1269 dump_sample(evsel, event, sample, perf_env__arch(NULL)); in machines__deliver_event()
1272 dump_sample(evsel, event, sample, perf_env__arch(machine->env)); in machines__deliver_event()
1273 return evlist__deliver_sample(evlist, tool, event, sample, evsel, machine); in machines__deliver_event()
1275 return tool->mmap(tool, event, sample, machine); in machines__deliver_event()
1277 if (event->header.misc & PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT) in machines__deliver_event()
1278 ++evlist->stats.nr_proc_map_timeout; in machines__deliver_event()
1279 return tool->mmap2(tool, event, sample, machine); in machines__deliver_event()
1281 return tool->comm(tool, event, sample, machine); in machines__deliver_event()
1283 return tool->namespaces(tool, event, sample, machine); in machines__deliver_event()
1285 return tool->cgroup(tool, event, sample, machine); in machines__deliver_event()
1287 return tool->fork(tool, event, sample, machine); in machines__deliver_event()
1289 return tool->exit(tool, event, sample, machine); in machines__deliver_event()
1291 if (tool->lost == perf_event__process_lost) in machines__deliver_event()
1292 evlist->stats.total_lost += event->lost.lost; in machines__deliver_event()
1293 return tool->lost(tool, event, sample, machine); in machines__deliver_event()
1295 if (event->header.misc & PERF_RECORD_MISC_LOST_SAMPLES_BPF) in machines__deliver_event()
1296 evlist->stats.total_dropped_samples += event->lost_samples.lost; in machines__deliver_event()
1297 else if (tool->lost_samples == perf_event__process_lost_samples) in machines__deliver_event()
1298 evlist->stats.total_lost_samples += event->lost_samples.lost; in machines__deliver_event()
1299 return tool->lost_samples(tool, event, sample, machine); in machines__deliver_event()
1301 dump_read(evsel, event); in machines__deliver_event()
1302 return tool->read(tool, event, sample, evsel, machine); in machines__deliver_event()
1304 return tool->throttle(tool, event, sample, machine); in machines__deliver_event()
1306 return tool->unthrottle(tool, event, sample, machine); in machines__deliver_event()
1308 if (tool->aux == perf_event__process_aux) { in machines__deliver_event()
1309 if (event->aux.flags & PERF_AUX_FLAG_TRUNCATED) in machines__deliver_event()
1310 evlist->stats.total_aux_lost += 1; in machines__deliver_event()
1311 if (event->aux.flags & PERF_AUX_FLAG_PARTIAL) in machines__deliver_event()
1312 evlist->stats.total_aux_partial += 1; in machines__deliver_event()
1313 if (event->aux.flags & PERF_AUX_FLAG_COLLISION) in machines__deliver_event()
1314 evlist->stats.total_aux_collision += 1; in machines__deliver_event()
1316 return tool->aux(tool, event, sample, machine); in machines__deliver_event()
1318 return tool->itrace_start(tool, event, sample, machine); in machines__deliver_event()
1321 return tool->context_switch(tool, event, sample, machine); in machines__deliver_event()
1323 return tool->ksymbol(tool, event, sample, machine); in machines__deliver_event()
1325 return tool->bpf(tool, event, sample, machine); in machines__deliver_event()
1327 return tool->text_poke(tool, event, sample, machine); in machines__deliver_event()
1329 return tool->aux_output_hw_id(tool, event, sample, machine); in machines__deliver_event()
1331 ++evlist->stats.nr_unknown_events; in machines__deliver_event()
1332 return -1; in machines__deliver_event()
1337 union perf_event *event, in perf_session__deliver_event() argument
1343 int ret = evlist__parse_sample(session->evlist, event, &sample); in perf_session__deliver_event()
1350 ret = auxtrace__process_event(session, event, &sample, tool); in perf_session__deliver_event()
1356 ret = machines__deliver_event(&session->machines, session->evlist, in perf_session__deliver_event()
1357 event, &sample, tool, file_offset, file_path); in perf_session__deliver_event()
1366 union perf_event *event, in perf_session__process_user_event() argument
1370 struct ordered_events *oe = &session->ordered_events; in perf_session__process_user_event()
1371 const struct perf_tool *tool = session->tool; in perf_session__process_user_event()
1373 int fd = perf_data__fd(session->data); in perf_session__process_user_event()
1376 if (event->header.type != PERF_RECORD_COMPRESSED || perf_tool__compressed_is_stub(tool)) in perf_session__process_user_event()
1377 dump_event(session->evlist, event, file_offset, &sample, file_path); in perf_session__process_user_event()
1380 switch (event->header.type) { in perf_session__process_user_event()
1382 err = tool->attr(tool, event, &session->evlist); in perf_session__process_user_event()
1389 return tool->event_update(tool, event, &session->evlist); in perf_session__process_user_event()
1402 if (!perf_data__is_pipe(session->data)) in perf_session__process_user_event()
1404 return tool->tracing_data(session, event); in perf_session__process_user_event()
1406 return tool->build_id(session, event); in perf_session__process_user_event()
1408 return tool->finished_round(tool, event, oe); in perf_session__process_user_event()
1410 return tool->id_index(session, event); in perf_session__process_user_event()
1412 return tool->auxtrace_info(session, event); in perf_session__process_user_event()
1419 if (!perf_data__is_pipe(session->data)) in perf_session__process_user_event()
1420 lseek(fd, file_offset + event->header.size, SEEK_SET); in perf_session__process_user_event()
1421 return tool->auxtrace(session, event); in perf_session__process_user_event()
1423 perf_session__auxtrace_error_inc(session, event); in perf_session__process_user_event()
1424 return tool->auxtrace_error(session, event); in perf_session__process_user_event()
1426 return tool->thread_map(session, event); in perf_session__process_user_event()
1428 return tool->cpu_map(session, event); in perf_session__process_user_event()
1430 return tool->stat_config(session, event); in perf_session__process_user_event()
1432 return tool->stat(session, event); in perf_session__process_user_event()
1434 return tool->stat_round(session, event); in perf_session__process_user_event()
1436 session->time_conv = event->time_conv; in perf_session__process_user_event()
1437 return tool->time_conv(session, event); in perf_session__process_user_event()
1439 return tool->feature(session, event); in perf_session__process_user_event()
1441 err = tool->compressed(session, event, file_offset, file_path); in perf_session__process_user_event()
1443 dump_event(session->evlist, event, file_offset, &sample, file_path); in perf_session__process_user_event()
1446 return tool->finished_init(session, event); in perf_session__process_user_event()
1448 return -EINVAL; in perf_session__process_user_event()
1453 union perf_event *event, in perf_session__deliver_synth_event() argument
1456 struct evlist *evlist = session->evlist; in perf_session__deliver_synth_event()
1457 const struct perf_tool *tool = session->tool; in perf_session__deliver_synth_event()
1459 events_stats__inc(&evlist->stats, event->header.type); in perf_session__deliver_synth_event()
1461 if (event->header.type >= PERF_RECORD_USER_TYPE_START) in perf_session__deliver_synth_event()
1462 return perf_session__process_user_event(session, event, 0, NULL); in perf_session__deliver_synth_event()
1464 return machines__deliver_event(&session->machines, evlist, event, sample, tool, 0, NULL); in perf_session__deliver_synth_event()
1483 if (attr->size != sizeof(ev.attr_id.attr.attr)) { in perf_session__deliver_synth_attr_event()
1485 return -EINVAL; in perf_session__deliver_synth_attr_event()
1491 static void event_swap(union perf_event *event, bool sample_id_all) in event_swap() argument
1495 swap = perf_event__swap_ops[event->header.type]; in event_swap()
1497 swap(event, sample_id_all); in event_swap()
1505 union perf_event *event; in perf_session__peek_event() local
1509 if (session->one_mmap && !session->header.needs_swap) { in perf_session__peek_event()
1510 event = file_offset - session->one_mmap_offset + in perf_session__peek_event()
1511 session->one_mmap_addr; in perf_session__peek_event()
1515 if (perf_data__is_pipe(session->data)) in perf_session__peek_event()
1516 return -1; in perf_session__peek_event()
1518 fd = perf_data__fd(session->data); in perf_session__peek_event()
1522 return -1; in perf_session__peek_event()
1524 if (lseek(fd, file_offset, SEEK_SET) == (off_t)-1 || in perf_session__peek_event()
1526 return -1; in perf_session__peek_event()
1528 event = (union perf_event *)buf; in perf_session__peek_event()
1530 if (session->header.needs_swap) in perf_session__peek_event()
1531 perf_event_header__bswap(&event->header); in perf_session__peek_event()
1533 if (event->header.size < hdr_sz || event->header.size > buf_sz) in perf_session__peek_event()
1534 return -1; in perf_session__peek_event()
1537 rest = event->header.size - hdr_sz; in perf_session__peek_event()
1540 return -1; in perf_session__peek_event()
1542 if (session->header.needs_swap) in perf_session__peek_event()
1543 event_swap(event, evlist__sample_id_all(session->evlist)); in perf_session__peek_event()
1547 if (sample && event->header.type < PERF_RECORD_USER_TYPE_START && in perf_session__peek_event()
1548 evlist__parse_sample(session->evlist, event, sample)) in perf_session__peek_event()
1549 return -1; in perf_session__peek_event()
1551 *event_ptr = event; in perf_session__peek_event()
1561 union perf_event *event; in perf_session__peek_events() local
1566 PERF_SAMPLE_MAX_SIZE, &event, in perf_session__peek_events()
1571 err = cb(session, event, offset, data); in perf_session__peek_events()
1575 offset += event->header.size; in perf_session__peek_events()
1576 if (event->header.type == PERF_RECORD_AUXTRACE) in perf_session__peek_events()
1577 offset += event->auxtrace.size; in perf_session__peek_events()
1585 union perf_event *event, u64 file_offset, in perf_session__process_event() argument
1588 struct evlist *evlist = session->evlist; in perf_session__process_event()
1589 const struct perf_tool *tool = session->tool; in perf_session__process_event()
1592 if (session->header.needs_swap) in perf_session__process_event()
1593 event_swap(event, evlist__sample_id_all(evlist)); in perf_session__process_event()
1595 if (event->header.type >= PERF_RECORD_HEADER_MAX) in perf_session__process_event()
1596 return -EINVAL; in perf_session__process_event()
1598 events_stats__inc(&evlist->stats, event->header.type); in perf_session__process_event()
1600 if (event->header.type >= PERF_RECORD_USER_TYPE_START) in perf_session__process_event()
1601 return perf_session__process_user_event(session, event, file_offset, file_path); in perf_session__process_event()
1603 if (tool->ordered_events) { in perf_session__process_event()
1604 u64 timestamp = -1ULL; in perf_session__process_event()
1606 ret = evlist__parse_sample_timestamp(evlist, event, ×tamp); in perf_session__process_event()
1607 if (ret && ret != -1) in perf_session__process_event()
1610 ret = perf_session__queue_event(session, event, timestamp, file_offset, file_path); in perf_session__process_event()
1611 if (ret != -ETIME) in perf_session__process_event()
1615 return perf_session__deliver_event(session, event, tool, file_offset, file_path); in perf_session__process_event()
1620 hdr->type = bswap_32(hdr->type); in perf_event_header__bswap()
1621 hdr->misc = bswap_16(hdr->misc); in perf_event_header__bswap()
1622 hdr->size = bswap_16(hdr->size); in perf_event_header__bswap()
1627 return machine__findnew_thread(&session->machines.host, -1, pid); in perf_session__findnew()
1632 struct thread *thread = machine__idle_thread(&session->machines.host); in perf_session__register_idle_thread()
1636 return thread ? 0 : -1; in perf_session__register_idle_thread()
1642 const struct ordered_events *oe = &session->ordered_events; in perf_session__warn_order()
1646 evlist__for_each_entry(session->evlist, evsel) { in perf_session__warn_order()
1647 if (evsel->core.attr.write_backward) in perf_session__warn_order()
1653 if (oe->nr_unordered_events != 0) in perf_session__warn_order()
1654 ui__warning("%u out of order events recorded.\n", oe->nr_unordered_events); in perf_session__warn_order()
1659 const struct events_stats *stats = &session->evlist->stats; in perf_session__warn_about_errors()
1661 if (session->tool->lost == perf_event__process_lost && in perf_session__warn_about_errors()
1662 stats->nr_events[PERF_RECORD_LOST] != 0) { in perf_session__warn_about_errors()
1665 stats->nr_events[0], in perf_session__warn_about_errors()
1666 stats->nr_events[PERF_RECORD_LOST]); in perf_session__warn_about_errors()
1669 if (session->tool->lost_samples == perf_event__process_lost_samples) { in perf_session__warn_about_errors()
1672 drop_rate = (double)stats->total_lost_samples / in perf_session__warn_about_errors()
1673 (double) (stats->nr_events[PERF_RECORD_SAMPLE] + stats->total_lost_samples); in perf_session__warn_about_errors()
1676 stats->nr_events[PERF_RECORD_SAMPLE] + stats->total_lost_samples, in perf_session__warn_about_errors()
1681 if (session->tool->aux == perf_event__process_aux && in perf_session__warn_about_errors()
1682 stats->total_aux_lost != 0) { in perf_session__warn_about_errors()
1684 stats->total_aux_lost, in perf_session__warn_about_errors()
1685 stats->nr_events[PERF_RECORD_AUX]); in perf_session__warn_about_errors()
1688 if (session->tool->aux == perf_event__process_aux && in perf_session__warn_about_errors()
1689 stats->total_aux_partial != 0) { in perf_session__warn_about_errors()
1697 stats->total_aux_partial, in perf_session__warn_about_errors()
1698 stats->nr_events[PERF_RECORD_AUX], in perf_session__warn_about_errors()
1705 if (session->tool->aux == perf_event__process_aux && in perf_session__warn_about_errors()
1706 stats->total_aux_collision != 0) { in perf_session__warn_about_errors()
1708 stats->total_aux_collision, in perf_session__warn_about_errors()
1709 stats->nr_events[PERF_RECORD_AUX]); in perf_session__warn_about_errors()
1712 if (stats->nr_unknown_events != 0) { in perf_session__warn_about_errors()
1717 "reporting to linux-kernel@vger.kernel.org.\n\n", in perf_session__warn_about_errors()
1718 stats->nr_unknown_events); in perf_session__warn_about_errors()
1721 if (stats->nr_unknown_id != 0) { in perf_session__warn_about_errors()
1723 stats->nr_unknown_id); in perf_session__warn_about_errors()
1726 if (stats->nr_invalid_chains != 0) { in perf_session__warn_about_errors()
1729 "Consider reporting to linux-kernel@vger.kernel.org.\n\n", in perf_session__warn_about_errors()
1730 stats->nr_invalid_chains, in perf_session__warn_about_errors()
1731 stats->nr_events[PERF_RECORD_SAMPLE]); in perf_session__warn_about_errors()
1734 if (stats->nr_unprocessable_samples != 0) { in perf_session__warn_about_errors()
1737 stats->nr_unprocessable_samples); in perf_session__warn_about_errors()
1744 if (stats->nr_proc_map_timeout != 0) { in perf_session__warn_about_errors()
1745 ui__warning("%d map information files for pre-existing threads were\n" in perf_session__warn_about_errors()
1748 "threads by running with -v and redirecting the output\n" in perf_session__warn_about_errors()
1751 "Increase it by --proc-map-timeout\n", in perf_session__warn_about_errors()
1752 stats->nr_proc_map_timeout); in perf_session__warn_about_errors()
1764 return machines__for_each_thread(&session->machines, in perf_session__flush_thread_stacks()
1775 struct ordered_events *oe = &session->ordered_events; in __perf_session__process_pipe_events()
1776 const struct perf_tool *tool = session->tool; in __perf_session__process_pipe_events()
1778 union perf_event *event; in __perf_session__process_pipe_events() local
1789 * a file name other than "-". Then we can get the total size and show in __perf_session__process_pipe_events()
1792 if (strcmp(session->data->path, "-") && session->data->file.size) { in __perf_session__process_pipe_events()
1793 ui_progress__init_size(&prog, session->data->file.size, in __perf_session__process_pipe_events()
1803 return -errno; in __perf_session__process_pipe_events()
1806 event = buf; in __perf_session__process_pipe_events()
1807 err = perf_data__read(session->data, event, in __perf_session__process_pipe_events()
1813 pr_err("failed to read event header\n"); in __perf_session__process_pipe_events()
1817 if (session->header.needs_swap) in __perf_session__process_pipe_events()
1818 perf_event_header__bswap(&event->header); in __perf_session__process_pipe_events()
1820 size = event->header.size; in __perf_session__process_pipe_events()
1822 pr_err("bad event header size\n"); in __perf_session__process_pipe_events()
1829 pr_err("failed to allocate memory to read event\n"); in __perf_session__process_pipe_events()
1834 event = buf; in __perf_session__process_pipe_events()
1836 p = event; in __perf_session__process_pipe_events()
1839 if (size - sizeof(struct perf_event_header)) { in __perf_session__process_pipe_events()
1840 err = perf_data__read(session->data, p, in __perf_session__process_pipe_events()
1841 size - sizeof(struct perf_event_header)); in __perf_session__process_pipe_events()
1844 pr_err("unexpected end of event stream\n"); in __perf_session__process_pipe_events()
1848 pr_err("failed to read event data\n"); in __perf_session__process_pipe_events()
1853 if ((skip = perf_session__process_event(session, event, head, "pipe")) < 0) { in __perf_session__process_pipe_events()
1855 head, event->header.size, event->header.type); in __perf_session__process_pipe_events()
1856 err = -EINVAL; in __perf_session__process_pipe_events()
1887 if (!tool->no_warn) in __perf_session__process_pipe_events()
1889 ordered_events__free(&session->ordered_events); in __perf_session__process_pipe_events()
1898 union perf_event *event; in prefetch_event() local
1903 * the size of the event in the headers. in prefetch_event()
1905 if (head + sizeof(event->header) > mmap_size) in prefetch_event()
1908 event = (union perf_event *)(buf + head); in prefetch_event()
1910 perf_event_header__bswap(&event->header); in prefetch_event()
1912 event_size = event->header.size; in prefetch_event()
1914 return event; in prefetch_event()
1916 /* We're not fetching the event so swap back again */ in prefetch_event()
1918 perf_event_header__bswap(&event->header); in prefetch_event()
1920 /* Check if the event fits into the next mmapped buf. */ in prefetch_event()
1921 if (event_size <= mmap_size - head % page_size) { in prefetch_event()
1926 /* Invalid input. Event size should never exceed mmap_size. */ in prefetch_event()
1927 pr_debug("%s: head=%#" PRIx64 " event->header.size=%#x, mmap_size=%#zx:" in prefetch_event()
1936 return prefetch_event(buf, head, mmap_size, needs_swap, ERR_PTR(-EINVAL)); in fetch_mmaped_event()
1949 struct decomp *decomp = session->active_decomp->decomp_last; in __perf_session__process_decomp_events()
1954 while (decomp->head < decomp->size && !session_done()) { in __perf_session__process_decomp_events()
1955 union perf_event *event = fetch_decomp_event(decomp->head, decomp->size, decomp->data, in __perf_session__process_decomp_events() local
1956 session->header.needs_swap); in __perf_session__process_decomp_events()
1958 if (!event) in __perf_session__process_decomp_events()
1961 size = event->header.size; in __perf_session__process_decomp_events()
1964 (skip = perf_session__process_event(session, event, decomp->file_pos, in __perf_session__process_decomp_events()
1965 decomp->file_path)) < 0) { in __perf_session__process_decomp_events()
1967 decomp->file_pos + decomp->head, event->header.size, event->header.type); in __perf_session__process_decomp_events()
1968 return -EINVAL; in __perf_session__process_decomp_events()
1974 decomp->head += size; in __perf_session__process_decomp_events()
1995 union perf_event *event,
2022 u64 data_size = rd->data_size; in reader__init()
2023 char **mmaps = rd->mmaps; in reader__init()
2025 rd->head = rd->data_offset; in reader__init()
2026 data_size += rd->data_offset; in reader__init()
2028 rd->mmap_size = MMAP_SIZE; in reader__init()
2029 if (rd->mmap_size > data_size) { in reader__init()
2030 rd->mmap_size = data_size; in reader__init()
2035 memset(mmaps, 0, sizeof(rd->mmaps)); in reader__init()
2037 if (zstd_init(&rd->zstd_data, 0)) in reader__init()
2038 return -1; in reader__init()
2039 rd->decomp_data.zstd_decomp = &rd->zstd_data; in reader__init()
2047 perf_decomp__release_events(rd->decomp_data.decomp); in reader__release_decomp()
2048 zstd_fini(&rd->zstd_data); in reader__release_decomp()
2055 char *buf, **mmaps = rd->mmaps; in reader__mmap()
2061 if (rd->in_place_update) { in reader__mmap()
2063 } else if (session->header.needs_swap) { in reader__mmap()
2068 if (mmaps[rd->mmap_idx]) { in reader__mmap()
2069 munmap(mmaps[rd->mmap_idx], rd->mmap_size); in reader__mmap()
2070 mmaps[rd->mmap_idx] = NULL; in reader__mmap()
2073 page_offset = page_size * (rd->head / page_size); in reader__mmap()
2074 rd->file_offset += page_offset; in reader__mmap()
2075 rd->head -= page_offset; in reader__mmap()
2077 buf = mmap(NULL, rd->mmap_size, mmap_prot, mmap_flags, rd->fd, in reader__mmap()
2078 rd->file_offset); in reader__mmap()
2081 return -errno; in reader__mmap()
2083 mmaps[rd->mmap_idx] = rd->mmap_cur = buf; in reader__mmap()
2084 rd->mmap_idx = (rd->mmap_idx + 1) & (ARRAY_SIZE(rd->mmaps) - 1); in reader__mmap()
2085 rd->file_pos = rd->file_offset + rd->head; in reader__mmap()
2086 if (session->one_mmap) { in reader__mmap()
2087 session->one_mmap_addr = buf; in reader__mmap()
2088 session->one_mmap_offset = rd->file_offset; in reader__mmap()
2105 union perf_event *event; in reader__read_event() local
2108 event = fetch_mmaped_event(rd->head, rd->mmap_size, rd->mmap_cur, in reader__read_event()
2109 session->header.needs_swap); in reader__read_event()
2110 if (IS_ERR(event)) in reader__read_event()
2111 return PTR_ERR(event); in reader__read_event()
2113 if (!event) in reader__read_event()
2116 size = event->header.size; in reader__read_event()
2118 skip = -EINVAL; in reader__read_event()
2121 (skip = rd->process(session, event, rd->file_pos, rd->path)) < 0) { in reader__read_event()
2123 rd->file_offset + rd->head, event->header.size, in reader__read_event()
2124 event->header.type, strerror(-skip)); in reader__read_event()
2132 rd->size += size; in reader__read_event()
2133 rd->head += size; in reader__read_event()
2134 rd->file_pos += size; in reader__read_event()
2149 return (rd->file_pos >= rd->data_size + rd->data_offset); in reader__eof()
2158 err = reader__init(rd, &session->one_mmap); in reader__process_events()
2162 session->active_decomp = &rd->decomp_data; in reader__process_events()
2183 session->active_decomp = &session->decomp_data; in reader__process_events()
2188 union perf_event *event, in process_simple() argument
2192 return perf_session__process_event(session, event, file_offset, file_path); in process_simple()
2198 .fd = perf_data__fd(session->data), in __perf_session__process_events()
2199 .path = session->data->file.path, in __perf_session__process_events()
2200 .data_size = session->header.data_size, in __perf_session__process_events()
2201 .data_offset = session->header.data_offset, in __perf_session__process_events()
2203 .in_place_update = session->data->in_place_update, in __perf_session__process_events()
2205 struct ordered_events *oe = &session->ordered_events; in __perf_session__process_events()
2206 const struct perf_tool *tool = session->tool; in __perf_session__process_events()
2211 return -1; in __perf_session__process_events()
2228 if (!tool->no_warn) in __perf_session__process_events()
2234 ordered_events__reinit(&session->ordered_events); in __perf_session__process_events()
2237 session->one_mmap = false; in __perf_session__process_events()
2251 * data file holds per-cpu data, already sorted by kernel.
2255 struct perf_data *data = session->data; in __perf_session__process_dir_events()
2256 const struct perf_tool *tool = session->tool; in __perf_session__process_dir_events()
2259 u64 total_size = perf_data__size(session->data); in __perf_session__process_dir_events()
2265 for (i = 0; i < data->dir.nr; i++) { in __perf_session__process_dir_events()
2266 if (data->dir.files[i].size) in __perf_session__process_dir_events()
2272 return -ENOMEM; in __perf_session__process_dir_events()
2275 .fd = perf_data__fd(session->data), in __perf_session__process_dir_events()
2276 .path = session->data->file.path, in __perf_session__process_dir_events()
2277 .data_size = session->header.data_size, in __perf_session__process_dir_events()
2278 .data_offset = session->header.data_offset, in __perf_session__process_dir_events()
2280 .in_place_update = session->data->in_place_update, in __perf_session__process_dir_events()
2290 for (i = 0; i < data->dir.nr; i++) { in __perf_session__process_dir_events()
2291 if (!data->dir.files[i].size) in __perf_session__process_dir_events()
2294 .fd = data->dir.files[i].fd, in __perf_session__process_dir_events()
2295 .path = data->dir.files[i].path, in __perf_session__process_dir_events()
2296 .data_size = data->dir.files[i].size, in __perf_session__process_dir_events()
2299 .in_place_update = session->data->in_place_update, in __perf_session__process_dir_events()
2321 readers--; in __perf_session__process_dir_events()
2325 session->active_decomp = &rd[i].decomp_data; in __perf_session__process_dir_events()
2341 ret = ordered_events__flush(&session->ordered_events, OE_FLUSH__FINAL); in __perf_session__process_dir_events()
2349 if (!tool->no_warn) in __perf_session__process_dir_events()
2356 ordered_events__reinit(&session->ordered_events); in __perf_session__process_dir_events()
2358 session->one_mmap = false; in __perf_session__process_dir_events()
2360 session->active_decomp = &session->decomp_data; in __perf_session__process_dir_events()
2371 return -ENOMEM; in perf_session__process_events()
2373 if (perf_data__is_pipe(session->data)) in perf_session__process_events()
2376 if (perf_data__is_dir(session->data) && session->data->dir.nr) in perf_session__process_events()
2386 evlist__for_each_entry(session->evlist, evsel) { in perf_session__has_traces()
2387 if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT) in perf_session__has_traces()
2403 return -ENOMEM; in map__set_kallsyms_ref_reloc_sym()
2405 ref->name = strdup(symbol_name); in map__set_kallsyms_ref_reloc_sym()
2406 if (ref->name == NULL) { in map__set_kallsyms_ref_reloc_sym()
2408 return -ENOMEM; in map__set_kallsyms_ref_reloc_sym()
2411 bracket = strchr(ref->name, ']'); in map__set_kallsyms_ref_reloc_sym()
2415 ref->addr = addr; in map__set_kallsyms_ref_reloc_sym()
2419 kmap->ref_reloc_sym = ref; in map__set_kallsyms_ref_reloc_sym()
2426 return machines__fprintf_dsos(&session->machines, fp); in perf_session__fprintf_dsos()
2432 return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm); in perf_session__fprintf_dsos_buildid()
2440 if (perf_header__has_feat(&session->header, HEADER_AUXTRACE)) in perf_session__fprintf_nr_events()
2445 ret += events_stats__fprintf(&session->evlist->stats, fp); in perf_session__fprintf_nr_events()
2455 return machine__fprintf(&session->machines.host, fp); in perf_session__fprintf()
2465 maps__fprintf(machine__kernel_maps(&session->machines.host), stderr); in perf_session__dump_kmaps()
2474 evlist__for_each_entry(session->evlist, pos) { in perf_session__find_first_evtype()
2475 if (pos->core.attr.type == type) in perf_session__find_first_evtype()
2484 int i, err = -1; in perf_session__cpu_bitmap()
2486 int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS); in perf_session__cpu_bitmap()
2496 if (!(evsel->core.attr.sample_type & PERF_SAMPLE_CPU)) { in perf_session__cpu_bitmap()
2498 "Remove -C option to proceed.\n"); in perf_session__cpu_bitmap()
2499 return -1; in perf_session__cpu_bitmap()
2506 return -1; in perf_session__cpu_bitmap()
2539 struct machine *machine = machines__findnew(&session->machines, machine_pid); in perf_session__register_guest()
2543 return -ENOMEM; in perf_session__register_guest()
2545 machine->single_address_space = session->machines.host.single_address_space; in perf_session__register_guest()
2549 return -ENOMEM; in perf_session__register_guest()
2552 machine->kallsyms_filename = perf_data__guest_kallsyms_name(session->data, machine_pid); in perf_session__register_guest()
2560 struct machine *machine = &session->machines.host; in perf_session__set_guest_cpu()
2564 return -ENOMEM; in perf_session__set_guest_cpu()
2572 union perf_event *event) in perf_event__process_id_index() argument
2574 struct evlist *evlist = session->evlist; in perf_event__process_id_index()
2575 struct perf_record_id_index *ie = &event->id_index; in perf_event__process_id_index()
2576 size_t sz = ie->header.size - sizeof(*ie); in perf_event__process_id_index()
2585 nr = ie->nr; in perf_event__process_id_index()
2588 return -EINVAL; in perf_event__process_id_index()
2595 return -EINVAL; in perf_event__process_id_index()
2606 struct id_index_entry *e = &ie->entries[i]; in perf_event__process_id_index()
2611 fprintf(stdout, " ... id: %"PRI_lu64, e->id); in perf_event__process_id_index()
2612 fprintf(stdout, " idx: %"PRI_lu64, e->idx); in perf_event__process_id_index()
2613 fprintf(stdout, " cpu: %"PRI_ld64, e->cpu); in perf_event__process_id_index()
2614 fprintf(stdout, " tid: %"PRI_ld64, e->tid); in perf_event__process_id_index()
2616 fprintf(stdout, " machine_pid: %"PRI_ld64, e2->machine_pid); in perf_event__process_id_index()
2617 fprintf(stdout, " vcpu: %"PRI_lu64"\n", e2->vcpu); in perf_event__process_id_index()
2623 sid = evlist__id2sid(evlist, e->id); in perf_event__process_id_index()
2625 return -ENOENT; in perf_event__process_id_index()
2627 sid->idx = e->idx; in perf_event__process_id_index()
2628 sid->cpu.cpu = e->cpu; in perf_event__process_id_index()
2629 sid->tid = e->tid; in perf_event__process_id_index()
2634 sid->machine_pid = e2->machine_pid; in perf_event__process_id_index()
2635 sid->vcpu.cpu = e2->vcpu; in perf_event__process_id_index()
2637 if (!sid->machine_pid) in perf_event__process_id_index()
2640 if (sid->machine_pid != last_pid) { in perf_event__process_id_index()
2641 ret = perf_session__register_guest(session, sid->machine_pid); in perf_event__process_id_index()
2644 last_pid = sid->machine_pid; in perf_event__process_id_index()
2648 ret = perf_session__set_guest_cpu(session, sid->machine_pid, e->tid, e2->vcpu); in perf_event__process_id_index()
2660 err = machine__hit_all_dsos(&session->machines.host); in perf_session__dsos_hit_all()
2664 for (nd = rb_first_cached(&session->machines.guests); nd; in perf_session__dsos_hit_all()