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, u64 file_offset, in perf_session__process_compressed_event() argument
49 size_t mmap_len, decomp_len = session->header.env.comp_mmap_len; in perf_session__process_compressed_event()
50 struct decomp *decomp, *decomp_last = session->active_decomp->decomp_last; in perf_session__process_compressed_event()
53 decomp_last_rem = decomp_last->size - decomp_last->head; in perf_session__process_compressed_event()
59 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); in perf_session__process_compressed_event()
62 return -1; in perf_session__process_compressed_event()
65 decomp->file_pos = file_offset; in perf_session__process_compressed_event()
66 decomp->file_path = file_path; in perf_session__process_compressed_event()
67 decomp->mmap_len = mmap_len; in perf_session__process_compressed_event()
68 decomp->head = 0; in perf_session__process_compressed_event()
71 memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); in perf_session__process_compressed_event()
72 decomp->size = decomp_last_rem; in perf_session__process_compressed_event()
75 src = (void *)event + sizeof(struct perf_record_compressed); in perf_session__process_compressed_event()
76 src_size = event->pack.header.size - sizeof(struct perf_record_compressed); in perf_session__process_compressed_event()
78 decomp_size = zstd_decompress_stream(session->active_decomp->zstd_decomp, src, src_size, in perf_session__process_compressed_event()
79 &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); in perf_session__process_compressed_event()
83 return -1; in perf_session__process_compressed_event()
86 decomp->size += decomp_size; in perf_session__process_compressed_event()
88 if (session->active_decomp->decomp == NULL) in perf_session__process_compressed_event()
89 session->active_decomp->decomp = decomp; in perf_session__process_compressed_event()
91 session->active_decomp->decomp_last->next = decomp; in perf_session__process_compressed_event()
93 session->active_decomp->decomp_last = decomp; in perf_session__process_compressed_event()
104 union perf_event *event,
111 struct perf_data *data = session->data; in perf_session__open()
114 pr_err("incompatible file format (rerun with -v to learn more)\n"); in perf_session__open()
115 return -1; in perf_session__open()
118 if (perf_header__has_feat(&session->header, HEADER_AUXTRACE)) { in perf_session__open()
126 if (perf_header__has_feat(&session->header, HEADER_STAT)) in perf_session__open()
129 if (!evlist__valid_sample_type(session->evlist)) { in perf_session__open()
131 return -1; in perf_session__open()
134 if (!evlist__valid_sample_id_all(session->evlist)) { in perf_session__open()
136 return -1; in perf_session__open()
139 if (!evlist__valid_read_format(session->evlist)) { in perf_session__open()
141 return -1; in perf_session__open()
149 u16 id_hdr_size = evlist__id_hdr_size(session->evlist); in perf_session__set_id_hdr_size()
151 machines__set_id_hdr_size(&session->machines, id_hdr_size); in perf_session__set_id_hdr_size()
156 int ret = machine__create_kernel_maps(&session->machines.host); in perf_session__create_kernel_maps()
159 ret = machines__create_guest_kernel_maps(&session->machines); in perf_session__create_kernel_maps()
165 machines__destroy_kernel_maps(&session->machines); in perf_session__destroy_kernel_maps()
172 evlist__for_each_entry(session->evlist, evsel) { in perf_session__has_comm_exec()
173 if (evsel->core.attr.comm_exec) in perf_session__has_comm_exec()
184 machines__set_comm_exec(&session->machines, comm_exec); in perf_session__set_comm_exec()
188 struct ordered_event *event) in ordered_events__deliver_event() argument
193 return perf_session__deliver_event(session, event->event, in ordered_events__deliver_event()
194 session->tool, event->file_offset, in ordered_events__deliver_event()
195 event->file_path); in ordered_events__deliver_event()
202 int ret = -ENOMEM; in __perf_session__new()
208 session->repipe = repipe; in __perf_session__new()
209 session->tool = tool; in __perf_session__new()
210 session->decomp_data.zstd_decomp = &session->zstd_data; in __perf_session__new()
211 session->active_decomp = &session->decomp_data; in __perf_session__new()
212 INIT_LIST_HEAD(&session->auxtrace_index); in __perf_session__new()
213 machines__init(&session->machines); in __perf_session__new()
214 ordered_events__init(&session->ordered_events, in __perf_session__new()
217 perf_env__init(&session->header.env); in __perf_session__new()
223 session->data = data; in __perf_session__new()
232 * but not in pipe-mode. in __perf_session__new()
234 if (!data->is_pipe) { in __perf_session__new()
239 evlist__init_trace_event_sample_raw(session->evlist); in __perf_session__new()
242 if (data->is_dir) { in __perf_session__new()
253 session->machines.host.env = &perf_env; in __perf_session__new()
256 session->machines.host.single_address_space = in __perf_session__new()
257 perf_env__single_address_space(session->machines.host.env); in __perf_session__new()
262 * kernel MMAP event, in perf_event__process_mmap(). in __perf_session__new()
269 * In pipe-mode, evlist is empty until PERF_RECORD_HEADER_ATTR is in __perf_session__new()
272 if ((!data || !data->is_pipe) && tool && tool->ordering_requires_timestamps && in __perf_session__new()
273 tool->ordered_events && !evlist__sample_id_all(session->evlist)) { in __perf_session__new()
275 tool->ordered_events = false; in __perf_session__new()
295 next = decomp->next; in perf_decomp__release_events()
296 mmap_len = decomp->mmap_len; in perf_decomp__release_events()
306 auxtrace_index__free(&session->auxtrace_index); in perf_session__delete()
308 perf_decomp__release_events(session->decomp_data.decomp); in perf_session__delete()
309 perf_env__exit(&session->header.env); in perf_session__delete()
310 machines__exit(&session->machines); in perf_session__delete()
311 if (session->data) { in perf_session__delete()
312 if (perf_data__is_read(session->data)) in perf_session__delete()
313 evlist__delete(session->evlist); in perf_session__delete()
314 perf_data__close(session->data); in perf_session__delete()
317 trace_event__cleanup(&session->tevent); in perf_session__delete()
324 union perf_event *event in process_event_synth_tracing_data_stub()
332 union perf_event *event __maybe_unused, in process_event_synth_attr_stub()
341 union perf_event *event __maybe_unused, in process_event_synth_event_update_stub()
346 perf_event__fprintf_event_update(event, stdout); in process_event_synth_event_update_stub()
353 union perf_event *event __maybe_unused, in process_event_sample_stub()
363 union perf_event *event __maybe_unused, in process_event_stub()
372 union perf_event *event __maybe_unused, in process_finished_round_stub()
388 n -= ret; in skipn()
395 union perf_event *event) in process_event_auxtrace_stub() argument
398 if (perf_data__is_pipe(session->data)) in process_event_auxtrace_stub()
399 skipn(perf_data__fd(session->data), event->auxtrace.size); in process_event_auxtrace_stub()
400 return event->auxtrace.size; in process_event_auxtrace_stub()
404 union perf_event *event __maybe_unused) in process_event_op2_stub()
413 union perf_event *event __maybe_unused) in process_event_thread_map_stub()
416 perf_event__fprintf_thread_map(event, stdout); in process_event_thread_map_stub()
424 union perf_event *event __maybe_unused) in process_event_cpu_map_stub()
427 perf_event__fprintf_cpu_map(event, stdout); in process_event_cpu_map_stub()
435 union perf_event *event __maybe_unused) in process_event_stat_config_stub()
438 perf_event__fprintf_stat_config(event, stdout); in process_event_stat_config_stub()
445 union perf_event *event) in process_stat_stub() argument
448 perf_event__fprintf_stat(event, stdout); in process_stat_stub()
455 union perf_event *event) in process_stat_round_stub() argument
458 perf_event__fprintf_stat_round(event, stdout); in process_stat_round_stub()
465 union perf_event *event) in process_event_time_conv_stub() argument
468 perf_event__fprintf_time_conv(event, stdout); in process_event_time_conv_stub()
475 union perf_event *event __maybe_unused, in perf_session__process_compressed_event_stub()
485 if (tool->sample == NULL) in perf_tool__fill_defaults()
486 tool->sample = process_event_sample_stub; in perf_tool__fill_defaults()
487 if (tool->mmap == NULL) in perf_tool__fill_defaults()
488 tool->mmap = process_event_stub; in perf_tool__fill_defaults()
489 if (tool->mmap2 == NULL) in perf_tool__fill_defaults()
490 tool->mmap2 = process_event_stub; in perf_tool__fill_defaults()
491 if (tool->comm == NULL) in perf_tool__fill_defaults()
492 tool->comm = process_event_stub; in perf_tool__fill_defaults()
493 if (tool->namespaces == NULL) in perf_tool__fill_defaults()
494 tool->namespaces = process_event_stub; in perf_tool__fill_defaults()
495 if (tool->cgroup == NULL) in perf_tool__fill_defaults()
496 tool->cgroup = process_event_stub; in perf_tool__fill_defaults()
497 if (tool->fork == NULL) in perf_tool__fill_defaults()
498 tool->fork = process_event_stub; in perf_tool__fill_defaults()
499 if (tool->exit == NULL) in perf_tool__fill_defaults()
500 tool->exit = process_event_stub; in perf_tool__fill_defaults()
501 if (tool->lost == NULL) in perf_tool__fill_defaults()
502 tool->lost = perf_event__process_lost; in perf_tool__fill_defaults()
503 if (tool->lost_samples == NULL) in perf_tool__fill_defaults()
504 tool->lost_samples = perf_event__process_lost_samples; in perf_tool__fill_defaults()
505 if (tool->aux == NULL) in perf_tool__fill_defaults()
506 tool->aux = perf_event__process_aux; in perf_tool__fill_defaults()
507 if (tool->itrace_start == NULL) in perf_tool__fill_defaults()
508 tool->itrace_start = perf_event__process_itrace_start; in perf_tool__fill_defaults()
509 if (tool->context_switch == NULL) in perf_tool__fill_defaults()
510 tool->context_switch = perf_event__process_switch; in perf_tool__fill_defaults()
511 if (tool->ksymbol == NULL) in perf_tool__fill_defaults()
512 tool->ksymbol = perf_event__process_ksymbol; in perf_tool__fill_defaults()
513 if (tool->bpf == NULL) in perf_tool__fill_defaults()
514 tool->bpf = perf_event__process_bpf; in perf_tool__fill_defaults()
515 if (tool->text_poke == NULL) in perf_tool__fill_defaults()
516 tool->text_poke = perf_event__process_text_poke; in perf_tool__fill_defaults()
517 if (tool->aux_output_hw_id == NULL) in perf_tool__fill_defaults()
518 tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; in perf_tool__fill_defaults()
519 if (tool->read == NULL) in perf_tool__fill_defaults()
520 tool->read = process_event_sample_stub; in perf_tool__fill_defaults()
521 if (tool->throttle == NULL) in perf_tool__fill_defaults()
522 tool->throttle = process_event_stub; in perf_tool__fill_defaults()
523 if (tool->unthrottle == NULL) in perf_tool__fill_defaults()
524 tool->unthrottle = process_event_stub; in perf_tool__fill_defaults()
525 if (tool->attr == NULL) in perf_tool__fill_defaults()
526 tool->attr = process_event_synth_attr_stub; in perf_tool__fill_defaults()
527 if (tool->event_update == NULL) in perf_tool__fill_defaults()
528 tool->event_update = process_event_synth_event_update_stub; in perf_tool__fill_defaults()
529 if (tool->tracing_data == NULL) in perf_tool__fill_defaults()
530 tool->tracing_data = process_event_synth_tracing_data_stub; in perf_tool__fill_defaults()
531 if (tool->build_id == NULL) in perf_tool__fill_defaults()
532 tool->build_id = process_event_op2_stub; in perf_tool__fill_defaults()
533 if (tool->finished_round == NULL) { in perf_tool__fill_defaults()
534 if (tool->ordered_events) in perf_tool__fill_defaults()
535 tool->finished_round = perf_event__process_finished_round; in perf_tool__fill_defaults()
537 tool->finished_round = process_finished_round_stub; in perf_tool__fill_defaults()
539 if (tool->id_index == NULL) in perf_tool__fill_defaults()
540 tool->id_index = process_event_op2_stub; in perf_tool__fill_defaults()
541 if (tool->auxtrace_info == NULL) in perf_tool__fill_defaults()
542 tool->auxtrace_info = process_event_op2_stub; in perf_tool__fill_defaults()
543 if (tool->auxtrace == NULL) in perf_tool__fill_defaults()
544 tool->auxtrace = process_event_auxtrace_stub; in perf_tool__fill_defaults()
545 if (tool->auxtrace_error == NULL) in perf_tool__fill_defaults()
546 tool->auxtrace_error = process_event_op2_stub; in perf_tool__fill_defaults()
547 if (tool->thread_map == NULL) in perf_tool__fill_defaults()
548 tool->thread_map = process_event_thread_map_stub; in perf_tool__fill_defaults()
549 if (tool->cpu_map == NULL) in perf_tool__fill_defaults()
550 tool->cpu_map = process_event_cpu_map_stub; in perf_tool__fill_defaults()
551 if (tool->stat_config == NULL) in perf_tool__fill_defaults()
552 tool->stat_config = process_event_stat_config_stub; in perf_tool__fill_defaults()
553 if (tool->stat == NULL) in perf_tool__fill_defaults()
554 tool->stat = process_stat_stub; in perf_tool__fill_defaults()
555 if (tool->stat_round == NULL) in perf_tool__fill_defaults()
556 tool->stat_round = process_stat_round_stub; in perf_tool__fill_defaults()
557 if (tool->time_conv == NULL) in perf_tool__fill_defaults()
558 tool->time_conv = process_event_time_conv_stub; in perf_tool__fill_defaults()
559 if (tool->feature == NULL) in perf_tool__fill_defaults()
560 tool->feature = process_event_op2_stub; in perf_tool__fill_defaults()
561 if (tool->compressed == NULL) in perf_tool__fill_defaults()
562 tool->compressed = perf_session__process_compressed_event; in perf_tool__fill_defaults()
563 if (tool->finished_init == NULL) in perf_tool__fill_defaults()
564 tool->finished_init = process_event_op2_stub; in perf_tool__fill_defaults()
567 static void swap_sample_id_all(union perf_event *event, void *data) in swap_sample_id_all() argument
569 void *end = (void *) event + event->header.size; in swap_sample_id_all()
570 int size = end - data; in swap_sample_id_all()
576 static void perf_event__all64_swap(union perf_event *event, in perf_event__all64_swap() argument
579 struct perf_event_header *hdr = &event->header; in perf_event__all64_swap()
580 mem_bswap_64(hdr + 1, event->header.size - sizeof(*hdr)); in perf_event__all64_swap()
583 static void perf_event__comm_swap(union perf_event *event, bool sample_id_all) in perf_event__comm_swap() argument
585 event->comm.pid = bswap_32(event->comm.pid); in perf_event__comm_swap()
586 event->comm.tid = bswap_32(event->comm.tid); in perf_event__comm_swap()
589 void *data = &event->comm.comm; in perf_event__comm_swap()
592 swap_sample_id_all(event, data); in perf_event__comm_swap()
596 static void perf_event__mmap_swap(union perf_event *event, in perf_event__mmap_swap() argument
599 event->mmap.pid = bswap_32(event->mmap.pid); in perf_event__mmap_swap()
600 event->mmap.tid = bswap_32(event->mmap.tid); in perf_event__mmap_swap()
601 event->mmap.start = bswap_64(event->mmap.start); in perf_event__mmap_swap()
602 event->mmap.len = bswap_64(event->mmap.len); in perf_event__mmap_swap()
603 event->mmap.pgoff = bswap_64(event->mmap.pgoff); in perf_event__mmap_swap()
606 void *data = &event->mmap.filename; in perf_event__mmap_swap()
609 swap_sample_id_all(event, data); in perf_event__mmap_swap()
613 static void perf_event__mmap2_swap(union perf_event *event, in perf_event__mmap2_swap() argument
616 event->mmap2.pid = bswap_32(event->mmap2.pid); in perf_event__mmap2_swap()
617 event->mmap2.tid = bswap_32(event->mmap2.tid); in perf_event__mmap2_swap()
618 event->mmap2.start = bswap_64(event->mmap2.start); in perf_event__mmap2_swap()
619 event->mmap2.len = bswap_64(event->mmap2.len); in perf_event__mmap2_swap()
620 event->mmap2.pgoff = bswap_64(event->mmap2.pgoff); in perf_event__mmap2_swap()
622 if (!(event->header.misc & PERF_RECORD_MISC_MMAP_BUILD_ID)) { in perf_event__mmap2_swap()
623 event->mmap2.maj = bswap_32(event->mmap2.maj); in perf_event__mmap2_swap()
624 event->mmap2.min = bswap_32(event->mmap2.min); in perf_event__mmap2_swap()
625 event->mmap2.ino = bswap_64(event->mmap2.ino); in perf_event__mmap2_swap()
626 event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation); in perf_event__mmap2_swap()
630 void *data = &event->mmap2.filename; in perf_event__mmap2_swap()
633 swap_sample_id_all(event, data); in perf_event__mmap2_swap()
636 static void perf_event__task_swap(union perf_event *event, bool sample_id_all) in perf_event__task_swap() argument
638 event->fork.pid = bswap_32(event->fork.pid); in perf_event__task_swap()
639 event->fork.tid = bswap_32(event->fork.tid); in perf_event__task_swap()
640 event->fork.ppid = bswap_32(event->fork.ppid); in perf_event__task_swap()
641 event->fork.ptid = bswap_32(event->fork.ptid); in perf_event__task_swap()
642 event->fork.time = bswap_64(event->fork.time); in perf_event__task_swap()
645 swap_sample_id_all(event, &event->fork + 1); in perf_event__task_swap()
648 static void perf_event__read_swap(union perf_event *event, bool sample_id_all) in perf_event__read_swap() argument
650 event->read.pid = bswap_32(event->read.pid); in perf_event__read_swap()
651 event->read.tid = bswap_32(event->read.tid); in perf_event__read_swap()
652 event->read.value = bswap_64(event->read.value); in perf_event__read_swap()
653 event->read.time_enabled = bswap_64(event->read.time_enabled); in perf_event__read_swap()
654 event->read.time_running = bswap_64(event->read.time_running); in perf_event__read_swap()
655 event->read.id = bswap_64(event->read.id); in perf_event__read_swap()
658 swap_sample_id_all(event, &event->read + 1); in perf_event__read_swap()
661 static void perf_event__aux_swap(union perf_event *event, bool sample_id_all) in perf_event__aux_swap() argument
663 event->aux.aux_offset = bswap_64(event->aux.aux_offset); in perf_event__aux_swap()
664 event->aux.aux_size = bswap_64(event->aux.aux_size); in perf_event__aux_swap()
665 event->aux.flags = bswap_64(event->aux.flags); in perf_event__aux_swap()
668 swap_sample_id_all(event, &event->aux + 1); in perf_event__aux_swap()
671 static void perf_event__itrace_start_swap(union perf_event *event, in perf_event__itrace_start_swap() argument
674 event->itrace_start.pid = bswap_32(event->itrace_start.pid); in perf_event__itrace_start_swap()
675 event->itrace_start.tid = bswap_32(event->itrace_start.tid); in perf_event__itrace_start_swap()
678 swap_sample_id_all(event, &event->itrace_start + 1); in perf_event__itrace_start_swap()
681 static void perf_event__switch_swap(union perf_event *event, bool sample_id_all) in perf_event__switch_swap() argument
683 if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE) { in perf_event__switch_swap()
684 event->context_switch.next_prev_pid = in perf_event__switch_swap()
685 bswap_32(event->context_switch.next_prev_pid); in perf_event__switch_swap()
686 event->context_switch.next_prev_tid = in perf_event__switch_swap()
687 bswap_32(event->context_switch.next_prev_tid); in perf_event__switch_swap()
691 swap_sample_id_all(event, &event->context_switch + 1); in perf_event__switch_swap()
694 static void perf_event__text_poke_swap(union perf_event *event, bool sample_id_all) in perf_event__text_poke_swap() argument
696 event->text_poke.addr = bswap_64(event->text_poke.addr); in perf_event__text_poke_swap()
697 event->text_poke.old_len = bswap_16(event->text_poke.old_len); in perf_event__text_poke_swap()
698 event->text_poke.new_len = bswap_16(event->text_poke.new_len); in perf_event__text_poke_swap()
701 size_t len = sizeof(event->text_poke.old_len) + in perf_event__text_poke_swap()
702 sizeof(event->text_poke.new_len) + in perf_event__text_poke_swap()
703 event->text_poke.old_len + in perf_event__text_poke_swap()
704 event->text_poke.new_len; in perf_event__text_poke_swap()
705 void *data = &event->text_poke.old_len; in perf_event__text_poke_swap()
708 swap_sample_id_all(event, data); in perf_event__text_poke_swap()
712 static void perf_event__throttle_swap(union perf_event *event, in perf_event__throttle_swap() argument
715 event->throttle.time = bswap_64(event->throttle.time); in perf_event__throttle_swap()
716 event->throttle.id = bswap_64(event->throttle.id); in perf_event__throttle_swap()
717 event->throttle.stream_id = bswap_64(event->throttle.stream_id); in perf_event__throttle_swap()
720 swap_sample_id_all(event, &event->throttle + 1); in perf_event__throttle_swap()
723 static void perf_event__namespaces_swap(union perf_event *event, in perf_event__namespaces_swap() argument
728 event->namespaces.pid = bswap_32(event->namespaces.pid); in perf_event__namespaces_swap()
729 event->namespaces.tid = bswap_32(event->namespaces.tid); in perf_event__namespaces_swap()
730 event->namespaces.nr_namespaces = bswap_64(event->namespaces.nr_namespaces); in perf_event__namespaces_swap()
732 for (i = 0; i < event->namespaces.nr_namespaces; i++) { in perf_event__namespaces_swap()
733 struct perf_ns_link_info *ns = &event->namespaces.link_info[i]; in perf_event__namespaces_swap()
735 ns->dev = bswap_64(ns->dev); in perf_event__namespaces_swap()
736 ns->ino = bswap_64(ns->ino); in perf_event__namespaces_swap()
740 swap_sample_id_all(event, &event->namespaces.link_info[i]); in perf_event__namespaces_swap()
743 static void perf_event__cgroup_swap(union perf_event *event, bool sample_id_all) in perf_event__cgroup_swap() argument
745 event->cgroup.id = bswap_64(event->cgroup.id); in perf_event__cgroup_swap()
748 void *data = &event->cgroup.path; in perf_event__cgroup_swap()
751 swap_sample_id_all(event, data); in perf_event__cgroup_swap()
767 * Bit-fields are allocated from right to left (least to most significant)
768 * on little-endian implementations and from left to right (most to least
769 * significant) on big-endian implementations.
790 attr->type = bswap_32(attr->type); in perf_event__attr_swap()
791 attr->size = bswap_32(attr->size); in perf_event__attr_swap()
794 (attr->size > (offsetof(struct perf_event_attr, f) + \ in perf_event__attr_swap()
795 sizeof(attr->f) * (n))) in perf_event__attr_swap()
799 attr->f = bswap_##sz(attr->f); \ in perf_event__attr_swap()
825 swap_bitfield((u8 *) (&attr->read_format + 1), in perf_event__attr_swap()
833 static void perf_event__hdr_attr_swap(union perf_event *event, in perf_event__hdr_attr_swap() argument
838 perf_event__attr_swap(&event->attr.attr); in perf_event__hdr_attr_swap()
840 size = event->header.size; in perf_event__hdr_attr_swap()
841 size -= perf_record_header_attr_id(event) - (void *)event; in perf_event__hdr_attr_swap()
842 mem_bswap_64(perf_record_header_attr_id(event), size); in perf_event__hdr_attr_swap()
845 static void perf_event__event_update_swap(union perf_event *event, in perf_event__event_update_swap() argument
848 event->event_update.type = bswap_64(event->event_update.type); in perf_event__event_update_swap()
849 event->event_update.id = bswap_64(event->event_update.id); in perf_event__event_update_swap()
852 static void perf_event__event_type_swap(union perf_event *event, in perf_event__event_type_swap() argument
855 event->event_type.event_type.event_id = in perf_event__event_type_swap()
856 bswap_64(event->event_type.event_type.event_id); in perf_event__event_type_swap()
859 static void perf_event__tracing_data_swap(union perf_event *event, in perf_event__tracing_data_swap() argument
862 event->tracing_data.size = bswap_32(event->tracing_data.size); in perf_event__tracing_data_swap()
865 static void perf_event__auxtrace_info_swap(union perf_event *event, in perf_event__auxtrace_info_swap() argument
870 event->auxtrace_info.type = bswap_32(event->auxtrace_info.type); in perf_event__auxtrace_info_swap()
872 size = event->header.size; in perf_event__auxtrace_info_swap()
873 size -= (void *)&event->auxtrace_info.priv - (void *)event; in perf_event__auxtrace_info_swap()
874 mem_bswap_64(event->auxtrace_info.priv, size); in perf_event__auxtrace_info_swap()
877 static void perf_event__auxtrace_swap(union perf_event *event, in perf_event__auxtrace_swap() argument
880 event->auxtrace.size = bswap_64(event->auxtrace.size); in perf_event__auxtrace_swap()
881 event->auxtrace.offset = bswap_64(event->auxtrace.offset); in perf_event__auxtrace_swap()
882 event->auxtrace.reference = bswap_64(event->auxtrace.reference); in perf_event__auxtrace_swap()
883 event->auxtrace.idx = bswap_32(event->auxtrace.idx); in perf_event__auxtrace_swap()
884 event->auxtrace.tid = bswap_32(event->auxtrace.tid); in perf_event__auxtrace_swap()
885 event->auxtrace.cpu = bswap_32(event->auxtrace.cpu); in perf_event__auxtrace_swap()
888 static void perf_event__auxtrace_error_swap(union perf_event *event, in perf_event__auxtrace_error_swap() argument
891 event->auxtrace_error.type = bswap_32(event->auxtrace_error.type); in perf_event__auxtrace_error_swap()
892 event->auxtrace_error.code = bswap_32(event->auxtrace_error.code); in perf_event__auxtrace_error_swap()
893 event->auxtrace_error.cpu = bswap_32(event->auxtrace_error.cpu); in perf_event__auxtrace_error_swap()
894 event->auxtrace_error.pid = bswap_32(event->auxtrace_error.pid); in perf_event__auxtrace_error_swap()
895 event->auxtrace_error.tid = bswap_32(event->auxtrace_error.tid); in perf_event__auxtrace_error_swap()
896 event->auxtrace_error.fmt = bswap_32(event->auxtrace_error.fmt); in perf_event__auxtrace_error_swap()
897 event->auxtrace_error.ip = bswap_64(event->auxtrace_error.ip); in perf_event__auxtrace_error_swap()
898 if (event->auxtrace_error.fmt) in perf_event__auxtrace_error_swap()
899 event->auxtrace_error.time = bswap_64(event->auxtrace_error.time); in perf_event__auxtrace_error_swap()
900 if (event->auxtrace_error.fmt >= 2) { in perf_event__auxtrace_error_swap()
901 event->auxtrace_error.machine_pid = bswap_32(event->auxtrace_error.machine_pid); in perf_event__auxtrace_error_swap()
902 event->auxtrace_error.vcpu = bswap_32(event->auxtrace_error.vcpu); in perf_event__auxtrace_error_swap()
906 static void perf_event__thread_map_swap(union perf_event *event, in perf_event__thread_map_swap() argument
911 event->thread_map.nr = bswap_64(event->thread_map.nr); in perf_event__thread_map_swap()
913 for (i = 0; i < event->thread_map.nr; i++) in perf_event__thread_map_swap()
914 event->thread_map.entries[i].pid = bswap_64(event->thread_map.entries[i].pid); in perf_event__thread_map_swap()
917 static void perf_event__cpu_map_swap(union perf_event *event, in perf_event__cpu_map_swap() argument
920 struct perf_record_cpu_map_data *data = &event->cpu_map.data; in perf_event__cpu_map_swap()
922 data->type = bswap_16(data->type); in perf_event__cpu_map_swap()
924 switch (data->type) { in perf_event__cpu_map_swap()
926 data->cpus_data.nr = bswap_16(data->cpus_data.nr); in perf_event__cpu_map_swap()
928 for (unsigned i = 0; i < data->cpus_data.nr; i++) in perf_event__cpu_map_swap()
929 data->cpus_data.cpu[i] = bswap_16(data->cpus_data.cpu[i]); in perf_event__cpu_map_swap()
932 data->mask32_data.long_size = bswap_16(data->mask32_data.long_size); in perf_event__cpu_map_swap()
934 switch (data->mask32_data.long_size) { in perf_event__cpu_map_swap()
936 data->mask32_data.nr = bswap_16(data->mask32_data.nr); in perf_event__cpu_map_swap()
937 for (unsigned i = 0; i < data->mask32_data.nr; i++) in perf_event__cpu_map_swap()
938 data->mask32_data.mask[i] = bswap_32(data->mask32_data.mask[i]); in perf_event__cpu_map_swap()
941 data->mask64_data.nr = bswap_16(data->mask64_data.nr); in perf_event__cpu_map_swap()
942 for (unsigned i = 0; i < data->mask64_data.nr; i++) in perf_event__cpu_map_swap()
943 data->mask64_data.mask[i] = bswap_64(data->mask64_data.mask[i]); in perf_event__cpu_map_swap()
950 data->range_cpu_data.start_cpu = bswap_16(data->range_cpu_data.start_cpu); in perf_event__cpu_map_swap()
951 data->range_cpu_data.end_cpu = bswap_16(data->range_cpu_data.end_cpu); in perf_event__cpu_map_swap()
958 static void perf_event__stat_config_swap(union perf_event *event, in perf_event__stat_config_swap() argument
963 size = bswap_64(event->stat_config.nr) * sizeof(event->stat_config.data[0]); in perf_event__stat_config_swap()
965 mem_bswap_64(&event->stat_config.nr, size); in perf_event__stat_config_swap()
968 static void perf_event__stat_swap(union perf_event *event, in perf_event__stat_swap() argument
971 event->stat.id = bswap_64(event->stat.id); in perf_event__stat_swap()
972 event->stat.thread = bswap_32(event->stat.thread); in perf_event__stat_swap()
973 event->stat.cpu = bswap_32(event->stat.cpu); in perf_event__stat_swap()
974 event->stat.val = bswap_64(event->stat.val); in perf_event__stat_swap()
975 event->stat.ena = bswap_64(event->stat.ena); in perf_event__stat_swap()
976 event->stat.run = bswap_64(event->stat.run); in perf_event__stat_swap()
979 static void perf_event__stat_round_swap(union perf_event *event, in perf_event__stat_round_swap() argument
982 event->stat_round.type = bswap_64(event->stat_round.type); in perf_event__stat_round_swap()
983 event->stat_round.time = bswap_64(event->stat_round.time); in perf_event__stat_round_swap()
986 static void perf_event__time_conv_swap(union perf_event *event, in perf_event__time_conv_swap() argument
989 event->time_conv.time_shift = bswap_64(event->time_conv.time_shift); in perf_event__time_conv_swap()
990 event->time_conv.time_mult = bswap_64(event->time_conv.time_mult); in perf_event__time_conv_swap()
991 event->time_conv.time_zero = bswap_64(event->time_conv.time_zero); in perf_event__time_conv_swap()
993 if (event_contains(event->time_conv, time_cycles)) { in perf_event__time_conv_swap()
994 event->time_conv.time_cycles = bswap_64(event->time_conv.time_cycles); in perf_event__time_conv_swap()
995 event->time_conv.time_mask = bswap_64(event->time_conv.time_mask); in perf_event__time_conv_swap()
999 typedef void (*perf_event__swap_op)(union perf_event *event,
1042 * event.
1056 * - | 4 <--- max recorded
1064 * 5 | 7 <---- max recorded
1074 * - | 10
1080 union perf_event *event __maybe_unused, in perf_event__process_finished_round()
1088 int perf_session__queue_event(struct perf_session *s, union perf_event *event, in perf_session__queue_event() argument
1091 return ordered_events__queue(&s->ordered_events, event, timestamp, file_offset, file_path); in perf_session__queue_event()
1096 struct ip_callchain *callchain = sample->callchain; in callchain__lbr_callstack_printf()
1097 struct branch_stack *lbr_stack = sample->branch_stack; in callchain__lbr_callstack_printf()
1099 u64 kernel_callchain_nr = callchain->nr; in callchain__lbr_callstack_printf()
1103 if (callchain->ips[i] == PERF_CONTEXT_USER) in callchain__lbr_callstack_printf()
1107 if ((i != kernel_callchain_nr) && lbr_stack->nr) { in callchain__lbr_callstack_printf()
1119 * "A"->"B"->"C"->"D". in callchain__lbr_callstack_printf()
1121 * "C"->"D", "B"->"C", "A"->"B". in callchain__lbr_callstack_printf()
1125 total_nr = i + 1 + lbr_stack->nr + 1; in callchain__lbr_callstack_printf()
1132 i, callchain->ips[i]); in callchain__lbr_callstack_printf()
1136 for (i = 0; i < lbr_stack->nr; i++) in callchain__lbr_callstack_printf()
1146 struct ip_callchain *callchain = sample->callchain; in callchain__printf()
1151 printf("... FP chain: nr:%" PRIu64 "\n", callchain->nr); in callchain__printf()
1153 for (i = 0; i < callchain->nr; i++) in callchain__printf()
1155 i, callchain->ips[i]); in callchain__printf()
1164 printf("%s: nr:%" PRIu64 "\n", "... branch stack", sample->branch_stack->nr); in branch_stack__printf()
1168 * B()->C() in branch_stack__printf()
1169 * A()->B() in branch_stack__printf()
1175 printf("%s: nr:%" PRIu64 "\n", "... branch callstack", sample->branch_stack->nr+1); in branch_stack__printf()
1178 for (i = 0; i < sample->branch_stack->nr; i++) { in branch_stack__printf()
1182 printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x %s %s\n", in branch_stack__printf()
1183 i, e->from, e->to, in branch_stack__printf()
1184 (unsigned short)e->flags.cycles, in branch_stack__printf()
1185 e->flags.mispred ? "M" : " ", in branch_stack__printf()
1186 e->flags.predicted ? "P" : " ", in branch_stack__printf()
1187 e->flags.abort ? "A" : " ", in branch_stack__printf()
1188 e->flags.in_tx ? "T" : " ", in branch_stack__printf()
1189 (unsigned)e->flags.reserved, in branch_stack__printf()
1191 e->flags.spec ? branch_spec_desc(e->flags.spec) : ""); in branch_stack__printf()
1196 i, e->to, i+1, e->from); in branch_stack__printf()
1198 printf("..... %2"PRIu64": %016" PRIx64 "\n", i+1, e->from); in branch_stack__printf()
1211 printf(".... %-5s 0x%016" PRIx64 "\n", in regs_dump__printf()
1218 [PERF_SAMPLE_REGS_ABI_32] = "32-bit",
1219 [PERF_SAMPLE_REGS_ABI_64] = "64-bit",
1224 if (d->abi > PERF_SAMPLE_REGS_ABI_64) in regs_dump_abi()
1227 return regs_abi[d->abi]; in regs_dump_abi()
1232 u64 mask = regs->mask; in regs__printf()
1239 regs_dump__printf(mask, regs->regs, arch); in regs__printf()
1244 struct regs_dump *user_regs = &sample->user_regs; in regs_user__printf()
1246 if (user_regs->regs) in regs_user__printf()
1252 struct regs_dump *intr_regs = &sample->intr_regs; in regs_intr__printf()
1254 if (intr_regs->regs) in regs_intr__printf()
1261 dump->size, dump->offset); in stack_user__printf()
1264 static void evlist__print_tstamp(struct evlist *evlist, union perf_event *event, struct perf_sample… in evlist__print_tstamp() argument
1268 if (event->header.type != PERF_RECORD_SAMPLE && in evlist__print_tstamp()
1270 fputs("-1 -1 ", stdout); in evlist__print_tstamp()
1275 printf("%u ", sample->cpu); in evlist__print_tstamp()
1278 printf("%" PRIu64 " ", sample->time); in evlist__print_tstamp()
1287 sample->read.time_enabled); in sample_read__printf()
1291 sample->read.time_running); in sample_read__printf()
1294 struct sample_read_value *value = sample->read.group.values; in sample_read__printf()
1296 printf(".... group nr %" PRIu64 "\n", sample->read.group.nr); in sample_read__printf()
1298 sample_read_group__for_each(value, sample->read.group.nr, read_format) { in sample_read__printf()
1301 value->id, value->value); in sample_read__printf()
1303 printf(", lost %" PRIu64, value->lost); in sample_read__printf()
1308 sample->read.one.id, sample->read.one.value); in sample_read__printf()
1310 printf(", lost %" PRIu64, sample->read.one.lost); in sample_read__printf()
1315 static void dump_event(struct evlist *evlist, union perf_event *event, in dump_event() argument
1322 printf("\n%#" PRIx64 "@%s [%#x]: event: %d\n", in dump_event()
1323 file_offset, file_path, event->header.size, event->header.type); in dump_event()
1325 trace_event(event); in dump_event()
1326 if (event->header.type == PERF_RECORD_SAMPLE && evlist->trace_event_sample_raw) in dump_event()
1327 evlist->trace_event_sample_raw(evlist, event, sample); in dump_event()
1330 evlist__print_tstamp(evlist, event, sample); in dump_event()
1333 event->header.size, perf_event__name(event->header.type)); in dump_event()
1344 static void dump_sample(struct evsel *evsel, union perf_event *event, in dump_sample() argument
1354 event->header.misc, sample->pid, sample->tid, sample->ip, in dump_sample()
1355 sample->period, sample->addr); in dump_sample()
1357 sample_type = evsel->core.attr.sample_type; in dump_sample()
1372 stack_user__printf(&sample->user_stack); in dump_sample()
1375 printf("... weight: %" PRIu64 "", sample->weight); in dump_sample()
1377 printf(",0x%"PRIx16"", sample->ins_lat); in dump_sample()
1378 printf(",0x%"PRIx16"", sample->p_stage_cyc); in dump_sample()
1384 printf(" . data_src: 0x%"PRIx64"\n", sample->data_src); in dump_sample()
1387 printf(" .. phys_addr: 0x%"PRIx64"\n", sample->phys_addr); in dump_sample()
1390 printf(" .. data page size: %s\n", get_page_size_name(sample->data_page_size, str)); in dump_sample()
1393 printf(" .. code page size: %s\n", get_page_size_name(sample->code_page_size, str)); in dump_sample()
1396 printf("... transaction: %" PRIx64 "\n", sample->transaction); in dump_sample()
1399 sample_read__printf(sample, evsel->core.attr.read_format); in dump_sample()
1402 static void dump_read(struct evsel *evsel, union perf_event *event) in dump_read() argument
1404 struct perf_record_read *read_event = &event->read; in dump_read()
1410 printf(": %d %d %s %" PRI_lu64 "\n", event->read.pid, event->read.tid, in dump_read()
1411 evsel__name(evsel), event->read.value); in dump_read()
1416 read_format = evsel->core.attr.read_format; in dump_read()
1419 printf("... time enabled : %" PRI_lu64 "\n", read_event->time_enabled); in dump_read()
1422 printf("... time running : %" PRI_lu64 "\n", read_event->time_running); in dump_read()
1425 printf("... id : %" PRI_lu64 "\n", read_event->id); in dump_read()
1428 printf("... lost : %" PRI_lu64 "\n", read_event->lost); in dump_read()
1432 union perf_event *event, in machines__find_for_cpumode() argument
1436 ((sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL) || in machines__find_for_cpumode()
1437 (sample->cpumode == PERF_RECORD_MISC_GUEST_USER))) { in machines__find_for_cpumode()
1440 if (sample->machine_pid) in machines__find_for_cpumode()
1441 pid = sample->machine_pid; in machines__find_for_cpumode()
1442 else if (event->header.type == PERF_RECORD_MMAP in machines__find_for_cpumode()
1443 || event->header.type == PERF_RECORD_MMAP2) in machines__find_for_cpumode()
1444 pid = event->mmap.pid; in machines__find_for_cpumode()
1446 pid = sample->pid; in machines__find_for_cpumode()
1458 return &machines->host; in machines__find_for_cpumode()
1463 union perf_event *event, in deliver_sample_value() argument
1468 struct perf_sample_id *sid = evlist__id2sid(evlist, v->id); in deliver_sample_value()
1472 sample->id = v->id; in deliver_sample_value()
1473 sample->period = v->value - sid->period; in deliver_sample_value()
1474 sid->period = v->value; in deliver_sample_value()
1477 if (!sid || sid->evsel == NULL) { in deliver_sample_value()
1478 ++evlist->stats.nr_unknown_id; in deliver_sample_value()
1486 if (!sample->period) in deliver_sample_value()
1489 evsel = container_of(sid->evsel, struct evsel, core); in deliver_sample_value()
1490 return tool->sample(tool, event, sample, evsel, machine); in deliver_sample_value()
1495 union perf_event *event, in deliver_sample_group() argument
1500 int ret = -EINVAL; in deliver_sample_group()
1501 struct sample_read_value *v = sample->read.group.values; in deliver_sample_group()
1503 if (tool->dont_split_sample_group) in deliver_sample_group()
1504 return deliver_sample_value(evlist, tool, event, sample, v, machine); in deliver_sample_group()
1506 sample_read_group__for_each(v, sample->read.group.nr, read_format) { in deliver_sample_group()
1507 ret = deliver_sample_value(evlist, tool, event, sample, v, in deliver_sample_group()
1517 union perf_event *event, struct perf_sample *sample, in evlist__deliver_sample() argument
1521 u64 sample_type = evsel->core.attr.sample_type; in evlist__deliver_sample()
1522 u64 read_format = evsel->core.attr.read_format; in evlist__deliver_sample()
1526 return tool->sample(tool, event, sample, evsel, machine); in evlist__deliver_sample()
1530 return deliver_sample_group(evlist, tool, event, sample, in evlist__deliver_sample()
1533 return deliver_sample_value(evlist, tool, event, sample, in evlist__deliver_sample()
1534 &sample->read.one, machine); in evlist__deliver_sample()
1539 union perf_event *event, in machines__deliver_event() argument
1547 dump_event(evlist, event, file_offset, sample, file_path); in machines__deliver_event()
1549 evsel = evlist__id2evsel(evlist, sample->id); in machines__deliver_event()
1551 machine = machines__find_for_cpumode(machines, event, sample); in machines__deliver_event()
1553 switch (event->header.type) { in machines__deliver_event()
1556 ++evlist->stats.nr_unknown_id; in machines__deliver_event()
1560 ++evlist->stats.nr_unprocessable_samples; in machines__deliver_event()
1561 dump_sample(evsel, event, sample, perf_env__arch(NULL)); in machines__deliver_event()
1564 dump_sample(evsel, event, sample, perf_env__arch(machine->env)); in machines__deliver_event()
1565 return evlist__deliver_sample(evlist, tool, event, sample, evsel, machine); in machines__deliver_event()
1567 return tool->mmap(tool, event, sample, machine); in machines__deliver_event()
1569 if (event->header.misc & PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT) in machines__deliver_event()
1570 ++evlist->stats.nr_proc_map_timeout; in machines__deliver_event()
1571 return tool->mmap2(tool, event, sample, machine); in machines__deliver_event()
1573 return tool->comm(tool, event, sample, machine); in machines__deliver_event()
1575 return tool->namespaces(tool, event, sample, machine); in machines__deliver_event()
1577 return tool->cgroup(tool, event, sample, machine); in machines__deliver_event()
1579 return tool->fork(tool, event, sample, machine); in machines__deliver_event()
1581 return tool->exit(tool, event, sample, machine); in machines__deliver_event()
1583 if (tool->lost == perf_event__process_lost) in machines__deliver_event()
1584 evlist->stats.total_lost += event->lost.lost; in machines__deliver_event()
1585 return tool->lost(tool, event, sample, machine); in machines__deliver_event()
1587 if (tool->lost_samples == perf_event__process_lost_samples && in machines__deliver_event()
1588 !(event->header.misc & PERF_RECORD_MISC_LOST_SAMPLES_BPF)) in machines__deliver_event()
1589 evlist->stats.total_lost_samples += event->lost_samples.lost; in machines__deliver_event()
1590 return tool->lost_samples(tool, event, sample, machine); in machines__deliver_event()
1592 dump_read(evsel, event); in machines__deliver_event()
1593 return tool->read(tool, event, sample, evsel, machine); in machines__deliver_event()
1595 return tool->throttle(tool, event, sample, machine); in machines__deliver_event()
1597 return tool->unthrottle(tool, event, sample, machine); in machines__deliver_event()
1599 if (tool->aux == perf_event__process_aux) { in machines__deliver_event()
1600 if (event->aux.flags & PERF_AUX_FLAG_TRUNCATED) in machines__deliver_event()
1601 evlist->stats.total_aux_lost += 1; in machines__deliver_event()
1602 if (event->aux.flags & PERF_AUX_FLAG_PARTIAL) in machines__deliver_event()
1603 evlist->stats.total_aux_partial += 1; in machines__deliver_event()
1604 if (event->aux.flags & PERF_AUX_FLAG_COLLISION) in machines__deliver_event()
1605 evlist->stats.total_aux_collision += 1; in machines__deliver_event()
1607 return tool->aux(tool, event, sample, machine); in machines__deliver_event()
1609 return tool->itrace_start(tool, event, sample, machine); in machines__deliver_event()
1612 return tool->context_switch(tool, event, sample, machine); in machines__deliver_event()
1614 return tool->ksymbol(tool, event, sample, machine); in machines__deliver_event()
1616 return tool->bpf(tool, event, sample, machine); in machines__deliver_event()
1618 return tool->text_poke(tool, event, sample, machine); in machines__deliver_event()
1620 return tool->aux_output_hw_id(tool, event, sample, machine); in machines__deliver_event()
1622 ++evlist->stats.nr_unknown_events; in machines__deliver_event()
1623 return -1; in machines__deliver_event()
1628 union perf_event *event, in perf_session__deliver_event() argument
1634 int ret = evlist__parse_sample(session->evlist, event, &sample); in perf_session__deliver_event()
1641 ret = auxtrace__process_event(session, event, &sample, tool); in perf_session__deliver_event()
1647 ret = machines__deliver_event(&session->machines, session->evlist, in perf_session__deliver_event()
1648 event, &sample, tool, file_offset, file_path); in perf_session__deliver_event()
1657 union perf_event *event, in perf_session__process_user_event() argument
1661 struct ordered_events *oe = &session->ordered_events; in perf_session__process_user_event()
1662 struct perf_tool *tool = session->tool; in perf_session__process_user_event()
1664 int fd = perf_data__fd(session->data); in perf_session__process_user_event()
1667 if (event->header.type != PERF_RECORD_COMPRESSED || in perf_session__process_user_event()
1668 tool->compressed == perf_session__process_compressed_event_stub) in perf_session__process_user_event()
1669 dump_event(session->evlist, event, file_offset, &sample, file_path); in perf_session__process_user_event()
1672 switch (event->header.type) { in perf_session__process_user_event()
1674 err = tool->attr(tool, event, &session->evlist); in perf_session__process_user_event()
1681 return tool->event_update(tool, event, &session->evlist); in perf_session__process_user_event()
1694 if (!perf_data__is_pipe(session->data)) in perf_session__process_user_event()
1696 return tool->tracing_data(session, event); in perf_session__process_user_event()
1698 return tool->build_id(session, event); in perf_session__process_user_event()
1700 return tool->finished_round(tool, event, oe); in perf_session__process_user_event()
1702 return tool->id_index(session, event); in perf_session__process_user_event()
1704 return tool->auxtrace_info(session, event); in perf_session__process_user_event()
1711 if (!perf_data__is_pipe(session->data)) in perf_session__process_user_event()
1712 lseek(fd, file_offset + event->header.size, SEEK_SET); in perf_session__process_user_event()
1713 return tool->auxtrace(session, event); in perf_session__process_user_event()
1715 perf_session__auxtrace_error_inc(session, event); in perf_session__process_user_event()
1716 return tool->auxtrace_error(session, event); in perf_session__process_user_event()
1718 return tool->thread_map(session, event); in perf_session__process_user_event()
1720 return tool->cpu_map(session, event); in perf_session__process_user_event()
1722 return tool->stat_config(session, event); in perf_session__process_user_event()
1724 return tool->stat(session, event); in perf_session__process_user_event()
1726 return tool->stat_round(session, event); in perf_session__process_user_event()
1728 session->time_conv = event->time_conv; in perf_session__process_user_event()
1729 return tool->time_conv(session, event); in perf_session__process_user_event()
1731 return tool->feature(session, event); in perf_session__process_user_event()
1733 err = tool->compressed(session, event, file_offset, file_path); in perf_session__process_user_event()
1735 dump_event(session->evlist, event, file_offset, &sample, file_path); in perf_session__process_user_event()
1738 return tool->finished_init(session, event); in perf_session__process_user_event()
1740 return -EINVAL; in perf_session__process_user_event()
1745 union perf_event *event, in perf_session__deliver_synth_event() argument
1748 struct evlist *evlist = session->evlist; in perf_session__deliver_synth_event()
1749 struct perf_tool *tool = session->tool; in perf_session__deliver_synth_event()
1751 events_stats__inc(&evlist->stats, event->header.type); in perf_session__deliver_synth_event()
1753 if (event->header.type >= PERF_RECORD_USER_TYPE_START) in perf_session__deliver_synth_event()
1754 return perf_session__process_user_event(session, event, 0, NULL); in perf_session__deliver_synth_event()
1756 return machines__deliver_event(&session->machines, evlist, event, sample, tool, 0, NULL); in perf_session__deliver_synth_event()
1759 static void event_swap(union perf_event *event, bool sample_id_all) in event_swap() argument
1763 swap = perf_event__swap_ops[event->header.type]; in event_swap()
1765 swap(event, sample_id_all); in event_swap()
1773 union perf_event *event; in perf_session__peek_event() local
1777 if (session->one_mmap && !session->header.needs_swap) { in perf_session__peek_event()
1778 event = file_offset - session->one_mmap_offset + in perf_session__peek_event()
1779 session->one_mmap_addr; in perf_session__peek_event()
1783 if (perf_data__is_pipe(session->data)) in perf_session__peek_event()
1784 return -1; in perf_session__peek_event()
1786 fd = perf_data__fd(session->data); in perf_session__peek_event()
1790 return -1; in perf_session__peek_event()
1792 if (lseek(fd, file_offset, SEEK_SET) == (off_t)-1 || in perf_session__peek_event()
1794 return -1; in perf_session__peek_event()
1796 event = (union perf_event *)buf; in perf_session__peek_event()
1798 if (session->header.needs_swap) in perf_session__peek_event()
1799 perf_event_header__bswap(&event->header); in perf_session__peek_event()
1801 if (event->header.size < hdr_sz || event->header.size > buf_sz) in perf_session__peek_event()
1802 return -1; in perf_session__peek_event()
1805 rest = event->header.size - hdr_sz; in perf_session__peek_event()
1808 return -1; in perf_session__peek_event()
1810 if (session->header.needs_swap) in perf_session__peek_event()
1811 event_swap(event, evlist__sample_id_all(session->evlist)); in perf_session__peek_event()
1815 if (sample && event->header.type < PERF_RECORD_USER_TYPE_START && in perf_session__peek_event()
1816 evlist__parse_sample(session->evlist, event, sample)) in perf_session__peek_event()
1817 return -1; in perf_session__peek_event()
1819 *event_ptr = event; in perf_session__peek_event()
1829 union perf_event *event; in perf_session__peek_events() local
1834 PERF_SAMPLE_MAX_SIZE, &event, in perf_session__peek_events()
1839 err = cb(session, event, offset, data); in perf_session__peek_events()
1843 offset += event->header.size; in perf_session__peek_events()
1844 if (event->header.type == PERF_RECORD_AUXTRACE) in perf_session__peek_events()
1845 offset += event->auxtrace.size; in perf_session__peek_events()
1853 union perf_event *event, u64 file_offset, in perf_session__process_event() argument
1856 struct evlist *evlist = session->evlist; in perf_session__process_event()
1857 struct perf_tool *tool = session->tool; in perf_session__process_event()
1860 if (session->header.needs_swap) in perf_session__process_event()
1861 event_swap(event, evlist__sample_id_all(evlist)); in perf_session__process_event()
1863 if (event->header.type >= PERF_RECORD_HEADER_MAX) in perf_session__process_event()
1864 return -EINVAL; in perf_session__process_event()
1866 events_stats__inc(&evlist->stats, event->header.type); in perf_session__process_event()
1868 if (event->header.type >= PERF_RECORD_USER_TYPE_START) in perf_session__process_event()
1869 return perf_session__process_user_event(session, event, file_offset, file_path); in perf_session__process_event()
1871 if (tool->ordered_events) { in perf_session__process_event()
1872 u64 timestamp = -1ULL; in perf_session__process_event()
1874 ret = evlist__parse_sample_timestamp(evlist, event, &timestamp); in perf_session__process_event()
1875 if (ret && ret != -1) in perf_session__process_event()
1878 ret = perf_session__queue_event(session, event, timestamp, file_offset, file_path); in perf_session__process_event()
1879 if (ret != -ETIME) in perf_session__process_event()
1883 return perf_session__deliver_event(session, event, tool, file_offset, file_path); in perf_session__process_event()
1888 hdr->type = bswap_32(hdr->type); in perf_event_header__bswap()
1889 hdr->misc = bswap_16(hdr->misc); in perf_event_header__bswap()
1890 hdr->size = bswap_16(hdr->size); in perf_event_header__bswap()
1895 return machine__findnew_thread(&session->machines.host, -1, pid); in perf_session__findnew()
1900 struct thread *thread = machine__idle_thread(&session->machines.host); in perf_session__register_idle_thread()
1904 return thread ? 0 : -1; in perf_session__register_idle_thread()
1910 const struct ordered_events *oe = &session->ordered_events; in perf_session__warn_order()
1914 evlist__for_each_entry(session->evlist, evsel) { in perf_session__warn_order()
1915 if (evsel->core.attr.write_backward) in perf_session__warn_order()
1921 if (oe->nr_unordered_events != 0) in perf_session__warn_order()
1922 ui__warning("%u out of order events recorded.\n", oe->nr_unordered_events); in perf_session__warn_order()
1927 const struct events_stats *stats = &session->evlist->stats; in perf_session__warn_about_errors()
1929 if (session->tool->lost == perf_event__process_lost && in perf_session__warn_about_errors()
1930 stats->nr_events[PERF_RECORD_LOST] != 0) { in perf_session__warn_about_errors()
1933 stats->nr_events[0], in perf_session__warn_about_errors()
1934 stats->nr_events[PERF_RECORD_LOST]); in perf_session__warn_about_errors()
1937 if (session->tool->lost_samples == perf_event__process_lost_samples) { in perf_session__warn_about_errors()
1940 drop_rate = (double)stats->total_lost_samples / in perf_session__warn_about_errors()
1941 (double) (stats->nr_events[PERF_RECORD_SAMPLE] + stats->total_lost_samples); in perf_session__warn_about_errors()
1944 stats->nr_events[PERF_RECORD_SAMPLE] + stats->total_lost_samples, in perf_session__warn_about_errors()
1949 if (session->tool->aux == perf_event__process_aux && in perf_session__warn_about_errors()
1950 stats->total_aux_lost != 0) { in perf_session__warn_about_errors()
1952 stats->total_aux_lost, in perf_session__warn_about_errors()
1953 stats->nr_events[PERF_RECORD_AUX]); in perf_session__warn_about_errors()
1956 if (session->tool->aux == perf_event__process_aux && in perf_session__warn_about_errors()
1957 stats->total_aux_partial != 0) { in perf_session__warn_about_errors()
1965 stats->total_aux_partial, in perf_session__warn_about_errors()
1966 stats->nr_events[PERF_RECORD_AUX], in perf_session__warn_about_errors()
1973 if (session->tool->aux == perf_event__process_aux && in perf_session__warn_about_errors()
1974 stats->total_aux_collision != 0) { in perf_session__warn_about_errors()
1976 stats->total_aux_collision, in perf_session__warn_about_errors()
1977 stats->nr_events[PERF_RECORD_AUX]); in perf_session__warn_about_errors()
1980 if (stats->nr_unknown_events != 0) { in perf_session__warn_about_errors()
1985 "reporting to linux-kernel@vger.kernel.org.\n\n", in perf_session__warn_about_errors()
1986 stats->nr_unknown_events); in perf_session__warn_about_errors()
1989 if (stats->nr_unknown_id != 0) { in perf_session__warn_about_errors()
1991 stats->nr_unknown_id); in perf_session__warn_about_errors()
1994 if (stats->nr_invalid_chains != 0) { in perf_session__warn_about_errors()
1997 "Consider reporting to linux-kernel@vger.kernel.org.\n\n", in perf_session__warn_about_errors()
1998 stats->nr_invalid_chains, in perf_session__warn_about_errors()
1999 stats->nr_events[PERF_RECORD_SAMPLE]); in perf_session__warn_about_errors()
2002 if (stats->nr_unprocessable_samples != 0) { in perf_session__warn_about_errors()
2005 stats->nr_unprocessable_samples); in perf_session__warn_about_errors()
2012 if (stats->nr_proc_map_timeout != 0) { in perf_session__warn_about_errors()
2013 ui__warning("%d map information files for pre-existing threads were\n" in perf_session__warn_about_errors()
2016 "threads by running with -v and redirecting the output\n" in perf_session__warn_about_errors()
2019 "Increase it by --proc-map-timeout\n", in perf_session__warn_about_errors()
2020 stats->nr_proc_map_timeout); in perf_session__warn_about_errors()
2032 return machines__for_each_thread(&session->machines, in perf_session__flush_thread_stacks()
2043 struct ordered_events *oe = &session->ordered_events; in __perf_session__process_pipe_events()
2044 struct perf_tool *tool = session->tool; in __perf_session__process_pipe_events()
2045 union perf_event *event; in __perf_session__process_pipe_events() local
2060 return -errno; in __perf_session__process_pipe_events()
2063 event = buf; in __perf_session__process_pipe_events()
2064 err = perf_data__read(session->data, event, in __perf_session__process_pipe_events()
2070 pr_err("failed to read event header\n"); in __perf_session__process_pipe_events()
2074 if (session->header.needs_swap) in __perf_session__process_pipe_events()
2075 perf_event_header__bswap(&event->header); in __perf_session__process_pipe_events()
2077 size = event->header.size; in __perf_session__process_pipe_events()
2079 pr_err("bad event header size\n"); in __perf_session__process_pipe_events()
2086 pr_err("failed to allocate memory to read event\n"); in __perf_session__process_pipe_events()
2091 event = buf; in __perf_session__process_pipe_events()
2093 p = event; in __perf_session__process_pipe_events()
2096 if (size - sizeof(struct perf_event_header)) { in __perf_session__process_pipe_events()
2097 err = perf_data__read(session->data, p, in __perf_session__process_pipe_events()
2098 size - sizeof(struct perf_event_header)); in __perf_session__process_pipe_events()
2101 pr_err("unexpected end of event stream\n"); in __perf_session__process_pipe_events()
2105 pr_err("failed to read event data\n"); in __perf_session__process_pipe_events()
2110 if ((skip = perf_session__process_event(session, event, head, "pipe")) < 0) { in __perf_session__process_pipe_events()
2112 head, event->header.size, event->header.type); in __perf_session__process_pipe_events()
2113 err = -EINVAL; in __perf_session__process_pipe_events()
2139 if (!tool->no_warn) in __perf_session__process_pipe_events()
2141 ordered_events__free(&session->ordered_events); in __perf_session__process_pipe_events()
2150 union perf_event *event; in prefetch_event() local
2155 * the size of the event in the headers. in prefetch_event()
2157 if (head + sizeof(event->header) > mmap_size) in prefetch_event()
2160 event = (union perf_event *)(buf + head); in prefetch_event()
2162 perf_event_header__bswap(&event->header); in prefetch_event()
2164 event_size = event->header.size; in prefetch_event()
2166 return event; in prefetch_event()
2168 /* We're not fetching the event so swap back again */ in prefetch_event()
2170 perf_event_header__bswap(&event->header); in prefetch_event()
2172 /* Check if the event fits into the next mmapped buf. */ in prefetch_event()
2173 if (event_size <= mmap_size - head % page_size) { in prefetch_event()
2178 /* Invalid input. Event size should never exceed mmap_size. */ in prefetch_event()
2179 pr_debug("%s: head=%#" PRIx64 " event->header.size=%#x, mmap_size=%#zx:" in prefetch_event()
2188 return prefetch_event(buf, head, mmap_size, needs_swap, ERR_PTR(-EINVAL)); in fetch_mmaped_event()
2201 struct decomp *decomp = session->active_decomp->decomp_last; in __perf_session__process_decomp_events()
2206 while (decomp->head < decomp->size && !session_done()) { in __perf_session__process_decomp_events()
2207 union perf_event *event = fetch_decomp_event(decomp->head, decomp->size, decomp->data, in __perf_session__process_decomp_events() local
2208 session->header.needs_swap); in __perf_session__process_decomp_events()
2210 if (!event) in __perf_session__process_decomp_events()
2213 size = event->header.size; in __perf_session__process_decomp_events()
2216 (skip = perf_session__process_event(session, event, decomp->file_pos, in __perf_session__process_decomp_events()
2217 decomp->file_path)) < 0) { in __perf_session__process_decomp_events()
2219 decomp->file_pos + decomp->head, event->header.size, event->header.type); in __perf_session__process_decomp_events()
2220 return -EINVAL; in __perf_session__process_decomp_events()
2226 decomp->head += size; in __perf_session__process_decomp_events()
2247 union perf_event *event,
2274 u64 data_size = rd->data_size; in reader__init()
2275 char **mmaps = rd->mmaps; in reader__init()
2277 rd->head = rd->data_offset; in reader__init()
2278 data_size += rd->data_offset; in reader__init()
2280 rd->mmap_size = MMAP_SIZE; in reader__init()
2281 if (rd->mmap_size > data_size) { in reader__init()
2282 rd->mmap_size = data_size; in reader__init()
2287 memset(mmaps, 0, sizeof(rd->mmaps)); in reader__init()
2289 if (zstd_init(&rd->zstd_data, 0)) in reader__init()
2290 return -1; in reader__init()
2291 rd->decomp_data.zstd_decomp = &rd->zstd_data; in reader__init()
2299 perf_decomp__release_events(rd->decomp_data.decomp); in reader__release_decomp()
2300 zstd_fini(&rd->zstd_data); in reader__release_decomp()
2307 char *buf, **mmaps = rd->mmaps; in reader__mmap()
2313 if (rd->in_place_update) { in reader__mmap()
2315 } else if (session->header.needs_swap) { in reader__mmap()
2320 if (mmaps[rd->mmap_idx]) { in reader__mmap()
2321 munmap(mmaps[rd->mmap_idx], rd->mmap_size); in reader__mmap()
2322 mmaps[rd->mmap_idx] = NULL; in reader__mmap()
2325 page_offset = page_size * (rd->head / page_size); in reader__mmap()
2326 rd->file_offset += page_offset; in reader__mmap()
2327 rd->head -= page_offset; in reader__mmap()
2329 buf = mmap(NULL, rd->mmap_size, mmap_prot, mmap_flags, rd->fd, in reader__mmap()
2330 rd->file_offset); in reader__mmap()
2333 return -errno; in reader__mmap()
2335 mmaps[rd->mmap_idx] = rd->mmap_cur = buf; in reader__mmap()
2336 rd->mmap_idx = (rd->mmap_idx + 1) & (ARRAY_SIZE(rd->mmaps) - 1); in reader__mmap()
2337 rd->file_pos = rd->file_offset + rd->head; in reader__mmap()
2338 if (session->one_mmap) { in reader__mmap()
2339 session->one_mmap_addr = buf; in reader__mmap()
2340 session->one_mmap_offset = rd->file_offset; in reader__mmap()
2357 union perf_event *event; in reader__read_event() local
2360 event = fetch_mmaped_event(rd->head, rd->mmap_size, rd->mmap_cur, in reader__read_event()
2361 session->header.needs_swap); in reader__read_event()
2362 if (IS_ERR(event)) in reader__read_event()
2363 return PTR_ERR(event); in reader__read_event()
2365 if (!event) in reader__read_event()
2368 size = event->header.size; in reader__read_event()
2370 skip = -EINVAL; in reader__read_event()
2373 (skip = rd->process(session, event, rd->file_pos, rd->path)) < 0) { in reader__read_event()
2375 rd->file_offset + rd->head, event->header.size, in reader__read_event()
2376 event->header.type, strerror(-skip)); in reader__read_event()
2384 rd->size += size; in reader__read_event()
2385 rd->head += size; in reader__read_event()
2386 rd->file_pos += size; in reader__read_event()
2401 return (rd->file_pos >= rd->data_size + rd->data_offset); in reader__eof()
2410 err = reader__init(rd, &session->one_mmap); in reader__process_events()
2414 session->active_decomp = &rd->decomp_data; in reader__process_events()
2435 session->active_decomp = &session->decomp_data; in reader__process_events()
2440 union perf_event *event, in process_simple() argument
2444 return perf_session__process_event(session, event, file_offset, file_path); in process_simple()
2450 .fd = perf_data__fd(session->data), in __perf_session__process_events()
2451 .path = session->data->file.path, in __perf_session__process_events()
2452 .data_size = session->header.data_size, in __perf_session__process_events()
2453 .data_offset = session->header.data_offset, in __perf_session__process_events()
2455 .in_place_update = session->data->in_place_update, in __perf_session__process_events()
2457 struct ordered_events *oe = &session->ordered_events; in __perf_session__process_events()
2458 struct perf_tool *tool = session->tool; in __perf_session__process_events()
2465 return -1; in __perf_session__process_events()
2482 if (!tool->no_warn) in __perf_session__process_events()
2488 ordered_events__reinit(&session->ordered_events); in __perf_session__process_events()
2491 session->one_mmap = false; in __perf_session__process_events()
2505 * data file holds per-cpu data, already sorted by kernel.
2509 struct perf_data *data = session->data; in __perf_session__process_dir_events()
2510 struct perf_tool *tool = session->tool; in __perf_session__process_dir_events()
2513 u64 total_size = perf_data__size(session->data); in __perf_session__process_dir_events()
2521 for (i = 0; i < data->dir.nr; i++) { in __perf_session__process_dir_events()
2522 if (data->dir.files[i].size) in __perf_session__process_dir_events()
2528 return -ENOMEM; in __perf_session__process_dir_events()
2531 .fd = perf_data__fd(session->data), in __perf_session__process_dir_events()
2532 .path = session->data->file.path, in __perf_session__process_dir_events()
2533 .data_size = session->header.data_size, in __perf_session__process_dir_events()
2534 .data_offset = session->header.data_offset, in __perf_session__process_dir_events()
2536 .in_place_update = session->data->in_place_update, in __perf_session__process_dir_events()
2546 for (i = 0; i < data->dir.nr; i++) { in __perf_session__process_dir_events()
2547 if (!data->dir.files[i].size) in __perf_session__process_dir_events()
2550 .fd = data->dir.files[i].fd, in __perf_session__process_dir_events()
2551 .path = data->dir.files[i].path, in __perf_session__process_dir_events()
2552 .data_size = data->dir.files[i].size, in __perf_session__process_dir_events()
2555 .in_place_update = session->data->in_place_update, in __perf_session__process_dir_events()
2577 readers--; in __perf_session__process_dir_events()
2581 session->active_decomp = &rd[i].decomp_data; in __perf_session__process_dir_events()
2597 ret = ordered_events__flush(&session->ordered_events, OE_FLUSH__FINAL); in __perf_session__process_dir_events()
2605 if (!tool->no_warn) in __perf_session__process_dir_events()
2612 ordered_events__reinit(&session->ordered_events); in __perf_session__process_dir_events()
2614 session->one_mmap = false; in __perf_session__process_dir_events()
2616 session->active_decomp = &session->decomp_data; in __perf_session__process_dir_events()
2627 return -ENOMEM; in perf_session__process_events()
2629 if (perf_data__is_pipe(session->data)) in perf_session__process_events()
2632 if (perf_data__is_dir(session->data) && session->data->dir.nr) in perf_session__process_events()
2642 evlist__for_each_entry(session->evlist, evsel) { in perf_session__has_traces()
2643 if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT) in perf_session__has_traces()
2659 return -ENOMEM; in map__set_kallsyms_ref_reloc_sym()
2661 ref->name = strdup(symbol_name); in map__set_kallsyms_ref_reloc_sym()
2662 if (ref->name == NULL) { in map__set_kallsyms_ref_reloc_sym()
2664 return -ENOMEM; in map__set_kallsyms_ref_reloc_sym()
2667 bracket = strchr(ref->name, ']'); in map__set_kallsyms_ref_reloc_sym()
2671 ref->addr = addr; in map__set_kallsyms_ref_reloc_sym()
2675 kmap->ref_reloc_sym = ref; in map__set_kallsyms_ref_reloc_sym()
2682 return machines__fprintf_dsos(&session->machines, fp); in perf_session__fprintf_dsos()
2688 return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm); in perf_session__fprintf_dsos_buildid()
2697 if (perf_header__has_feat(&session->header, HEADER_AUXTRACE)) in perf_session__fprintf_nr_events()
2702 ret += events_stats__fprintf(&session->evlist->stats, fp, skip_empty); in perf_session__fprintf_nr_events()
2712 return machine__fprintf(&session->machines.host, fp); in perf_session__fprintf()
2720 evlist__for_each_entry(session->evlist, pos) { in perf_session__find_first_evtype()
2721 if (pos->core.attr.type == type) in perf_session__find_first_evtype()
2730 int i, err = -1; in perf_session__cpu_bitmap()
2732 int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS); in perf_session__cpu_bitmap()
2741 if (!(evsel->core.attr.sample_type & PERF_SAMPLE_CPU)) { in perf_session__cpu_bitmap()
2743 "Remove -C option to proceed.\n"); in perf_session__cpu_bitmap()
2744 return -1; in perf_session__cpu_bitmap()
2751 return -1; in perf_session__cpu_bitmap()
2786 struct machine *machine = machines__findnew(&session->machines, machine_pid); in perf_session__register_guest()
2790 return -ENOMEM; in perf_session__register_guest()
2792 machine->single_address_space = session->machines.host.single_address_space; in perf_session__register_guest()
2796 return -ENOMEM; in perf_session__register_guest()
2799 machine->kallsyms_filename = perf_data__guest_kallsyms_name(session->data, machine_pid); in perf_session__register_guest()
2807 struct machine *machine = &session->machines.host; in perf_session__set_guest_cpu()
2811 return -ENOMEM; in perf_session__set_guest_cpu()
2819 union perf_event *event) in perf_event__process_id_index() argument
2821 struct evlist *evlist = session->evlist; in perf_event__process_id_index()
2822 struct perf_record_id_index *ie = &event->id_index; in perf_event__process_id_index()
2823 size_t sz = ie->header.size - sizeof(*ie); in perf_event__process_id_index()
2832 nr = ie->nr; in perf_event__process_id_index()
2835 return -EINVAL; in perf_event__process_id_index()
2842 return -EINVAL; in perf_event__process_id_index()
2853 struct id_index_entry *e = &ie->entries[i]; in perf_event__process_id_index()
2858 fprintf(stdout, " ... id: %"PRI_lu64, e->id); in perf_event__process_id_index()
2859 fprintf(stdout, " idx: %"PRI_lu64, e->idx); in perf_event__process_id_index()
2860 fprintf(stdout, " cpu: %"PRI_ld64, e->cpu); in perf_event__process_id_index()
2861 fprintf(stdout, " tid: %"PRI_ld64, e->tid); in perf_event__process_id_index()
2863 fprintf(stdout, " machine_pid: %"PRI_ld64, e2->machine_pid); in perf_event__process_id_index()
2864 fprintf(stdout, " vcpu: %"PRI_lu64"\n", e2->vcpu); in perf_event__process_id_index()
2870 sid = evlist__id2sid(evlist, e->id); in perf_event__process_id_index()
2872 return -ENOENT; in perf_event__process_id_index()
2874 sid->idx = e->idx; in perf_event__process_id_index()
2875 sid->cpu.cpu = e->cpu; in perf_event__process_id_index()
2876 sid->tid = e->tid; in perf_event__process_id_index()
2881 sid->machine_pid = e2->machine_pid; in perf_event__process_id_index()
2882 sid->vcpu.cpu = e2->vcpu; in perf_event__process_id_index()
2884 if (!sid->machine_pid) in perf_event__process_id_index()
2887 if (sid->machine_pid != last_pid) { in perf_event__process_id_index()
2888 ret = perf_session__register_guest(session, sid->machine_pid); in perf_event__process_id_index()
2891 last_pid = sid->machine_pid; in perf_event__process_id_index()
2895 ret = perf_session__set_guest_cpu(session, sid->machine_pid, e->tid, e2->vcpu); in perf_event__process_id_index()