Lines Matching refs:pt

161 	struct intel_pt *pt;  member
205 static void intel_pt_dump(struct intel_pt *pt __maybe_unused, in intel_pt_dump()
245 static void intel_pt_dump_event(struct intel_pt *pt, unsigned char *buf, in intel_pt_dump_event() argument
249 intel_pt_dump(pt, buf, len); in intel_pt_dump_event()
265 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_dump_sample() local
269 intel_pt_dump(pt, sample->aux_sample.data, sample->aux_sample.size); in intel_pt_dump_sample()
272 static bool intel_pt_log_events(struct intel_pt *pt, u64 tm) in intel_pt_log_events() argument
274 struct perf_time_interval *range = pt->synth_opts.ptime_range; in intel_pt_log_events()
275 int n = pt->synth_opts.range_num; in intel_pt_log_events()
277 if (pt->synth_opts.log_plus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS) in intel_pt_log_events()
280 if (pt->synth_opts.log_minus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS) in intel_pt_log_events()
327 struct intel_pt *pt = ptq->pt; in intel_pt_findnew_vmcs_info() local
329 if (!vmcs && !pt->dflt_tsc_offset) in intel_pt_findnew_vmcs_info()
332 return intel_pt_findnew_vmcs(&pt->vmcs_info, vmcs, pt->dflt_tsc_offset); in intel_pt_findnew_vmcs_info()
335 static void intel_pt_free_vmcs_info(struct intel_pt *pt) in intel_pt_free_vmcs_info() argument
340 n = rb_first(&pt->vmcs_info); in intel_pt_free_vmcs_info()
344 rb_erase(&v->rb_node, &pt->vmcs_info); in intel_pt_free_vmcs_info()
349 static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *a, in intel_pt_do_fix_overlap() argument
356 pt->have_tsc, &consecutive, in intel_pt_do_fix_overlap()
357 pt->synth_opts.vm_time_correlation); in intel_pt_do_fix_overlap()
365 if (pt->synth_opts.vm_time_correlation) in intel_pt_do_fix_overlap()
382 int fd = perf_data__fd(ptq->pt->session->data); in intel_pt_get_buffer()
389 might_overlap = ptq->pt->snapshot_mode || ptq->pt->sampling_mode; in intel_pt_get_buffer()
391 intel_pt_do_fix_overlap(ptq->pt, old_buffer, buffer)) in intel_pt_get_buffer()
433 queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; in intel_pt_lookahead()
483 queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; in intel_pt_get_trace()
653 return ip >= ptq->pt->kernel_start ? in intel_pt_nr_cpumode()
668 struct machines *machines = &ptq->pt->session->machines; in intel_pt_get_guest()
698 struct machine *machine = ptq->pt->machine; in intel_pt_walk_next_insn()
729 thread = ptq->pt->unknown_thread; in intel_pt_walk_next_insn()
834 static bool intel_pt_match_pgd_ip(struct intel_pt *pt, uint64_t ip, in intel_pt_match_pgd_ip() argument
842 list_for_each_entry(filt, &pt->filts.head, list) { in intel_pt_match_pgd_ip()
882 return intel_pt_match_pgd_ip(ptq->pt, ip, ip, NULL); in __intel_pt_pgd_ip()
885 } else if (ip >= ptq->pt->kernel_start) { in __intel_pt_pgd_ip()
886 return intel_pt_match_pgd_ip(ptq->pt, ip, ip, NULL); in __intel_pt_pgd_ip()
900 return intel_pt_match_pgd_ip(ptq->pt, ip, offset, in __intel_pt_pgd_ip()
909 static bool intel_pt_get_config(struct intel_pt *pt, in intel_pt_get_config() argument
912 if (attr->type == pt->pmu_type) { in intel_pt_get_config()
921 static bool intel_pt_exclude_kernel(struct intel_pt *pt) in intel_pt_exclude_kernel() argument
925 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_exclude_kernel()
926 if (intel_pt_get_config(pt, &evsel->core.attr, NULL) && in intel_pt_exclude_kernel()
933 static bool intel_pt_return_compression(struct intel_pt *pt) in intel_pt_return_compression() argument
938 if (!pt->noretcomp_bit) in intel_pt_return_compression()
941 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_return_compression()
942 if (intel_pt_get_config(pt, &evsel->core.attr, &config) && in intel_pt_return_compression()
943 (config & pt->noretcomp_bit)) in intel_pt_return_compression()
949 static bool intel_pt_branch_enable(struct intel_pt *pt) in intel_pt_branch_enable() argument
954 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_branch_enable()
955 if (intel_pt_get_config(pt, &evsel->core.attr, &config) && in intel_pt_branch_enable()
962 static unsigned int intel_pt_mtc_period(struct intel_pt *pt) in intel_pt_mtc_period() argument
968 if (!pt->mtc_freq_bits) in intel_pt_mtc_period()
971 for (shift = 0, config = pt->mtc_freq_bits; !(config & 1); shift++) in intel_pt_mtc_period()
974 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_mtc_period()
975 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) in intel_pt_mtc_period()
976 return (config & pt->mtc_freq_bits) >> shift; in intel_pt_mtc_period()
981 static bool intel_pt_timeless_decoding(struct intel_pt *pt) in intel_pt_timeless_decoding() argument
987 if (!pt->tsc_bit || !pt->cap_user_time_zero || pt->synth_opts.timeless_decoding) in intel_pt_timeless_decoding()
990 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_timeless_decoding()
993 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) { in intel_pt_timeless_decoding()
994 if (config & pt->tsc_bit) in intel_pt_timeless_decoding()
1003 static bool intel_pt_tracing_kernel(struct intel_pt *pt) in intel_pt_tracing_kernel() argument
1007 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_tracing_kernel()
1008 if (intel_pt_get_config(pt, &evsel->core.attr, NULL) && in intel_pt_tracing_kernel()
1015 static bool intel_pt_have_tsc(struct intel_pt *pt) in intel_pt_have_tsc() argument
1021 if (!pt->tsc_bit) in intel_pt_have_tsc()
1024 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_have_tsc()
1025 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) { in intel_pt_have_tsc()
1026 if (config & pt->tsc_bit) in intel_pt_have_tsc()
1035 static bool intel_pt_have_mtc(struct intel_pt *pt) in intel_pt_have_mtc() argument
1040 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_have_mtc()
1041 if (intel_pt_get_config(pt, &evsel->core.attr, &config) && in intel_pt_have_mtc()
1042 (config & pt->mtc_bit)) in intel_pt_have_mtc()
1048 static bool intel_pt_sampling_mode(struct intel_pt *pt) in intel_pt_sampling_mode() argument
1052 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_sampling_mode()
1060 static u64 intel_pt_ctl(struct intel_pt *pt) in intel_pt_ctl() argument
1065 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_ctl()
1066 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) in intel_pt_ctl()
1072 static u64 intel_pt_ns_to_ticks(const struct intel_pt *pt, u64 ns) in intel_pt_ns_to_ticks() argument
1076 quot = ns / pt->tc.time_mult; in intel_pt_ns_to_ticks()
1077 rem = ns % pt->tc.time_mult; in intel_pt_ns_to_ticks()
1078 return (quot << pt->tc.time_shift) + (rem << pt->tc.time_shift) / in intel_pt_ns_to_ticks()
1079 pt->tc.time_mult; in intel_pt_ns_to_ticks()
1082 static struct ip_callchain *intel_pt_alloc_chain(struct intel_pt *pt) in intel_pt_alloc_chain() argument
1087 sz += (pt->synth_opts.callchain_sz + 1) * sizeof(u64); in intel_pt_alloc_chain()
1091 static int intel_pt_callchain_init(struct intel_pt *pt) in intel_pt_callchain_init() argument
1095 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_callchain_init()
1100 pt->chain = intel_pt_alloc_chain(pt); in intel_pt_callchain_init()
1101 if (!pt->chain) in intel_pt_callchain_init()
1107 static void intel_pt_add_callchain(struct intel_pt *pt, in intel_pt_add_callchain() argument
1110 struct thread *thread = machine__findnew_thread(pt->machine, in intel_pt_add_callchain()
1114 thread_stack__sample_late(thread, sample->cpu, pt->chain, in intel_pt_add_callchain()
1115 pt->synth_opts.callchain_sz + 1, sample->ip, in intel_pt_add_callchain()
1116 pt->kernel_start); in intel_pt_add_callchain()
1118 sample->callchain = pt->chain; in intel_pt_add_callchain()
1129 static int intel_pt_br_stack_init(struct intel_pt *pt) in intel_pt_br_stack_init() argument
1133 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_br_stack_init()
1138 pt->br_stack = intel_pt_alloc_br_stack(pt->br_stack_sz); in intel_pt_br_stack_init()
1139 if (!pt->br_stack) in intel_pt_br_stack_init()
1145 static void intel_pt_add_br_stack(struct intel_pt *pt, in intel_pt_add_br_stack() argument
1148 struct thread *thread = machine__findnew_thread(pt->machine, in intel_pt_add_br_stack()
1152 thread_stack__br_sample_late(thread, sample->cpu, pt->br_stack, in intel_pt_add_br_stack()
1153 pt->br_stack_sz, sample->ip, in intel_pt_add_br_stack()
1154 pt->kernel_start); in intel_pt_add_br_stack()
1156 sample->branch_stack = pt->br_stack; in intel_pt_add_br_stack()
1162 static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, in intel_pt_alloc_queue() argument
1166 struct perf_env *env = pt->machine->env; in intel_pt_alloc_queue()
1173 if (pt->synth_opts.callchain) { in intel_pt_alloc_queue()
1174 ptq->chain = intel_pt_alloc_chain(pt); in intel_pt_alloc_queue()
1179 if (pt->synth_opts.last_branch || pt->synth_opts.other_events) { in intel_pt_alloc_queue()
1180 unsigned int entry_cnt = max(LBRS_MAX, pt->br_stack_sz); in intel_pt_alloc_queue()
1191 ptq->pt = pt; in intel_pt_alloc_queue()
1193 ptq->exclude_kernel = intel_pt_exclude_kernel(pt); in intel_pt_alloc_queue()
1204 params.return_compression = intel_pt_return_compression(pt); in intel_pt_alloc_queue()
1205 params.branch_enable = intel_pt_branch_enable(pt); in intel_pt_alloc_queue()
1206 params.ctl = intel_pt_ctl(pt); in intel_pt_alloc_queue()
1207 params.max_non_turbo_ratio = pt->max_non_turbo_ratio; in intel_pt_alloc_queue()
1208 params.mtc_period = intel_pt_mtc_period(pt); in intel_pt_alloc_queue()
1209 params.tsc_ctc_ratio_n = pt->tsc_ctc_ratio_n; in intel_pt_alloc_queue()
1210 params.tsc_ctc_ratio_d = pt->tsc_ctc_ratio_d; in intel_pt_alloc_queue()
1211 params.quick = pt->synth_opts.quick; in intel_pt_alloc_queue()
1212 params.vm_time_correlation = pt->synth_opts.vm_time_correlation; in intel_pt_alloc_queue()
1213 params.vm_tm_corr_dry_run = pt->synth_opts.vm_tm_corr_dry_run; in intel_pt_alloc_queue()
1214 params.first_timestamp = pt->first_timestamp; in intel_pt_alloc_queue()
1215 params.max_loops = pt->max_loops; in intel_pt_alloc_queue()
1217 if (pt->filts.cnt > 0) in intel_pt_alloc_queue()
1220 if (pt->synth_opts.instructions) { in intel_pt_alloc_queue()
1221 if (pt->synth_opts.period) { in intel_pt_alloc_queue()
1222 switch (pt->synth_opts.period_type) { in intel_pt_alloc_queue()
1226 params.period = pt->synth_opts.period; in intel_pt_alloc_queue()
1230 params.period = pt->synth_opts.period; in intel_pt_alloc_queue()
1234 params.period = intel_pt_ns_to_ticks(pt, in intel_pt_alloc_queue()
1235 pt->synth_opts.period); in intel_pt_alloc_queue()
1280 static void intel_pt_first_timestamp(struct intel_pt *pt, u64 timestamp) in intel_pt_first_timestamp() argument
1284 pt->first_timestamp = timestamp; in intel_pt_first_timestamp()
1286 for (i = 0; i < pt->queues.nr_queues; i++) { in intel_pt_first_timestamp()
1287 struct auxtrace_queue *queue = &pt->queues.queue_array[i]; in intel_pt_first_timestamp()
1295 static void intel_pt_set_pid_tid_cpu(struct intel_pt *pt, in intel_pt_set_pid_tid_cpu() argument
1300 if (queue->tid == -1 || pt->have_sched_switch) { in intel_pt_set_pid_tid_cpu()
1301 ptq->tid = machine__get_current_tid(pt->machine, ptq->cpu); in intel_pt_set_pid_tid_cpu()
1308 ptq->thread = machine__find_thread(pt->machine, -1, ptq->tid); in intel_pt_set_pid_tid_cpu()
1351 static void intel_pt_setup_time_range(struct intel_pt *pt, in intel_pt_setup_time_range() argument
1354 if (!pt->range_cnt) in intel_pt_setup_time_range()
1357 ptq->sel_timestamp = pt->time_ranges[0].start; in intel_pt_setup_time_range()
1363 ptq->sel_timestamp = pt->time_ranges[0].end; in intel_pt_setup_time_range()
1368 static int intel_pt_setup_queue(struct intel_pt *pt, in intel_pt_setup_queue() argument
1378 ptq = intel_pt_alloc_queue(pt, queue_nr); in intel_pt_setup_queue()
1389 if (pt->sampling_mode && !pt->snapshot_mode && in intel_pt_setup_queue()
1390 pt->timeless_decoding) in intel_pt_setup_queue()
1393 ptq->sync_switch = pt->sync_switch; in intel_pt_setup_queue()
1395 intel_pt_setup_time_range(pt, ptq); in intel_pt_setup_queue()
1404 if (pt->timeless_decoding) in intel_pt_setup_queue()
1441 ret = auxtrace_heap__add(&pt->heap, queue_nr, ptq->timestamp); in intel_pt_setup_queue()
1450 static int intel_pt_setup_queues(struct intel_pt *pt) in intel_pt_setup_queues() argument
1455 for (i = 0; i < pt->queues.nr_queues; i++) { in intel_pt_setup_queues()
1456 ret = intel_pt_setup_queue(pt, &pt->queues.queue_array[i], i); in intel_pt_setup_queues()
1463 static inline bool intel_pt_skip_event(struct intel_pt *pt) in intel_pt_skip_event() argument
1465 return pt->synth_opts.initial_skip && in intel_pt_skip_event()
1466 pt->num_events++ < pt->synth_opts.initial_skip; in intel_pt_skip_event()
1474 static inline bool intel_pt_skip_cbr_event(struct intel_pt *pt) in intel_pt_skip_cbr_event() argument
1476 return pt->synth_opts.initial_skip && in intel_pt_skip_cbr_event()
1477 pt->num_events + 4 < pt->synth_opts.initial_skip; in intel_pt_skip_cbr_event()
1494 static void intel_pt_prep_b_sample(struct intel_pt *pt, in intel_pt_prep_b_sample() argument
1501 if (!pt->timeless_decoding) in intel_pt_prep_b_sample()
1502 sample->time = tsc_to_perf_time(ptq->timestamp, &pt->tc); in intel_pt_prep_b_sample()
1520 static inline int intel_pt_opt_inject(struct intel_pt *pt, in intel_pt_opt_inject() argument
1524 if (!pt->synth_opts.inject) in intel_pt_opt_inject()
1530 static int intel_pt_deliver_synth_event(struct intel_pt *pt, in intel_pt_deliver_synth_event() argument
1536 ret = intel_pt_opt_inject(pt, event, sample, type); in intel_pt_deliver_synth_event()
1540 ret = perf_session__deliver_synth_event(pt->session, event, sample); in intel_pt_deliver_synth_event()
1549 struct intel_pt *pt = ptq->pt; in intel_pt_synth_branch_sample() local
1558 if (pt->branches_filter && !(pt->branches_filter & ptq->flags)) in intel_pt_synth_branch_sample()
1561 if (intel_pt_skip_event(pt)) in intel_pt_synth_branch_sample()
1564 intel_pt_prep_b_sample(pt, ptq, event, &sample); in intel_pt_synth_branch_sample()
1566 sample.id = ptq->pt->branches_id; in intel_pt_synth_branch_sample()
1567 sample.stream_id = ptq->pt->branches_id; in intel_pt_synth_branch_sample()
1573 if (pt->synth_opts.last_branch && sort__mode == SORT_MODE__BRANCH) { in intel_pt_synth_branch_sample()
1593 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_branch_sample()
1594 pt->branches_sample_type); in intel_pt_synth_branch_sample()
1597 static void intel_pt_prep_sample(struct intel_pt *pt, in intel_pt_prep_sample() argument
1602 intel_pt_prep_b_sample(pt, ptq, event, sample); in intel_pt_prep_sample()
1604 if (pt->synth_opts.callchain) { in intel_pt_prep_sample()
1606 pt->synth_opts.callchain_sz + 1, in intel_pt_prep_sample()
1607 sample->ip, pt->kernel_start); in intel_pt_prep_sample()
1611 if (pt->synth_opts.last_branch) { in intel_pt_prep_sample()
1613 pt->br_stack_sz); in intel_pt_prep_sample()
1620 struct intel_pt *pt = ptq->pt; in intel_pt_synth_instruction_sample() local
1624 if (intel_pt_skip_event(pt)) in intel_pt_synth_instruction_sample()
1627 intel_pt_prep_sample(pt, ptq, event, &sample); in intel_pt_synth_instruction_sample()
1629 sample.id = ptq->pt->instructions_id; in intel_pt_synth_instruction_sample()
1630 sample.stream_id = ptq->pt->instructions_id; in intel_pt_synth_instruction_sample()
1631 if (pt->synth_opts.quick) in intel_pt_synth_instruction_sample()
1646 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_instruction_sample()
1647 pt->instructions_sample_type); in intel_pt_synth_instruction_sample()
1652 struct intel_pt *pt = ptq->pt; in intel_pt_synth_transaction_sample() local
1656 if (intel_pt_skip_event(pt)) in intel_pt_synth_transaction_sample()
1659 intel_pt_prep_sample(pt, ptq, event, &sample); in intel_pt_synth_transaction_sample()
1661 sample.id = ptq->pt->transactions_id; in intel_pt_synth_transaction_sample()
1662 sample.stream_id = ptq->pt->transactions_id; in intel_pt_synth_transaction_sample()
1664 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_transaction_sample()
1665 pt->transactions_sample_type); in intel_pt_synth_transaction_sample()
1668 static void intel_pt_prep_p_sample(struct intel_pt *pt, in intel_pt_prep_p_sample() argument
1673 intel_pt_prep_sample(pt, ptq, event, sample); in intel_pt_prep_p_sample()
1685 struct intel_pt *pt = ptq->pt; in intel_pt_synth_ptwrite_sample() local
1690 if (intel_pt_skip_event(pt)) in intel_pt_synth_ptwrite_sample()
1693 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_ptwrite_sample()
1695 sample.id = ptq->pt->ptwrites_id; in intel_pt_synth_ptwrite_sample()
1696 sample.stream_id = ptq->pt->ptwrites_id; in intel_pt_synth_ptwrite_sample()
1705 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_ptwrite_sample()
1706 pt->ptwrites_sample_type); in intel_pt_synth_ptwrite_sample()
1711 struct intel_pt *pt = ptq->pt; in intel_pt_synth_cbr_sample() local
1717 if (intel_pt_skip_cbr_event(pt)) in intel_pt_synth_cbr_sample()
1722 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_cbr_sample()
1724 sample.id = ptq->pt->cbr_id; in intel_pt_synth_cbr_sample()
1725 sample.stream_id = ptq->pt->cbr_id; in intel_pt_synth_cbr_sample()
1727 flags = (u16)ptq->state->cbr_payload | (pt->max_non_turbo_ratio << 16); in intel_pt_synth_cbr_sample()
1729 raw.freq = cpu_to_le32(raw.cbr * pt->cbr2khz); in intel_pt_synth_cbr_sample()
1735 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_cbr_sample()
1736 pt->pwr_events_sample_type); in intel_pt_synth_cbr_sample()
1741 struct intel_pt *pt = ptq->pt; in intel_pt_synth_psb_sample() local
1746 if (intel_pt_skip_event(pt)) in intel_pt_synth_psb_sample()
1749 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_psb_sample()
1751 sample.id = ptq->pt->psb_id; in intel_pt_synth_psb_sample()
1752 sample.stream_id = ptq->pt->psb_id; in intel_pt_synth_psb_sample()
1761 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_psb_sample()
1762 pt->pwr_events_sample_type); in intel_pt_synth_psb_sample()
1767 struct intel_pt *pt = ptq->pt; in intel_pt_synth_mwait_sample() local
1772 if (intel_pt_skip_event(pt)) in intel_pt_synth_mwait_sample()
1775 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_mwait_sample()
1777 sample.id = ptq->pt->mwait_id; in intel_pt_synth_mwait_sample()
1778 sample.stream_id = ptq->pt->mwait_id; in intel_pt_synth_mwait_sample()
1786 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_mwait_sample()
1787 pt->pwr_events_sample_type); in intel_pt_synth_mwait_sample()
1792 struct intel_pt *pt = ptq->pt; in intel_pt_synth_pwre_sample() local
1797 if (intel_pt_skip_event(pt)) in intel_pt_synth_pwre_sample()
1800 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_pwre_sample()
1802 sample.id = ptq->pt->pwre_id; in intel_pt_synth_pwre_sample()
1803 sample.stream_id = ptq->pt->pwre_id; in intel_pt_synth_pwre_sample()
1811 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_pwre_sample()
1812 pt->pwr_events_sample_type); in intel_pt_synth_pwre_sample()
1817 struct intel_pt *pt = ptq->pt; in intel_pt_synth_exstop_sample() local
1822 if (intel_pt_skip_event(pt)) in intel_pt_synth_exstop_sample()
1825 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_exstop_sample()
1827 sample.id = ptq->pt->exstop_id; in intel_pt_synth_exstop_sample()
1828 sample.stream_id = ptq->pt->exstop_id; in intel_pt_synth_exstop_sample()
1836 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_exstop_sample()
1837 pt->pwr_events_sample_type); in intel_pt_synth_exstop_sample()
1842 struct intel_pt *pt = ptq->pt; in intel_pt_synth_pwrx_sample() local
1847 if (intel_pt_skip_event(pt)) in intel_pt_synth_pwrx_sample()
1850 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_pwrx_sample()
1852 sample.id = ptq->pt->pwrx_id; in intel_pt_synth_pwrx_sample()
1853 sample.stream_id = ptq->pt->pwrx_id; in intel_pt_synth_pwrx_sample()
1861 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_pwrx_sample()
1862 pt->pwr_events_sample_type); in intel_pt_synth_pwrx_sample()
1997 struct intel_pt *pt = ptq->pt; in intel_pt_do_synth_pebs_sample() local
2002 if (intel_pt_skip_event(pt)) in intel_pt_do_synth_pebs_sample()
2032 else if (!pt->timeless_decoding) in intel_pt_do_synth_pebs_sample()
2035 sample.time = tsc_to_perf_time(timestamp, &pt->tc); in intel_pt_do_synth_pebs_sample()
2039 pt->synth_opts.callchain) { in intel_pt_do_synth_pebs_sample()
2041 pt->synth_opts.callchain_sz, sample.ip, in intel_pt_do_synth_pebs_sample()
2042 pt->kernel_start); in intel_pt_do_synth_pebs_sample()
2067 } else if (pt->synth_opts.last_branch) { in intel_pt_do_synth_pebs_sample()
2070 pt->br_stack_sz); in intel_pt_do_synth_pebs_sample()
2121 return intel_pt_deliver_synth_event(pt, event, &sample, sample_type); in intel_pt_do_synth_pebs_sample()
2126 struct intel_pt *pt = ptq->pt; in intel_pt_synth_single_pebs_sample() local
2127 struct evsel *evsel = pt->pebs_evsel; in intel_pt_synth_single_pebs_sample()
2137 struct intel_pt *pt = ptq->pt; in intel_pt_synth_pebs_sample() local
2142 if (!pt->single_pebs) in intel_pt_synth_pebs_sample()
2150 if (!pt->single_pebs) in intel_pt_synth_pebs_sample()
2163 static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu, in intel_pt_synth_error() argument
2170 if (pt->synth_opts.error_minus_flags) { in intel_pt_synth_error()
2172 pt->synth_opts.error_minus_flags & AUXTRACE_ERR_FLG_OVERFLOW) in intel_pt_synth_error()
2175 pt->synth_opts.error_minus_flags & AUXTRACE_ERR_FLG_DATA_LOST) in intel_pt_synth_error()
2184 err = perf_session__deliver_synth_event(pt->session, &event, NULL); in intel_pt_synth_error()
2195 struct intel_pt *pt = ptq->pt; in intel_ptq_synth_error() local
2198 tm = pt->timeless_decoding ? 0 : tsc_to_perf_time(tm, &pt->tc); in intel_ptq_synth_error()
2200 return intel_pt_synth_error(pt, state->err, ptq->cpu, ptq->pid, in intel_ptq_synth_error()
2204 static int intel_pt_next_tid(struct intel_pt *pt, struct intel_pt_queue *ptq) in intel_pt_next_tid() argument
2215 err = machine__set_current_tid(pt->machine, ptq->cpu, -1, tid); in intel_pt_next_tid()
2217 queue = &pt->queues.queue_array[ptq->queue_nr]; in intel_pt_next_tid()
2218 intel_pt_set_pid_tid_cpu(pt, queue); in intel_pt_next_tid()
2227 struct intel_pt *pt = ptq->pt; in intel_pt_is_switch_ip() local
2229 return ip == pt->switch_ip && in intel_pt_is_switch_ip()
2241 struct intel_pt *pt = ptq->pt; in intel_pt_sample() local
2249 if (pt->synth_opts.approx_ipc) { in intel_pt_sample()
2263 if (pt->sample_pebs && state->type & INTEL_PT_BLK_ITEMS) { in intel_pt_sample()
2269 if (pt->sample_pwr_events) { in intel_pt_sample()
2304 if (pt->sample_instructions && (state->type & INTEL_PT_INSTRUCTION)) { in intel_pt_sample()
2310 if (pt->sample_transactions && (state->type & INTEL_PT_TRANSACTION)) { in intel_pt_sample()
2316 if (pt->sample_ptwrites && (state->type & INTEL_PT_PTW)) { in intel_pt_sample()
2325 if (pt->use_thread_stack) { in intel_pt_sample()
2328 state->trace_nr, pt->callstack, in intel_pt_sample()
2329 pt->br_stack_sz_plus, in intel_pt_sample()
2330 pt->mispred_all); in intel_pt_sample()
2335 if (pt->sample_branches) { in intel_pt_sample()
2369 err = intel_pt_next_tid(pt, ptq); in intel_pt_sample()
2383 state->to_ip == pt->ptss_ip && in intel_pt_sample()
2391 static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip) in intel_pt_switch_ip() argument
2393 struct machine *machine = pt->machine; in intel_pt_switch_ip()
2425 if (pt->have_sched_switch == 1) in intel_pt_switch_ip()
2443 static void intel_pt_enable_sync_switch(struct intel_pt *pt) in intel_pt_enable_sync_switch() argument
2447 pt->sync_switch = true; in intel_pt_enable_sync_switch()
2449 for (i = 0; i < pt->queues.nr_queues; i++) { in intel_pt_enable_sync_switch()
2450 struct auxtrace_queue *queue = &pt->queues.queue_array[i]; in intel_pt_enable_sync_switch()
2464 struct intel_pt *pt = ptq->pt; in intel_pt_next_time() local
2469 ptq->sel_timestamp = pt->time_ranges[ptq->sel_idx].end; in intel_pt_next_time()
2471 } else if (ptq->sel_idx + 1 < pt->range_cnt) { in intel_pt_next_time()
2475 ptq->sel_timestamp = pt->time_ranges[ptq->sel_idx].start; in intel_pt_next_time()
2503 intel_pt_next_tid(ptq->pt, ptq); in intel_pt_time_filter()
2533 struct intel_pt *pt = ptq->pt; in intel_pt_run_decoder() local
2537 if (!pt->kernel_start) { in intel_pt_run_decoder()
2538 pt->kernel_start = machine__kernel_start(pt->machine); in intel_pt_run_decoder()
2539 if (pt->per_cpu_mmaps && in intel_pt_run_decoder()
2540 (pt->have_sched_switch == 1 || pt->have_sched_switch == 3) && in intel_pt_run_decoder()
2541 !pt->timeless_decoding && intel_pt_tracing_kernel(pt) && in intel_pt_run_decoder()
2542 !pt->sampling_mode && !pt->synth_opts.vm_time_correlation) { in intel_pt_run_decoder()
2543 pt->switch_ip = intel_pt_switch_ip(pt, &pt->ptss_ip); in intel_pt_run_decoder()
2544 if (pt->switch_ip) { in intel_pt_run_decoder()
2546 pt->switch_ip, pt->ptss_ip); in intel_pt_run_decoder()
2547 intel_pt_enable_sync_switch(pt); in intel_pt_run_decoder()
2564 state->from_ip >= pt->kernel_start) { in intel_pt_run_decoder()
2566 intel_pt_next_tid(pt, ptq); in intel_pt_run_decoder()
2569 if (pt->synth_opts.errors) { in intel_pt_run_decoder()
2582 if (pt->est_tsc && in intel_pt_run_decoder()
2583 (state->from_ip >= pt->kernel_start || !state->from_ip) && in intel_pt_run_decoder()
2584 state->to_ip && state->to_ip < pt->kernel_start) { in intel_pt_run_decoder()
2606 if (!pt->timeless_decoding && ptq->timestamp >= *timestamp) { in intel_pt_run_decoder()
2614 static inline int intel_pt_update_queues(struct intel_pt *pt) in intel_pt_update_queues() argument
2616 if (pt->queues.new_data) { in intel_pt_update_queues()
2617 pt->queues.new_data = false; in intel_pt_update_queues()
2618 return intel_pt_setup_queues(pt); in intel_pt_update_queues()
2623 static int intel_pt_process_queues(struct intel_pt *pt, u64 timestamp) in intel_pt_process_queues() argument
2633 if (!pt->heap.heap_cnt) in intel_pt_process_queues()
2636 if (pt->heap.heap_array[0].ordinal >= timestamp) in intel_pt_process_queues()
2639 queue_nr = pt->heap.heap_array[0].queue_nr; in intel_pt_process_queues()
2640 queue = &pt->queues.queue_array[queue_nr]; in intel_pt_process_queues()
2644 queue_nr, pt->heap.heap_array[0].ordinal, in intel_pt_process_queues()
2647 auxtrace_heap__pop(&pt->heap); in intel_pt_process_queues()
2649 if (pt->heap.heap_cnt) { in intel_pt_process_queues()
2650 ts = pt->heap.heap_array[0].ordinal + 1; in intel_pt_process_queues()
2657 intel_pt_set_pid_tid_cpu(pt, queue); in intel_pt_process_queues()
2662 auxtrace_heap__add(&pt->heap, queue_nr, ts); in intel_pt_process_queues()
2667 ret = auxtrace_heap__add(&pt->heap, queue_nr, ts); in intel_pt_process_queues()
2678 static int intel_pt_process_timeless_queues(struct intel_pt *pt, pid_t tid, in intel_pt_process_timeless_queues() argument
2681 struct auxtrace_queues *queues = &pt->queues; in intel_pt_process_timeless_queues()
2686 struct auxtrace_queue *queue = &pt->queues.queue_array[i]; in intel_pt_process_timeless_queues()
2691 intel_pt_set_pid_tid_cpu(pt, queue); in intel_pt_process_timeless_queues()
2702 struct machine *m = ptq->pt->machine; in intel_pt_sample_set_pid_tid_cpu()
2726 static int intel_pt_process_timeless_sample(struct intel_pt *pt, in intel_pt_process_timeless_sample() argument
2733 queue = auxtrace_queues__sample_queue(&pt->queues, sample, pt->session); in intel_pt_process_timeless_sample()
2748 static int intel_pt_lost(struct intel_pt *pt, struct perf_sample *sample) in intel_pt_lost() argument
2750 return intel_pt_synth_error(pt, INTEL_PT_ERR_LOST, sample->cpu, in intel_pt_lost()
2754 static struct intel_pt_queue *intel_pt_cpu_to_ptq(struct intel_pt *pt, int cpu) in intel_pt_cpu_to_ptq() argument
2758 if (cpu < 0 || !pt->queues.nr_queues) in intel_pt_cpu_to_ptq()
2761 if ((unsigned)cpu >= pt->queues.nr_queues) in intel_pt_cpu_to_ptq()
2762 i = pt->queues.nr_queues - 1; in intel_pt_cpu_to_ptq()
2766 if (pt->queues.queue_array[i].cpu == cpu) in intel_pt_cpu_to_ptq()
2767 return pt->queues.queue_array[i].priv; in intel_pt_cpu_to_ptq()
2770 if (pt->queues.queue_array[--i].cpu == cpu) in intel_pt_cpu_to_ptq()
2771 return pt->queues.queue_array[i].priv; in intel_pt_cpu_to_ptq()
2774 for (; j < pt->queues.nr_queues; j++) { in intel_pt_cpu_to_ptq()
2775 if (pt->queues.queue_array[j].cpu == cpu) in intel_pt_cpu_to_ptq()
2776 return pt->queues.queue_array[j].priv; in intel_pt_cpu_to_ptq()
2782 static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid, in intel_pt_sync_switch() argument
2788 if (!pt->sync_switch) in intel_pt_sync_switch()
2791 ptq = intel_pt_cpu_to_ptq(pt, cpu); in intel_pt_sync_switch()
2806 &pt->tc); in intel_pt_sync_switch()
2807 err = auxtrace_heap__add(&pt->heap, ptq->queue_nr, in intel_pt_sync_switch()
2827 static int intel_pt_process_switch(struct intel_pt *pt, in intel_pt_process_switch() argument
2832 struct evsel *evsel = evlist__id2evsel(pt->session->evlist, sample->id); in intel_pt_process_switch()
2834 if (evsel != pt->switch_evsel) in intel_pt_process_switch()
2842 &pt->tc)); in intel_pt_process_switch()
2844 ret = intel_pt_sync_switch(pt, cpu, tid, sample->time); in intel_pt_process_switch()
2848 return machine__set_current_tid(pt->machine, cpu, -1, tid); in intel_pt_process_switch()
2851 static int intel_pt_context_switch_in(struct intel_pt *pt, in intel_pt_context_switch_in() argument
2858 if (pt->sync_switch) { in intel_pt_context_switch_in()
2861 ptq = intel_pt_cpu_to_ptq(pt, cpu); in intel_pt_context_switch_in()
2883 if (machine__get_current_tid(pt->machine, cpu) == tid) in intel_pt_context_switch_in()
2886 return machine__set_current_tid(pt->machine, cpu, pid, tid); in intel_pt_context_switch_in()
2889 static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event, in intel_pt_context_switch() argument
2898 if (pt->have_sched_switch == 3) { in intel_pt_context_switch()
2900 return intel_pt_context_switch_in(pt, sample); in intel_pt_context_switch()
2917 ret = intel_pt_sync_switch(pt, cpu, tid, sample->time); in intel_pt_context_switch()
2921 return machine__set_current_tid(pt->machine, cpu, pid, tid); in intel_pt_context_switch()
2924 static int intel_pt_process_itrace_start(struct intel_pt *pt, in intel_pt_process_itrace_start() argument
2928 if (!pt->per_cpu_mmaps) in intel_pt_process_itrace_start()
2934 perf_time_to_tsc(sample->time, &pt->tc)); in intel_pt_process_itrace_start()
2936 return machine__set_current_tid(pt->machine, sample->cpu, in intel_pt_process_itrace_start()
2941 static int intel_pt_process_aux_output_hw_id(struct intel_pt *pt, in intel_pt_process_aux_output_hw_id() argument
2950 queue = auxtrace_queues__sample_queue(&pt->queues, sample, pt->session); in intel_pt_process_aux_output_hw_id()
2951 evsel = evlist__id2evsel_strict(pt->session->evlist, sample->id); in intel_pt_process_aux_output_hw_id()
2977 static int intel_pt_text_poke(struct intel_pt *pt, union perf_event *event) in intel_pt_text_poke() argument
2983 struct thread *thread = pt->unknown_thread; in intel_pt_text_poke()
2985 struct machine *machine = pt->machine; in intel_pt_text_poke()
3031 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_process_event() local
3045 timestamp = perf_time_to_tsc(sample->time, &pt->tc); in intel_pt_process_event()
3049 if (timestamp || pt->timeless_decoding) { in intel_pt_process_event()
3050 err = intel_pt_update_queues(pt); in intel_pt_process_event()
3055 if (pt->timeless_decoding) { in intel_pt_process_event()
3056 if (pt->sampling_mode) { in intel_pt_process_event()
3058 err = intel_pt_process_timeless_sample(pt, in intel_pt_process_event()
3061 err = intel_pt_process_timeless_queues(pt, in intel_pt_process_event()
3066 if (!pt->first_timestamp) in intel_pt_process_event()
3067 intel_pt_first_timestamp(pt, timestamp); in intel_pt_process_event()
3068 err = intel_pt_process_queues(pt, timestamp); in intel_pt_process_event()
3074 if (pt->synth_opts.add_callchain && !sample->callchain) in intel_pt_process_event()
3075 intel_pt_add_callchain(pt, sample); in intel_pt_process_event()
3076 if (pt->synth_opts.add_last_branch && !sample->branch_stack) in intel_pt_process_event()
3077 intel_pt_add_br_stack(pt, sample); in intel_pt_process_event()
3082 pt->synth_opts.errors) { in intel_pt_process_event()
3083 err = intel_pt_lost(pt, sample); in intel_pt_process_event()
3088 if (pt->switch_evsel && event->header.type == PERF_RECORD_SAMPLE) in intel_pt_process_event()
3089 err = intel_pt_process_switch(pt, sample); in intel_pt_process_event()
3091 err = intel_pt_process_itrace_start(pt, event, sample); in intel_pt_process_event()
3093 err = intel_pt_process_aux_output_hw_id(pt, event, sample); in intel_pt_process_event()
3096 err = intel_pt_context_switch(pt, event, sample); in intel_pt_process_event()
3099 err = intel_pt_text_poke(pt, event); in intel_pt_process_event()
3101 if (intel_pt_enable_logging && intel_pt_log_events(pt, sample->time)) { in intel_pt_process_event()
3112 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_flush() local
3122 ret = intel_pt_update_queues(pt); in intel_pt_flush()
3126 if (pt->timeless_decoding) in intel_pt_flush()
3127 return intel_pt_process_timeless_queues(pt, -1, in intel_pt_flush()
3130 return intel_pt_process_queues(pt, MAX_TIMESTAMP); in intel_pt_flush()
3135 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_free_events() local
3137 struct auxtrace_queues *queues = &pt->queues; in intel_pt_free_events()
3150 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_free() local
3153 auxtrace_heap__free(&pt->heap); in intel_pt_free()
3156 intel_pt_free_vmcs_info(pt); in intel_pt_free()
3157 thread__put(pt->unknown_thread); in intel_pt_free()
3158 addr_filters__exit(&pt->filts); in intel_pt_free()
3159 zfree(&pt->chain); in intel_pt_free()
3160 zfree(&pt->filter); in intel_pt_free()
3161 zfree(&pt->time_ranges); in intel_pt_free()
3162 free(pt); in intel_pt_free()
3168 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_evsel_is_auxtrace() local
3171 return evsel->core.attr.type == pt->pmu_type; in intel_pt_evsel_is_auxtrace()
3178 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_process_auxtrace_event() local
3181 if (!pt->data_queued) { in intel_pt_process_auxtrace_event()
3195 err = auxtrace_queues__add_event(&pt->queues, session, event, in intel_pt_process_auxtrace_event()
3203 intel_pt_dump_event(pt, buffer->data, in intel_pt_process_auxtrace_event()
3217 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_queue_data() local
3222 return auxtrace_queues__add_event(&pt->queues, session, event, in intel_pt_queue_data()
3227 timestamp = perf_time_to_tsc(sample->time, &pt->tc); in intel_pt_queue_data()
3231 return auxtrace_queues__add_sample(&pt->queues, session, sample, in intel_pt_queue_data()
3288 static struct evsel *intel_pt_evsel(struct intel_pt *pt, in intel_pt_evsel() argument
3294 if (evsel->core.attr.type == pt->pmu_type && evsel->core.ids) in intel_pt_evsel()
3301 static int intel_pt_synth_events(struct intel_pt *pt, in intel_pt_synth_events() argument
3305 struct evsel *evsel = intel_pt_evsel(pt, evlist); in intel_pt_synth_events()
3321 if (pt->timeless_decoding) in intel_pt_synth_events()
3325 if (!pt->per_cpu_mmaps) in intel_pt_synth_events()
3339 if (pt->synth_opts.branches) { in intel_pt_synth_events()
3346 pt->sample_branches = true; in intel_pt_synth_events()
3347 pt->branches_sample_type = attr.sample_type; in intel_pt_synth_events()
3348 pt->branches_id = id; in intel_pt_synth_events()
3353 if (pt->synth_opts.callchain) in intel_pt_synth_events()
3355 if (pt->synth_opts.last_branch) { in intel_pt_synth_events()
3365 if (pt->synth_opts.instructions) { in intel_pt_synth_events()
3367 if (pt->synth_opts.period_type == PERF_ITRACE_PERIOD_NANOSECS) in intel_pt_synth_events()
3369 intel_pt_ns_to_ticks(pt, pt->synth_opts.period); in intel_pt_synth_events()
3371 attr.sample_period = pt->synth_opts.period; in intel_pt_synth_events()
3375 pt->sample_instructions = true; in intel_pt_synth_events()
3376 pt->instructions_sample_type = attr.sample_type; in intel_pt_synth_events()
3377 pt->instructions_id = id; in intel_pt_synth_events()
3384 if (pt->synth_opts.transactions) { in intel_pt_synth_events()
3389 pt->sample_transactions = true; in intel_pt_synth_events()
3390 pt->transactions_sample_type = attr.sample_type; in intel_pt_synth_events()
3391 pt->transactions_id = id; in intel_pt_synth_events()
3399 if (pt->synth_opts.ptwrites) { in intel_pt_synth_events()
3404 pt->sample_ptwrites = true; in intel_pt_synth_events()
3405 pt->ptwrites_sample_type = attr.sample_type; in intel_pt_synth_events()
3406 pt->ptwrites_id = id; in intel_pt_synth_events()
3411 if (pt->synth_opts.pwr_events) { in intel_pt_synth_events()
3412 pt->sample_pwr_events = true; in intel_pt_synth_events()
3413 pt->pwr_events_sample_type = attr.sample_type; in intel_pt_synth_events()
3419 pt->cbr_id = id; in intel_pt_synth_events()
3427 pt->psb_id = id; in intel_pt_synth_events()
3432 if (pt->synth_opts.pwr_events && (evsel->core.attr.config & 0x10)) { in intel_pt_synth_events()
3437 pt->mwait_id = id; in intel_pt_synth_events()
3445 pt->pwre_id = id; in intel_pt_synth_events()
3453 pt->exstop_id = id; in intel_pt_synth_events()
3461 pt->pwrx_id = id; in intel_pt_synth_events()
3469 static void intel_pt_setup_pebs_events(struct intel_pt *pt) in intel_pt_setup_pebs_events() argument
3473 if (!pt->synth_opts.other_events) in intel_pt_setup_pebs_events()
3476 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_setup_pebs_events()
3478 if (pt->single_pebs) { in intel_pt_setup_pebs_events()
3479 pt->single_pebs = false; in intel_pt_setup_pebs_events()
3482 pt->single_pebs = true; in intel_pt_setup_pebs_events()
3483 pt->sample_pebs = true; in intel_pt_setup_pebs_events()
3484 pt->pebs_evsel = evsel; in intel_pt_setup_pebs_events()
3517 struct intel_pt *pt = data; in intel_pt_perf_config() local
3520 pt->mispred_all = perf_config_bool(var, value); in intel_pt_perf_config()
3523 perf_config_int(&pt->max_loops, var, value); in intel_pt_perf_config()
3529 static u64 intel_pt_tsc_start(u64 ns, struct intel_pt *pt) in intel_pt_tsc_start() argument
3533 tsc = perf_time_to_tsc(ns, &pt->tc); in intel_pt_tsc_start()
3536 tm = tsc_to_perf_time(tsc, &pt->tc); in intel_pt_tsc_start()
3543 tm = tsc_to_perf_time(++tsc, &pt->tc); in intel_pt_tsc_start()
3549 static u64 intel_pt_tsc_end(u64 ns, struct intel_pt *pt) in intel_pt_tsc_end() argument
3553 tsc = perf_time_to_tsc(ns, &pt->tc); in intel_pt_tsc_end()
3556 tm = tsc_to_perf_time(tsc, &pt->tc); in intel_pt_tsc_end()
3563 tm = tsc_to_perf_time(--tsc, &pt->tc); in intel_pt_tsc_end()
3568 static int intel_pt_setup_time_ranges(struct intel_pt *pt, in intel_pt_setup_time_ranges() argument
3575 if (!n || !p || pt->timeless_decoding) in intel_pt_setup_time_ranges()
3578 pt->time_ranges = calloc(n, sizeof(struct range)); in intel_pt_setup_time_ranges()
3579 if (!pt->time_ranges) in intel_pt_setup_time_ranges()
3582 pt->range_cnt = n; in intel_pt_setup_time_ranges()
3587 struct range *r = &pt->time_ranges[i]; in intel_pt_setup_time_ranges()
3595 r->start = ts ? intel_pt_tsc_start(ts, pt) : 0; in intel_pt_setup_time_ranges()
3596 r->end = te ? intel_pt_tsc_end(te, pt) : 0; in intel_pt_setup_time_ranges()
3607 static int intel_pt_parse_vm_tm_corr_arg(struct intel_pt *pt, char **args) in intel_pt_parse_vm_tm_corr_arg() argument
3624 pt->dflt_tsc_offset = tsc_offset; in intel_pt_parse_vm_tm_corr_arg()
3635 vmcs_info = intel_pt_findnew_vmcs(&pt->vmcs_info, vmcs, tsc_offset); in intel_pt_parse_vm_tm_corr_arg()
3647 static int intel_pt_parse_vm_tm_corr_args(struct intel_pt *pt) in intel_pt_parse_vm_tm_corr_args() argument
3649 char *args = pt->synth_opts.vm_tm_corr_args; in intel_pt_parse_vm_tm_corr_args()
3656 ret = intel_pt_parse_vm_tm_corr_arg(pt, &args); in intel_pt_parse_vm_tm_corr_args()
3716 struct intel_pt *pt; in intel_pt_process_auxtrace_info() local
3725 pt = zalloc(sizeof(struct intel_pt)); in intel_pt_process_auxtrace_info()
3726 if (!pt) in intel_pt_process_auxtrace_info()
3729 pt->vmcs_info = RB_ROOT; in intel_pt_process_auxtrace_info()
3731 addr_filters__init(&pt->filts); in intel_pt_process_auxtrace_info()
3733 err = perf_config(intel_pt_perf_config, pt); in intel_pt_process_auxtrace_info()
3737 err = auxtrace_queues__init(&pt->queues); in intel_pt_process_auxtrace_info()
3742 pt->synth_opts = *session->itrace_synth_opts; in intel_pt_process_auxtrace_info()
3746 itrace_synth_opts__set_default(&pt->synth_opts, opts->default_no_sample); in intel_pt_process_auxtrace_info()
3748 pt->synth_opts.branches = false; in intel_pt_process_auxtrace_info()
3749 pt->synth_opts.callchain = true; in intel_pt_process_auxtrace_info()
3750 pt->synth_opts.add_callchain = true; in intel_pt_process_auxtrace_info()
3752 pt->synth_opts.thread_stack = opts->thread_stack; in intel_pt_process_auxtrace_info()
3755 if (!(pt->synth_opts.log_plus_flags & AUXTRACE_LOG_FLG_USE_STDOUT)) in intel_pt_process_auxtrace_info()
3758 pt->session = session; in intel_pt_process_auxtrace_info()
3759 pt->machine = &session->machines.host; /* No kvm support */ in intel_pt_process_auxtrace_info()
3760 pt->auxtrace_type = auxtrace_info->type; in intel_pt_process_auxtrace_info()
3761 pt->pmu_type = auxtrace_info->priv[INTEL_PT_PMU_TYPE]; in intel_pt_process_auxtrace_info()
3762 pt->tc.time_shift = auxtrace_info->priv[INTEL_PT_TIME_SHIFT]; in intel_pt_process_auxtrace_info()
3763 pt->tc.time_mult = auxtrace_info->priv[INTEL_PT_TIME_MULT]; in intel_pt_process_auxtrace_info()
3764 pt->tc.time_zero = auxtrace_info->priv[INTEL_PT_TIME_ZERO]; in intel_pt_process_auxtrace_info()
3765 pt->cap_user_time_zero = auxtrace_info->priv[INTEL_PT_CAP_USER_TIME_ZERO]; in intel_pt_process_auxtrace_info()
3766 pt->tsc_bit = auxtrace_info->priv[INTEL_PT_TSC_BIT]; in intel_pt_process_auxtrace_info()
3767 pt->noretcomp_bit = auxtrace_info->priv[INTEL_PT_NORETCOMP_BIT]; in intel_pt_process_auxtrace_info()
3768 pt->have_sched_switch = auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH]; in intel_pt_process_auxtrace_info()
3769 pt->snapshot_mode = auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE]; in intel_pt_process_auxtrace_info()
3770 pt->per_cpu_mmaps = auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS]; in intel_pt_process_auxtrace_info()
3775 pt->mtc_bit = auxtrace_info->priv[INTEL_PT_MTC_BIT]; in intel_pt_process_auxtrace_info()
3776 pt->mtc_freq_bits = auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS]; in intel_pt_process_auxtrace_info()
3777 pt->tsc_ctc_ratio_n = auxtrace_info->priv[INTEL_PT_TSC_CTC_N]; in intel_pt_process_auxtrace_info()
3778 pt->tsc_ctc_ratio_d = auxtrace_info->priv[INTEL_PT_TSC_CTC_D]; in intel_pt_process_auxtrace_info()
3779 pt->cyc_bit = auxtrace_info->priv[INTEL_PT_CYC_BIT]; in intel_pt_process_auxtrace_info()
3785 pt->max_non_turbo_ratio = in intel_pt_process_auxtrace_info()
3812 pt->filter = memdup(filter, len); in intel_pt_process_auxtrace_info()
3813 if (!pt->filter) { in intel_pt_process_auxtrace_info()
3818 mem_bswap_64(pt->filter, len); in intel_pt_process_auxtrace_info()
3819 if (pt->filter[len - 1]) { in intel_pt_process_auxtrace_info()
3824 err = addr_filters__parse_bare_filter(&pt->filts, in intel_pt_process_auxtrace_info()
3829 intel_pt_print_info_str("Filter string", pt->filter); in intel_pt_process_auxtrace_info()
3832 pt->timeless_decoding = intel_pt_timeless_decoding(pt); in intel_pt_process_auxtrace_info()
3833 if (pt->timeless_decoding && !pt->tc.time_mult) in intel_pt_process_auxtrace_info()
3834 pt->tc.time_mult = 1; in intel_pt_process_auxtrace_info()
3835 pt->have_tsc = intel_pt_have_tsc(pt); in intel_pt_process_auxtrace_info()
3836 pt->sampling_mode = intel_pt_sampling_mode(pt); in intel_pt_process_auxtrace_info()
3837 pt->est_tsc = !pt->timeless_decoding; in intel_pt_process_auxtrace_info()
3839 if (pt->synth_opts.vm_time_correlation) { in intel_pt_process_auxtrace_info()
3840 if (pt->timeless_decoding) { in intel_pt_process_auxtrace_info()
3851 if (!intel_pt_have_mtc(pt)) { in intel_pt_process_auxtrace_info()
3856 err = intel_pt_parse_vm_tm_corr_args(pt); in intel_pt_process_auxtrace_info()
3861 pt->unknown_thread = thread__new(999999999, 999999999); in intel_pt_process_auxtrace_info()
3862 if (!pt->unknown_thread) { in intel_pt_process_auxtrace_info()
3873 INIT_LIST_HEAD(&pt->unknown_thread->node); in intel_pt_process_auxtrace_info()
3875 err = thread__set_comm(pt->unknown_thread, "unknown", 0); in intel_pt_process_auxtrace_info()
3878 if (thread__init_maps(pt->unknown_thread, pt->machine)) { in intel_pt_process_auxtrace_info()
3883 pt->auxtrace.process_event = intel_pt_process_event; in intel_pt_process_auxtrace_info()
3884 pt->auxtrace.process_auxtrace_event = intel_pt_process_auxtrace_event; in intel_pt_process_auxtrace_info()
3885 pt->auxtrace.queue_data = intel_pt_queue_data; in intel_pt_process_auxtrace_info()
3886 pt->auxtrace.dump_auxtrace_sample = intel_pt_dump_sample; in intel_pt_process_auxtrace_info()
3887 pt->auxtrace.flush_events = intel_pt_flush; in intel_pt_process_auxtrace_info()
3888 pt->auxtrace.free_events = intel_pt_free_events; in intel_pt_process_auxtrace_info()
3889 pt->auxtrace.free = intel_pt_free; in intel_pt_process_auxtrace_info()
3890 pt->auxtrace.evsel_is_auxtrace = intel_pt_evsel_is_auxtrace; in intel_pt_process_auxtrace_info()
3891 session->auxtrace = &pt->auxtrace; in intel_pt_process_auxtrace_info()
3896 if (pt->have_sched_switch == 1) { in intel_pt_process_auxtrace_info()
3897 pt->switch_evsel = intel_pt_find_sched_switch(session->evlist); in intel_pt_process_auxtrace_info()
3898 if (!pt->switch_evsel) { in intel_pt_process_auxtrace_info()
3903 } else if (pt->have_sched_switch == 2 && in intel_pt_process_auxtrace_info()
3910 if (pt->synth_opts.log) in intel_pt_process_auxtrace_info()
3914 if (pt->tc.time_mult) { in intel_pt_process_auxtrace_info()
3915 u64 tsc_freq = intel_pt_ns_to_ticks(pt, 1000000000); in intel_pt_process_auxtrace_info()
3917 if (!pt->max_non_turbo_ratio) in intel_pt_process_auxtrace_info()
3918 pt->max_non_turbo_ratio = in intel_pt_process_auxtrace_info()
3922 pt->max_non_turbo_ratio); in intel_pt_process_auxtrace_info()
3923 pt->cbr2khz = tsc_freq / pt->max_non_turbo_ratio / 1000; in intel_pt_process_auxtrace_info()
3926 err = intel_pt_setup_time_ranges(pt, session->itrace_synth_opts); in intel_pt_process_auxtrace_info()
3930 if (pt->synth_opts.calls) in intel_pt_process_auxtrace_info()
3931 pt->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | in intel_pt_process_auxtrace_info()
3933 if (pt->synth_opts.returns) in intel_pt_process_auxtrace_info()
3934 pt->branches_filter |= PERF_IP_FLAG_RETURN | in intel_pt_process_auxtrace_info()
3937 if ((pt->synth_opts.callchain || pt->synth_opts.add_callchain) && in intel_pt_process_auxtrace_info()
3942 pt->synth_opts.callchain = false; in intel_pt_process_auxtrace_info()
3943 pt->synth_opts.add_callchain = false; in intel_pt_process_auxtrace_info()
3947 if (pt->synth_opts.add_callchain) { in intel_pt_process_auxtrace_info()
3948 err = intel_pt_callchain_init(pt); in intel_pt_process_auxtrace_info()
3953 if (pt->synth_opts.last_branch || pt->synth_opts.add_last_branch) { in intel_pt_process_auxtrace_info()
3954 pt->br_stack_sz = pt->synth_opts.last_branch_sz; in intel_pt_process_auxtrace_info()
3955 pt->br_stack_sz_plus = pt->br_stack_sz; in intel_pt_process_auxtrace_info()
3958 if (pt->synth_opts.add_last_branch) { in intel_pt_process_auxtrace_info()
3959 err = intel_pt_br_stack_init(pt); in intel_pt_process_auxtrace_info()
3969 if (intel_pt_tracing_kernel(pt)) in intel_pt_process_auxtrace_info()
3970 pt->br_stack_sz_plus += 1024; in intel_pt_process_auxtrace_info()
3972 pt->br_stack_sz_plus += 1; in intel_pt_process_auxtrace_info()
3975 pt->use_thread_stack = pt->synth_opts.callchain || in intel_pt_process_auxtrace_info()
3976 pt->synth_opts.add_callchain || in intel_pt_process_auxtrace_info()
3977 pt->synth_opts.thread_stack || in intel_pt_process_auxtrace_info()
3978 pt->synth_opts.last_branch || in intel_pt_process_auxtrace_info()
3979 pt->synth_opts.add_last_branch; in intel_pt_process_auxtrace_info()
3981 pt->callstack = pt->synth_opts.callchain || in intel_pt_process_auxtrace_info()
3982 pt->synth_opts.add_callchain || in intel_pt_process_auxtrace_info()
3983 pt->synth_opts.thread_stack; in intel_pt_process_auxtrace_info()
3985 err = intel_pt_synth_events(pt, session); in intel_pt_process_auxtrace_info()
3989 intel_pt_setup_pebs_events(pt); in intel_pt_process_auxtrace_info()
3991 if (pt->sampling_mode || list_empty(&session->auxtrace_index)) in intel_pt_process_auxtrace_info()
3994 err = auxtrace_queues__process_index(&pt->queues, session); in intel_pt_process_auxtrace_info()
3998 if (pt->queues.populated) in intel_pt_process_auxtrace_info()
3999 pt->data_queued = true; in intel_pt_process_auxtrace_info()
4001 if (pt->timeless_decoding) in intel_pt_process_auxtrace_info()
4007 zfree(&pt->chain); in intel_pt_process_auxtrace_info()
4008 thread__zput(pt->unknown_thread); in intel_pt_process_auxtrace_info()
4011 auxtrace_queues__free(&pt->queues); in intel_pt_process_auxtrace_info()
4014 addr_filters__exit(&pt->filts); in intel_pt_process_auxtrace_info()
4015 zfree(&pt->filter); in intel_pt_process_auxtrace_info()
4016 zfree(&pt->time_ranges); in intel_pt_process_auxtrace_info()
4017 free(pt); in intel_pt_process_auxtrace_info()