Lines Matching refs:pt

146 	struct intel_pt *pt;  member
185 static void intel_pt_dump(struct intel_pt *pt __maybe_unused, in intel_pt_dump()
225 static void intel_pt_dump_event(struct intel_pt *pt, unsigned char *buf, in intel_pt_dump_event() argument
229 intel_pt_dump(pt, buf, len); in intel_pt_dump_event()
245 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_dump_sample() local
249 intel_pt_dump(pt, sample->aux_sample.data, sample->aux_sample.size); in intel_pt_dump_sample()
252 static bool intel_pt_log_events(struct intel_pt *pt, u64 tm) in intel_pt_log_events() argument
254 struct perf_time_interval *range = pt->synth_opts.ptime_range; in intel_pt_log_events()
255 int n = pt->synth_opts.range_num; in intel_pt_log_events()
257 if (pt->synth_opts.log_plus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS) in intel_pt_log_events()
260 if (pt->synth_opts.log_minus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS) in intel_pt_log_events()
270 static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *a, in intel_pt_do_fix_overlap() argument
277 pt->have_tsc, &consecutive); in intel_pt_do_fix_overlap()
295 int fd = perf_data__fd(ptq->pt->session->data); in intel_pt_get_buffer()
302 might_overlap = ptq->pt->snapshot_mode || ptq->pt->sampling_mode; in intel_pt_get_buffer()
304 intel_pt_do_fix_overlap(ptq->pt, old_buffer, buffer)) in intel_pt_get_buffer()
346 queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; in intel_pt_lookahead()
396 queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; in intel_pt_get_trace()
552 static inline u8 intel_pt_cpumode(struct intel_pt *pt, uint64_t ip) in intel_pt_cpumode() argument
554 return ip >= pt->kernel_start ? in intel_pt_cpumode()
565 struct machine *machine = ptq->pt->machine; in intel_pt_walk_next_insn()
581 cpumode = intel_pt_cpumode(ptq->pt, *ip); in intel_pt_walk_next_insn()
587 thread = ptq->pt->unknown_thread; in intel_pt_walk_next_insn()
689 static bool intel_pt_match_pgd_ip(struct intel_pt *pt, uint64_t ip, in intel_pt_match_pgd_ip() argument
697 list_for_each_entry(filt, &pt->filts.head, list) { in intel_pt_match_pgd_ip()
735 if (ip >= ptq->pt->kernel_start) in __intel_pt_pgd_ip()
736 return intel_pt_match_pgd_ip(ptq->pt, ip, ip, NULL); in __intel_pt_pgd_ip()
749 return intel_pt_match_pgd_ip(ptq->pt, ip, offset, in __intel_pt_pgd_ip()
758 static bool intel_pt_get_config(struct intel_pt *pt, in intel_pt_get_config() argument
761 if (attr->type == pt->pmu_type) { in intel_pt_get_config()
770 static bool intel_pt_exclude_kernel(struct intel_pt *pt) in intel_pt_exclude_kernel() argument
774 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_exclude_kernel()
775 if (intel_pt_get_config(pt, &evsel->core.attr, NULL) && in intel_pt_exclude_kernel()
782 static bool intel_pt_return_compression(struct intel_pt *pt) in intel_pt_return_compression() argument
787 if (!pt->noretcomp_bit) in intel_pt_return_compression()
790 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_return_compression()
791 if (intel_pt_get_config(pt, &evsel->core.attr, &config) && in intel_pt_return_compression()
792 (config & pt->noretcomp_bit)) in intel_pt_return_compression()
798 static bool intel_pt_branch_enable(struct intel_pt *pt) in intel_pt_branch_enable() argument
803 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_branch_enable()
804 if (intel_pt_get_config(pt, &evsel->core.attr, &config) && in intel_pt_branch_enable()
811 static unsigned int intel_pt_mtc_period(struct intel_pt *pt) in intel_pt_mtc_period() argument
817 if (!pt->mtc_freq_bits) in intel_pt_mtc_period()
820 for (shift = 0, config = pt->mtc_freq_bits; !(config & 1); shift++) in intel_pt_mtc_period()
823 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_mtc_period()
824 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) in intel_pt_mtc_period()
825 return (config & pt->mtc_freq_bits) >> shift; in intel_pt_mtc_period()
830 static bool intel_pt_timeless_decoding(struct intel_pt *pt) in intel_pt_timeless_decoding() argument
836 if (!pt->tsc_bit || !pt->cap_user_time_zero) in intel_pt_timeless_decoding()
839 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_timeless_decoding()
842 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) { in intel_pt_timeless_decoding()
843 if (config & pt->tsc_bit) in intel_pt_timeless_decoding()
852 static bool intel_pt_tracing_kernel(struct intel_pt *pt) in intel_pt_tracing_kernel() argument
856 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_tracing_kernel()
857 if (intel_pt_get_config(pt, &evsel->core.attr, NULL) && in intel_pt_tracing_kernel()
864 static bool intel_pt_have_tsc(struct intel_pt *pt) in intel_pt_have_tsc() argument
870 if (!pt->tsc_bit) in intel_pt_have_tsc()
873 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_have_tsc()
874 if (intel_pt_get_config(pt, &evsel->core.attr, &config)) { in intel_pt_have_tsc()
875 if (config & pt->tsc_bit) in intel_pt_have_tsc()
884 static bool intel_pt_sampling_mode(struct intel_pt *pt) in intel_pt_sampling_mode() argument
888 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_sampling_mode()
896 static u64 intel_pt_ns_to_ticks(const struct intel_pt *pt, u64 ns) in intel_pt_ns_to_ticks() argument
900 quot = ns / pt->tc.time_mult; in intel_pt_ns_to_ticks()
901 rem = ns % pt->tc.time_mult; in intel_pt_ns_to_ticks()
902 return (quot << pt->tc.time_shift) + (rem << pt->tc.time_shift) / in intel_pt_ns_to_ticks()
903 pt->tc.time_mult; in intel_pt_ns_to_ticks()
906 static struct ip_callchain *intel_pt_alloc_chain(struct intel_pt *pt) in intel_pt_alloc_chain() argument
911 sz += (pt->synth_opts.callchain_sz + 1) * sizeof(u64); in intel_pt_alloc_chain()
915 static int intel_pt_callchain_init(struct intel_pt *pt) in intel_pt_callchain_init() argument
919 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_callchain_init()
924 pt->chain = intel_pt_alloc_chain(pt); in intel_pt_callchain_init()
925 if (!pt->chain) in intel_pt_callchain_init()
931 static void intel_pt_add_callchain(struct intel_pt *pt, in intel_pt_add_callchain() argument
934 struct thread *thread = machine__findnew_thread(pt->machine, in intel_pt_add_callchain()
938 thread_stack__sample_late(thread, sample->cpu, pt->chain, in intel_pt_add_callchain()
939 pt->synth_opts.callchain_sz + 1, sample->ip, in intel_pt_add_callchain()
940 pt->kernel_start); in intel_pt_add_callchain()
942 sample->callchain = pt->chain; in intel_pt_add_callchain()
953 static int intel_pt_br_stack_init(struct intel_pt *pt) in intel_pt_br_stack_init() argument
957 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_br_stack_init()
962 pt->br_stack = intel_pt_alloc_br_stack(pt->br_stack_sz); in intel_pt_br_stack_init()
963 if (!pt->br_stack) in intel_pt_br_stack_init()
969 static void intel_pt_add_br_stack(struct intel_pt *pt, in intel_pt_add_br_stack() argument
972 struct thread *thread = machine__findnew_thread(pt->machine, in intel_pt_add_br_stack()
976 thread_stack__br_sample_late(thread, sample->cpu, pt->br_stack, in intel_pt_add_br_stack()
977 pt->br_stack_sz, sample->ip, in intel_pt_add_br_stack()
978 pt->kernel_start); in intel_pt_add_br_stack()
980 sample->branch_stack = pt->br_stack; in intel_pt_add_br_stack()
986 static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, in intel_pt_alloc_queue() argument
990 struct perf_env *env = pt->machine->env; in intel_pt_alloc_queue()
997 if (pt->synth_opts.callchain) { in intel_pt_alloc_queue()
998 ptq->chain = intel_pt_alloc_chain(pt); in intel_pt_alloc_queue()
1003 if (pt->synth_opts.last_branch || pt->synth_opts.other_events) { in intel_pt_alloc_queue()
1004 unsigned int entry_cnt = max(LBRS_MAX, pt->br_stack_sz); in intel_pt_alloc_queue()
1015 ptq->pt = pt; in intel_pt_alloc_queue()
1017 ptq->exclude_kernel = intel_pt_exclude_kernel(pt); in intel_pt_alloc_queue()
1027 params.return_compression = intel_pt_return_compression(pt); in intel_pt_alloc_queue()
1028 params.branch_enable = intel_pt_branch_enable(pt); in intel_pt_alloc_queue()
1029 params.max_non_turbo_ratio = pt->max_non_turbo_ratio; in intel_pt_alloc_queue()
1030 params.mtc_period = intel_pt_mtc_period(pt); in intel_pt_alloc_queue()
1031 params.tsc_ctc_ratio_n = pt->tsc_ctc_ratio_n; in intel_pt_alloc_queue()
1032 params.tsc_ctc_ratio_d = pt->tsc_ctc_ratio_d; in intel_pt_alloc_queue()
1033 params.quick = pt->synth_opts.quick; in intel_pt_alloc_queue()
1035 if (pt->filts.cnt > 0) in intel_pt_alloc_queue()
1038 if (pt->synth_opts.instructions) { in intel_pt_alloc_queue()
1039 if (pt->synth_opts.period) { in intel_pt_alloc_queue()
1040 switch (pt->synth_opts.period_type) { in intel_pt_alloc_queue()
1044 params.period = pt->synth_opts.period; in intel_pt_alloc_queue()
1048 params.period = pt->synth_opts.period; in intel_pt_alloc_queue()
1052 params.period = intel_pt_ns_to_ticks(pt, in intel_pt_alloc_queue()
1053 pt->synth_opts.period); in intel_pt_alloc_queue()
1097 static void intel_pt_set_pid_tid_cpu(struct intel_pt *pt, in intel_pt_set_pid_tid_cpu() argument
1102 if (queue->tid == -1 || pt->have_sched_switch) { in intel_pt_set_pid_tid_cpu()
1103 ptq->tid = machine__get_current_tid(pt->machine, ptq->cpu); in intel_pt_set_pid_tid_cpu()
1110 ptq->thread = machine__find_thread(pt->machine, -1, ptq->tid); in intel_pt_set_pid_tid_cpu()
1150 static void intel_pt_setup_time_range(struct intel_pt *pt, in intel_pt_setup_time_range() argument
1153 if (!pt->range_cnt) in intel_pt_setup_time_range()
1156 ptq->sel_timestamp = pt->time_ranges[0].start; in intel_pt_setup_time_range()
1162 ptq->sel_timestamp = pt->time_ranges[0].end; in intel_pt_setup_time_range()
1167 static int intel_pt_setup_queue(struct intel_pt *pt, in intel_pt_setup_queue() argument
1177 ptq = intel_pt_alloc_queue(pt, queue_nr); in intel_pt_setup_queue()
1188 if (pt->sampling_mode && !pt->snapshot_mode && in intel_pt_setup_queue()
1189 pt->timeless_decoding) in intel_pt_setup_queue()
1192 ptq->sync_switch = pt->sync_switch; in intel_pt_setup_queue()
1194 intel_pt_setup_time_range(pt, ptq); in intel_pt_setup_queue()
1203 if (pt->timeless_decoding) in intel_pt_setup_queue()
1240 ret = auxtrace_heap__add(&pt->heap, queue_nr, ptq->timestamp); in intel_pt_setup_queue()
1249 static int intel_pt_setup_queues(struct intel_pt *pt) in intel_pt_setup_queues() argument
1254 for (i = 0; i < pt->queues.nr_queues; i++) { in intel_pt_setup_queues()
1255 ret = intel_pt_setup_queue(pt, &pt->queues.queue_array[i], i); in intel_pt_setup_queues()
1262 static inline bool intel_pt_skip_event(struct intel_pt *pt) in intel_pt_skip_event() argument
1264 return pt->synth_opts.initial_skip && in intel_pt_skip_event()
1265 pt->num_events++ < pt->synth_opts.initial_skip; in intel_pt_skip_event()
1273 static inline bool intel_pt_skip_cbr_event(struct intel_pt *pt) in intel_pt_skip_cbr_event() argument
1275 return pt->synth_opts.initial_skip && in intel_pt_skip_cbr_event()
1276 pt->num_events + 4 < pt->synth_opts.initial_skip; in intel_pt_skip_cbr_event()
1293 static void intel_pt_prep_b_sample(struct intel_pt *pt, in intel_pt_prep_b_sample() argument
1300 if (!pt->timeless_decoding) in intel_pt_prep_b_sample()
1301 sample->time = tsc_to_perf_time(ptq->timestamp, &pt->tc); in intel_pt_prep_b_sample()
1304 sample->cpumode = intel_pt_cpumode(pt, sample->ip); in intel_pt_prep_b_sample()
1319 static inline int intel_pt_opt_inject(struct intel_pt *pt, in intel_pt_opt_inject() argument
1323 if (!pt->synth_opts.inject) in intel_pt_opt_inject()
1329 static int intel_pt_deliver_synth_event(struct intel_pt *pt, in intel_pt_deliver_synth_event() argument
1335 ret = intel_pt_opt_inject(pt, event, sample, type); in intel_pt_deliver_synth_event()
1339 ret = perf_session__deliver_synth_event(pt->session, event, sample); in intel_pt_deliver_synth_event()
1348 struct intel_pt *pt = ptq->pt; in intel_pt_synth_branch_sample() local
1357 if (pt->branches_filter && !(pt->branches_filter & ptq->flags)) in intel_pt_synth_branch_sample()
1360 if (intel_pt_skip_event(pt)) in intel_pt_synth_branch_sample()
1363 intel_pt_prep_b_sample(pt, ptq, event, &sample); in intel_pt_synth_branch_sample()
1365 sample.id = ptq->pt->branches_id; in intel_pt_synth_branch_sample()
1366 sample.stream_id = ptq->pt->branches_id; in intel_pt_synth_branch_sample()
1372 if (pt->synth_opts.last_branch && sort__mode == SORT_MODE__BRANCH) { in intel_pt_synth_branch_sample()
1391 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_branch_sample()
1392 pt->branches_sample_type); in intel_pt_synth_branch_sample()
1395 static void intel_pt_prep_sample(struct intel_pt *pt, in intel_pt_prep_sample() argument
1400 intel_pt_prep_b_sample(pt, ptq, event, sample); in intel_pt_prep_sample()
1402 if (pt->synth_opts.callchain) { in intel_pt_prep_sample()
1404 pt->synth_opts.callchain_sz + 1, in intel_pt_prep_sample()
1405 sample->ip, pt->kernel_start); in intel_pt_prep_sample()
1409 if (pt->synth_opts.last_branch) { in intel_pt_prep_sample()
1411 pt->br_stack_sz); in intel_pt_prep_sample()
1418 struct intel_pt *pt = ptq->pt; in intel_pt_synth_instruction_sample() local
1422 if (intel_pt_skip_event(pt)) in intel_pt_synth_instruction_sample()
1425 intel_pt_prep_sample(pt, ptq, event, &sample); in intel_pt_synth_instruction_sample()
1427 sample.id = ptq->pt->instructions_id; in intel_pt_synth_instruction_sample()
1428 sample.stream_id = ptq->pt->instructions_id; in intel_pt_synth_instruction_sample()
1429 if (pt->synth_opts.quick) in intel_pt_synth_instruction_sample()
1443 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_instruction_sample()
1444 pt->instructions_sample_type); in intel_pt_synth_instruction_sample()
1449 struct intel_pt *pt = ptq->pt; in intel_pt_synth_transaction_sample() local
1453 if (intel_pt_skip_event(pt)) in intel_pt_synth_transaction_sample()
1456 intel_pt_prep_sample(pt, ptq, event, &sample); in intel_pt_synth_transaction_sample()
1458 sample.id = ptq->pt->transactions_id; in intel_pt_synth_transaction_sample()
1459 sample.stream_id = ptq->pt->transactions_id; in intel_pt_synth_transaction_sample()
1461 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_transaction_sample()
1462 pt->transactions_sample_type); in intel_pt_synth_transaction_sample()
1465 static void intel_pt_prep_p_sample(struct intel_pt *pt, in intel_pt_prep_p_sample() argument
1470 intel_pt_prep_sample(pt, ptq, event, sample); in intel_pt_prep_p_sample()
1482 struct intel_pt *pt = ptq->pt; in intel_pt_synth_ptwrite_sample() local
1487 if (intel_pt_skip_event(pt)) in intel_pt_synth_ptwrite_sample()
1490 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_ptwrite_sample()
1492 sample.id = ptq->pt->ptwrites_id; in intel_pt_synth_ptwrite_sample()
1493 sample.stream_id = ptq->pt->ptwrites_id; in intel_pt_synth_ptwrite_sample()
1502 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_ptwrite_sample()
1503 pt->ptwrites_sample_type); in intel_pt_synth_ptwrite_sample()
1508 struct intel_pt *pt = ptq->pt; in intel_pt_synth_cbr_sample() local
1514 if (intel_pt_skip_cbr_event(pt)) in intel_pt_synth_cbr_sample()
1519 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_cbr_sample()
1521 sample.id = ptq->pt->cbr_id; in intel_pt_synth_cbr_sample()
1522 sample.stream_id = ptq->pt->cbr_id; in intel_pt_synth_cbr_sample()
1524 flags = (u16)ptq->state->cbr_payload | (pt->max_non_turbo_ratio << 16); in intel_pt_synth_cbr_sample()
1526 raw.freq = cpu_to_le32(raw.cbr * pt->cbr2khz); in intel_pt_synth_cbr_sample()
1532 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_cbr_sample()
1533 pt->pwr_events_sample_type); in intel_pt_synth_cbr_sample()
1538 struct intel_pt *pt = ptq->pt; in intel_pt_synth_mwait_sample() local
1543 if (intel_pt_skip_event(pt)) in intel_pt_synth_mwait_sample()
1546 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_mwait_sample()
1548 sample.id = ptq->pt->mwait_id; in intel_pt_synth_mwait_sample()
1549 sample.stream_id = ptq->pt->mwait_id; in intel_pt_synth_mwait_sample()
1557 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_mwait_sample()
1558 pt->pwr_events_sample_type); in intel_pt_synth_mwait_sample()
1563 struct intel_pt *pt = ptq->pt; in intel_pt_synth_pwre_sample() local
1568 if (intel_pt_skip_event(pt)) in intel_pt_synth_pwre_sample()
1571 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_pwre_sample()
1573 sample.id = ptq->pt->pwre_id; in intel_pt_synth_pwre_sample()
1574 sample.stream_id = ptq->pt->pwre_id; in intel_pt_synth_pwre_sample()
1582 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_pwre_sample()
1583 pt->pwr_events_sample_type); in intel_pt_synth_pwre_sample()
1588 struct intel_pt *pt = ptq->pt; in intel_pt_synth_exstop_sample() local
1593 if (intel_pt_skip_event(pt)) in intel_pt_synth_exstop_sample()
1596 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_exstop_sample()
1598 sample.id = ptq->pt->exstop_id; in intel_pt_synth_exstop_sample()
1599 sample.stream_id = ptq->pt->exstop_id; in intel_pt_synth_exstop_sample()
1607 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_exstop_sample()
1608 pt->pwr_events_sample_type); in intel_pt_synth_exstop_sample()
1613 struct intel_pt *pt = ptq->pt; in intel_pt_synth_pwrx_sample() local
1618 if (intel_pt_skip_event(pt)) in intel_pt_synth_pwrx_sample()
1621 intel_pt_prep_p_sample(pt, ptq, event, &sample); in intel_pt_synth_pwrx_sample()
1623 sample.id = ptq->pt->pwrx_id; in intel_pt_synth_pwrx_sample()
1624 sample.stream_id = ptq->pt->pwrx_id; in intel_pt_synth_pwrx_sample()
1632 return intel_pt_deliver_synth_event(pt, event, &sample, in intel_pt_synth_pwrx_sample()
1633 pt->pwr_events_sample_type); in intel_pt_synth_pwrx_sample()
1768 struct intel_pt *pt = ptq->pt; in intel_pt_synth_pebs_sample() local
1769 struct evsel *evsel = pt->pebs_evsel; in intel_pt_synth_pebs_sample()
1775 if (intel_pt_skip_event(pt)) in intel_pt_synth_pebs_sample()
1795 cpumode = sample.ip < ptq->pt->kernel_start ? in intel_pt_synth_pebs_sample()
1808 else if (!pt->timeless_decoding) in intel_pt_synth_pebs_sample()
1811 sample.time = tsc_to_perf_time(timestamp, &pt->tc); in intel_pt_synth_pebs_sample()
1815 pt->synth_opts.callchain) { in intel_pt_synth_pebs_sample()
1817 pt->synth_opts.callchain_sz, sample.ip, in intel_pt_synth_pebs_sample()
1818 pt->kernel_start); in intel_pt_synth_pebs_sample()
1843 } else if (pt->synth_opts.last_branch) { in intel_pt_synth_pebs_sample()
1846 pt->br_stack_sz); in intel_pt_synth_pebs_sample()
1880 return intel_pt_deliver_synth_event(pt, event, &sample, sample_type); in intel_pt_synth_pebs_sample()
1883 static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu, in intel_pt_synth_error() argument
1890 if (pt->synth_opts.error_minus_flags) { in intel_pt_synth_error()
1892 pt->synth_opts.error_minus_flags & AUXTRACE_ERR_FLG_OVERFLOW) in intel_pt_synth_error()
1895 pt->synth_opts.error_minus_flags & AUXTRACE_ERR_FLG_DATA_LOST) in intel_pt_synth_error()
1904 err = perf_session__deliver_synth_event(pt->session, &event, NULL); in intel_pt_synth_error()
1915 struct intel_pt *pt = ptq->pt; in intel_ptq_synth_error() local
1918 tm = pt->timeless_decoding ? 0 : tsc_to_perf_time(tm, &pt->tc); in intel_ptq_synth_error()
1920 return intel_pt_synth_error(pt, state->err, ptq->cpu, ptq->pid, in intel_ptq_synth_error()
1924 static int intel_pt_next_tid(struct intel_pt *pt, struct intel_pt_queue *ptq) in intel_pt_next_tid() argument
1935 err = machine__set_current_tid(pt->machine, ptq->cpu, -1, tid); in intel_pt_next_tid()
1937 queue = &pt->queues.queue_array[ptq->queue_nr]; in intel_pt_next_tid()
1938 intel_pt_set_pid_tid_cpu(pt, queue); in intel_pt_next_tid()
1947 struct intel_pt *pt = ptq->pt; in intel_pt_is_switch_ip() local
1949 return ip == pt->switch_ip && in intel_pt_is_switch_ip()
1961 struct intel_pt *pt = ptq->pt; in intel_pt_sample() local
1982 if (pt->sample_pebs && state->type & INTEL_PT_BLK_ITEMS) { in intel_pt_sample()
1988 if (pt->sample_pwr_events) { in intel_pt_sample()
2018 if (pt->sample_instructions && (state->type & INTEL_PT_INSTRUCTION)) { in intel_pt_sample()
2024 if (pt->sample_transactions && (state->type & INTEL_PT_TRANSACTION)) { in intel_pt_sample()
2030 if (pt->sample_ptwrites && (state->type & INTEL_PT_PTW)) { in intel_pt_sample()
2039 if (pt->use_thread_stack) { in intel_pt_sample()
2042 state->trace_nr, pt->callstack, in intel_pt_sample()
2043 pt->br_stack_sz_plus, in intel_pt_sample()
2044 pt->mispred_all); in intel_pt_sample()
2049 if (pt->sample_branches) { in intel_pt_sample()
2063 err = intel_pt_next_tid(pt, ptq); in intel_pt_sample()
2077 state->to_ip == pt->ptss_ip && in intel_pt_sample()
2085 static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip) in intel_pt_switch_ip() argument
2087 struct machine *machine = pt->machine; in intel_pt_switch_ip()
2119 if (pt->have_sched_switch == 1) in intel_pt_switch_ip()
2137 static void intel_pt_enable_sync_switch(struct intel_pt *pt) in intel_pt_enable_sync_switch() argument
2141 pt->sync_switch = true; in intel_pt_enable_sync_switch()
2143 for (i = 0; i < pt->queues.nr_queues; i++) { in intel_pt_enable_sync_switch()
2144 struct auxtrace_queue *queue = &pt->queues.queue_array[i]; in intel_pt_enable_sync_switch()
2158 struct intel_pt *pt = ptq->pt; in intel_pt_next_time() local
2163 ptq->sel_timestamp = pt->time_ranges[ptq->sel_idx].end; in intel_pt_next_time()
2165 } else if (ptq->sel_idx + 1 < pt->range_cnt) { in intel_pt_next_time()
2169 ptq->sel_timestamp = pt->time_ranges[ptq->sel_idx].start; in intel_pt_next_time()
2197 intel_pt_next_tid(ptq->pt, ptq); in intel_pt_time_filter()
2227 struct intel_pt *pt = ptq->pt; in intel_pt_run_decoder() local
2231 if (!pt->kernel_start) { in intel_pt_run_decoder()
2232 pt->kernel_start = machine__kernel_start(pt->machine); in intel_pt_run_decoder()
2233 if (pt->per_cpu_mmaps && in intel_pt_run_decoder()
2234 (pt->have_sched_switch == 1 || pt->have_sched_switch == 3) && in intel_pt_run_decoder()
2235 !pt->timeless_decoding && intel_pt_tracing_kernel(pt) && in intel_pt_run_decoder()
2236 !pt->sampling_mode) { in intel_pt_run_decoder()
2237 pt->switch_ip = intel_pt_switch_ip(pt, &pt->ptss_ip); in intel_pt_run_decoder()
2238 if (pt->switch_ip) { in intel_pt_run_decoder()
2240 pt->switch_ip, pt->ptss_ip); in intel_pt_run_decoder()
2241 intel_pt_enable_sync_switch(pt); in intel_pt_run_decoder()
2258 state->from_ip >= pt->kernel_start) { in intel_pt_run_decoder()
2260 intel_pt_next_tid(pt, ptq); in intel_pt_run_decoder()
2262 if (pt->synth_opts.errors) { in intel_pt_run_decoder()
2275 if (pt->est_tsc && in intel_pt_run_decoder()
2276 (state->from_ip >= pt->kernel_start || !state->from_ip) && in intel_pt_run_decoder()
2277 state->to_ip && state->to_ip < pt->kernel_start) { in intel_pt_run_decoder()
2299 if (!pt->timeless_decoding && ptq->timestamp >= *timestamp) { in intel_pt_run_decoder()
2307 static inline int intel_pt_update_queues(struct intel_pt *pt) in intel_pt_update_queues() argument
2309 if (pt->queues.new_data) { in intel_pt_update_queues()
2310 pt->queues.new_data = false; in intel_pt_update_queues()
2311 return intel_pt_setup_queues(pt); in intel_pt_update_queues()
2316 static int intel_pt_process_queues(struct intel_pt *pt, u64 timestamp) in intel_pt_process_queues() argument
2326 if (!pt->heap.heap_cnt) in intel_pt_process_queues()
2329 if (pt->heap.heap_array[0].ordinal >= timestamp) in intel_pt_process_queues()
2332 queue_nr = pt->heap.heap_array[0].queue_nr; in intel_pt_process_queues()
2333 queue = &pt->queues.queue_array[queue_nr]; in intel_pt_process_queues()
2337 queue_nr, pt->heap.heap_array[0].ordinal, in intel_pt_process_queues()
2340 auxtrace_heap__pop(&pt->heap); in intel_pt_process_queues()
2342 if (pt->heap.heap_cnt) { in intel_pt_process_queues()
2343 ts = pt->heap.heap_array[0].ordinal + 1; in intel_pt_process_queues()
2350 intel_pt_set_pid_tid_cpu(pt, queue); in intel_pt_process_queues()
2355 auxtrace_heap__add(&pt->heap, queue_nr, ts); in intel_pt_process_queues()
2360 ret = auxtrace_heap__add(&pt->heap, queue_nr, ts); in intel_pt_process_queues()
2371 static int intel_pt_process_timeless_queues(struct intel_pt *pt, pid_t tid, in intel_pt_process_timeless_queues() argument
2374 struct auxtrace_queues *queues = &pt->queues; in intel_pt_process_timeless_queues()
2379 struct auxtrace_queue *queue = &pt->queues.queue_array[i]; in intel_pt_process_timeless_queues()
2384 intel_pt_set_pid_tid_cpu(pt, queue); in intel_pt_process_timeless_queues()
2395 struct machine *m = ptq->pt->machine; in intel_pt_sample_set_pid_tid_cpu()
2419 static int intel_pt_process_timeless_sample(struct intel_pt *pt, in intel_pt_process_timeless_sample() argument
2426 queue = auxtrace_queues__sample_queue(&pt->queues, sample, pt->session); in intel_pt_process_timeless_sample()
2441 static int intel_pt_lost(struct intel_pt *pt, struct perf_sample *sample) in intel_pt_lost() argument
2443 return intel_pt_synth_error(pt, INTEL_PT_ERR_LOST, sample->cpu, in intel_pt_lost()
2447 static struct intel_pt_queue *intel_pt_cpu_to_ptq(struct intel_pt *pt, int cpu) in intel_pt_cpu_to_ptq() argument
2451 if (cpu < 0 || !pt->queues.nr_queues) in intel_pt_cpu_to_ptq()
2454 if ((unsigned)cpu >= pt->queues.nr_queues) in intel_pt_cpu_to_ptq()
2455 i = pt->queues.nr_queues - 1; in intel_pt_cpu_to_ptq()
2459 if (pt->queues.queue_array[i].cpu == cpu) in intel_pt_cpu_to_ptq()
2460 return pt->queues.queue_array[i].priv; in intel_pt_cpu_to_ptq()
2463 if (pt->queues.queue_array[--i].cpu == cpu) in intel_pt_cpu_to_ptq()
2464 return pt->queues.queue_array[i].priv; in intel_pt_cpu_to_ptq()
2467 for (; j < pt->queues.nr_queues; j++) { in intel_pt_cpu_to_ptq()
2468 if (pt->queues.queue_array[j].cpu == cpu) in intel_pt_cpu_to_ptq()
2469 return pt->queues.queue_array[j].priv; in intel_pt_cpu_to_ptq()
2475 static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid, in intel_pt_sync_switch() argument
2481 if (!pt->sync_switch) in intel_pt_sync_switch()
2484 ptq = intel_pt_cpu_to_ptq(pt, cpu); in intel_pt_sync_switch()
2499 &pt->tc); in intel_pt_sync_switch()
2500 err = auxtrace_heap__add(&pt->heap, ptq->queue_nr, in intel_pt_sync_switch()
2520 static int intel_pt_process_switch(struct intel_pt *pt, in intel_pt_process_switch() argument
2527 evsel = perf_evlist__id2evsel(pt->session->evlist, sample->id); in intel_pt_process_switch()
2528 if (evsel != pt->switch_evsel) in intel_pt_process_switch()
2536 &pt->tc)); in intel_pt_process_switch()
2538 ret = intel_pt_sync_switch(pt, cpu, tid, sample->time); in intel_pt_process_switch()
2542 return machine__set_current_tid(pt->machine, cpu, -1, tid); in intel_pt_process_switch()
2545 static int intel_pt_context_switch_in(struct intel_pt *pt, in intel_pt_context_switch_in() argument
2552 if (pt->sync_switch) { in intel_pt_context_switch_in()
2555 ptq = intel_pt_cpu_to_ptq(pt, cpu); in intel_pt_context_switch_in()
2577 if (machine__get_current_tid(pt->machine, cpu) == tid) in intel_pt_context_switch_in()
2580 return machine__set_current_tid(pt->machine, cpu, pid, tid); in intel_pt_context_switch_in()
2583 static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event, in intel_pt_context_switch() argument
2592 if (pt->have_sched_switch == 3) { in intel_pt_context_switch()
2594 return intel_pt_context_switch_in(pt, sample); in intel_pt_context_switch()
2611 ret = intel_pt_sync_switch(pt, cpu, tid, sample->time); in intel_pt_context_switch()
2615 return machine__set_current_tid(pt->machine, cpu, pid, tid); in intel_pt_context_switch()
2618 static int intel_pt_process_itrace_start(struct intel_pt *pt, in intel_pt_process_itrace_start() argument
2622 if (!pt->per_cpu_mmaps) in intel_pt_process_itrace_start()
2628 perf_time_to_tsc(sample->time, &pt->tc)); in intel_pt_process_itrace_start()
2630 return machine__set_current_tid(pt->machine, sample->cpu, in intel_pt_process_itrace_start()
2647 static int intel_pt_text_poke(struct intel_pt *pt, union perf_event *event) in intel_pt_text_poke() argument
2653 struct thread *thread = pt->unknown_thread; in intel_pt_text_poke()
2655 struct machine *machine = pt->machine; in intel_pt_text_poke()
2701 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_process_event() local
2715 timestamp = perf_time_to_tsc(sample->time, &pt->tc); in intel_pt_process_event()
2719 if (timestamp || pt->timeless_decoding) { in intel_pt_process_event()
2720 err = intel_pt_update_queues(pt); in intel_pt_process_event()
2725 if (pt->timeless_decoding) { in intel_pt_process_event()
2726 if (pt->sampling_mode) { in intel_pt_process_event()
2728 err = intel_pt_process_timeless_sample(pt, in intel_pt_process_event()
2731 err = intel_pt_process_timeless_queues(pt, in intel_pt_process_event()
2736 err = intel_pt_process_queues(pt, timestamp); in intel_pt_process_event()
2742 if (pt->synth_opts.add_callchain && !sample->callchain) in intel_pt_process_event()
2743 intel_pt_add_callchain(pt, sample); in intel_pt_process_event()
2744 if (pt->synth_opts.add_last_branch && !sample->branch_stack) in intel_pt_process_event()
2745 intel_pt_add_br_stack(pt, sample); in intel_pt_process_event()
2750 pt->synth_opts.errors) { in intel_pt_process_event()
2751 err = intel_pt_lost(pt, sample); in intel_pt_process_event()
2756 if (pt->switch_evsel && event->header.type == PERF_RECORD_SAMPLE) in intel_pt_process_event()
2757 err = intel_pt_process_switch(pt, sample); in intel_pt_process_event()
2759 err = intel_pt_process_itrace_start(pt, event, sample); in intel_pt_process_event()
2762 err = intel_pt_context_switch(pt, event, sample); in intel_pt_process_event()
2765 err = intel_pt_text_poke(pt, event); in intel_pt_process_event()
2767 if (intel_pt_enable_logging && intel_pt_log_events(pt, sample->time)) { in intel_pt_process_event()
2778 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_flush() local
2788 ret = intel_pt_update_queues(pt); in intel_pt_flush()
2792 if (pt->timeless_decoding) in intel_pt_flush()
2793 return intel_pt_process_timeless_queues(pt, -1, in intel_pt_flush()
2796 return intel_pt_process_queues(pt, MAX_TIMESTAMP); in intel_pt_flush()
2801 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_free_events() local
2803 struct auxtrace_queues *queues = &pt->queues; in intel_pt_free_events()
2816 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_free() local
2819 auxtrace_heap__free(&pt->heap); in intel_pt_free()
2822 thread__put(pt->unknown_thread); in intel_pt_free()
2823 addr_filters__exit(&pt->filts); in intel_pt_free()
2824 zfree(&pt->chain); in intel_pt_free()
2825 zfree(&pt->filter); in intel_pt_free()
2826 zfree(&pt->time_ranges); in intel_pt_free()
2827 free(pt); in intel_pt_free()
2833 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_evsel_is_auxtrace() local
2836 return evsel->core.attr.type == pt->pmu_type; in intel_pt_evsel_is_auxtrace()
2843 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_process_auxtrace_event() local
2846 if (!pt->data_queued) { in intel_pt_process_auxtrace_event()
2860 err = auxtrace_queues__add_event(&pt->queues, session, event, in intel_pt_process_auxtrace_event()
2868 intel_pt_dump_event(pt, buffer->data, in intel_pt_process_auxtrace_event()
2882 struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, in intel_pt_queue_data() local
2887 return auxtrace_queues__add_event(&pt->queues, session, event, in intel_pt_queue_data()
2892 timestamp = perf_time_to_tsc(sample->time, &pt->tc); in intel_pt_queue_data()
2896 return auxtrace_queues__add_sample(&pt->queues, session, sample, in intel_pt_queue_data()
2953 static struct evsel *intel_pt_evsel(struct intel_pt *pt, in intel_pt_evsel() argument
2959 if (evsel->core.attr.type == pt->pmu_type && evsel->core.ids) in intel_pt_evsel()
2966 static int intel_pt_synth_events(struct intel_pt *pt, in intel_pt_synth_events() argument
2970 struct evsel *evsel = intel_pt_evsel(pt, evlist); in intel_pt_synth_events()
2986 if (pt->timeless_decoding) in intel_pt_synth_events()
2990 if (!pt->per_cpu_mmaps) in intel_pt_synth_events()
3004 if (pt->synth_opts.branches) { in intel_pt_synth_events()
3011 pt->sample_branches = true; in intel_pt_synth_events()
3012 pt->branches_sample_type = attr.sample_type; in intel_pt_synth_events()
3013 pt->branches_id = id; in intel_pt_synth_events()
3018 if (pt->synth_opts.callchain) in intel_pt_synth_events()
3020 if (pt->synth_opts.last_branch) { in intel_pt_synth_events()
3030 if (pt->synth_opts.instructions) { in intel_pt_synth_events()
3032 if (pt->synth_opts.period_type == PERF_ITRACE_PERIOD_NANOSECS) in intel_pt_synth_events()
3034 intel_pt_ns_to_ticks(pt, pt->synth_opts.period); in intel_pt_synth_events()
3036 attr.sample_period = pt->synth_opts.period; in intel_pt_synth_events()
3040 pt->sample_instructions = true; in intel_pt_synth_events()
3041 pt->instructions_sample_type = attr.sample_type; in intel_pt_synth_events()
3042 pt->instructions_id = id; in intel_pt_synth_events()
3049 if (pt->synth_opts.transactions) { in intel_pt_synth_events()
3054 pt->sample_transactions = true; in intel_pt_synth_events()
3055 pt->transactions_sample_type = attr.sample_type; in intel_pt_synth_events()
3056 pt->transactions_id = id; in intel_pt_synth_events()
3064 if (pt->synth_opts.ptwrites) { in intel_pt_synth_events()
3069 pt->sample_ptwrites = true; in intel_pt_synth_events()
3070 pt->ptwrites_sample_type = attr.sample_type; in intel_pt_synth_events()
3071 pt->ptwrites_id = id; in intel_pt_synth_events()
3076 if (pt->synth_opts.pwr_events) { in intel_pt_synth_events()
3077 pt->sample_pwr_events = true; in intel_pt_synth_events()
3078 pt->pwr_events_sample_type = attr.sample_type; in intel_pt_synth_events()
3084 pt->cbr_id = id; in intel_pt_synth_events()
3089 if (pt->synth_opts.pwr_events && (evsel->core.attr.config & 0x10)) { in intel_pt_synth_events()
3094 pt->mwait_id = id; in intel_pt_synth_events()
3102 pt->pwre_id = id; in intel_pt_synth_events()
3110 pt->exstop_id = id; in intel_pt_synth_events()
3118 pt->pwrx_id = id; in intel_pt_synth_events()
3126 static void intel_pt_setup_pebs_events(struct intel_pt *pt) in intel_pt_setup_pebs_events() argument
3130 if (!pt->synth_opts.other_events) in intel_pt_setup_pebs_events()
3133 evlist__for_each_entry(pt->session->evlist, evsel) { in intel_pt_setup_pebs_events()
3135 pt->sample_pebs = true; in intel_pt_setup_pebs_events()
3136 pt->pebs_evsel = evsel; in intel_pt_setup_pebs_events()
3170 struct intel_pt *pt = data; in intel_pt_perf_config() local
3173 pt->mispred_all = perf_config_bool(var, value); in intel_pt_perf_config()
3179 static u64 intel_pt_tsc_start(u64 ns, struct intel_pt *pt) in intel_pt_tsc_start() argument
3183 tsc = perf_time_to_tsc(ns, &pt->tc); in intel_pt_tsc_start()
3186 tm = tsc_to_perf_time(tsc, &pt->tc); in intel_pt_tsc_start()
3193 tm = tsc_to_perf_time(++tsc, &pt->tc); in intel_pt_tsc_start()
3199 static u64 intel_pt_tsc_end(u64 ns, struct intel_pt *pt) in intel_pt_tsc_end() argument
3203 tsc = perf_time_to_tsc(ns, &pt->tc); in intel_pt_tsc_end()
3206 tm = tsc_to_perf_time(tsc, &pt->tc); in intel_pt_tsc_end()
3213 tm = tsc_to_perf_time(--tsc, &pt->tc); in intel_pt_tsc_end()
3218 static int intel_pt_setup_time_ranges(struct intel_pt *pt, in intel_pt_setup_time_ranges() argument
3225 if (!n || !p || pt->timeless_decoding) in intel_pt_setup_time_ranges()
3228 pt->time_ranges = calloc(n, sizeof(struct range)); in intel_pt_setup_time_ranges()
3229 if (!pt->time_ranges) in intel_pt_setup_time_ranges()
3232 pt->range_cnt = n; in intel_pt_setup_time_ranges()
3237 struct range *r = &pt->time_ranges[i]; in intel_pt_setup_time_ranges()
3245 r->start = ts ? intel_pt_tsc_start(ts, pt) : 0; in intel_pt_setup_time_ranges()
3246 r->end = te ? intel_pt_tsc_end(te, pt) : 0; in intel_pt_setup_time_ranges()
3306 struct intel_pt *pt; in intel_pt_process_auxtrace_info() local
3315 pt = zalloc(sizeof(struct intel_pt)); in intel_pt_process_auxtrace_info()
3316 if (!pt) in intel_pt_process_auxtrace_info()
3319 addr_filters__init(&pt->filts); in intel_pt_process_auxtrace_info()
3321 err = perf_config(intel_pt_perf_config, pt); in intel_pt_process_auxtrace_info()
3325 err = auxtrace_queues__init(&pt->queues); in intel_pt_process_auxtrace_info()
3331 pt->session = session; in intel_pt_process_auxtrace_info()
3332 pt->machine = &session->machines.host; /* No kvm support */ in intel_pt_process_auxtrace_info()
3333 pt->auxtrace_type = auxtrace_info->type; in intel_pt_process_auxtrace_info()
3334 pt->pmu_type = auxtrace_info->priv[INTEL_PT_PMU_TYPE]; in intel_pt_process_auxtrace_info()
3335 pt->tc.time_shift = auxtrace_info->priv[INTEL_PT_TIME_SHIFT]; in intel_pt_process_auxtrace_info()
3336 pt->tc.time_mult = auxtrace_info->priv[INTEL_PT_TIME_MULT]; in intel_pt_process_auxtrace_info()
3337 pt->tc.time_zero = auxtrace_info->priv[INTEL_PT_TIME_ZERO]; in intel_pt_process_auxtrace_info()
3338 pt->cap_user_time_zero = auxtrace_info->priv[INTEL_PT_CAP_USER_TIME_ZERO]; in intel_pt_process_auxtrace_info()
3339 pt->tsc_bit = auxtrace_info->priv[INTEL_PT_TSC_BIT]; in intel_pt_process_auxtrace_info()
3340 pt->noretcomp_bit = auxtrace_info->priv[INTEL_PT_NORETCOMP_BIT]; in intel_pt_process_auxtrace_info()
3341 pt->have_sched_switch = auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH]; in intel_pt_process_auxtrace_info()
3342 pt->snapshot_mode = auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE]; in intel_pt_process_auxtrace_info()
3343 pt->per_cpu_mmaps = auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS]; in intel_pt_process_auxtrace_info()
3348 pt->mtc_bit = auxtrace_info->priv[INTEL_PT_MTC_BIT]; in intel_pt_process_auxtrace_info()
3349 pt->mtc_freq_bits = auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS]; in intel_pt_process_auxtrace_info()
3350 pt->tsc_ctc_ratio_n = auxtrace_info->priv[INTEL_PT_TSC_CTC_N]; in intel_pt_process_auxtrace_info()
3351 pt->tsc_ctc_ratio_d = auxtrace_info->priv[INTEL_PT_TSC_CTC_D]; in intel_pt_process_auxtrace_info()
3352 pt->cyc_bit = auxtrace_info->priv[INTEL_PT_CYC_BIT]; in intel_pt_process_auxtrace_info()
3358 pt->max_non_turbo_ratio = in intel_pt_process_auxtrace_info()
3385 pt->filter = memdup(filter, len); in intel_pt_process_auxtrace_info()
3386 if (!pt->filter) { in intel_pt_process_auxtrace_info()
3391 mem_bswap_64(pt->filter, len); in intel_pt_process_auxtrace_info()
3392 if (pt->filter[len - 1]) { in intel_pt_process_auxtrace_info()
3397 err = addr_filters__parse_bare_filter(&pt->filts, in intel_pt_process_auxtrace_info()
3402 intel_pt_print_info_str("Filter string", pt->filter); in intel_pt_process_auxtrace_info()
3405 pt->timeless_decoding = intel_pt_timeless_decoding(pt); in intel_pt_process_auxtrace_info()
3406 if (pt->timeless_decoding && !pt->tc.time_mult) in intel_pt_process_auxtrace_info()
3407 pt->tc.time_mult = 1; in intel_pt_process_auxtrace_info()
3408 pt->have_tsc = intel_pt_have_tsc(pt); in intel_pt_process_auxtrace_info()
3409 pt->sampling_mode = intel_pt_sampling_mode(pt); in intel_pt_process_auxtrace_info()
3410 pt->est_tsc = !pt->timeless_decoding; in intel_pt_process_auxtrace_info()
3412 pt->unknown_thread = thread__new(999999999, 999999999); in intel_pt_process_auxtrace_info()
3413 if (!pt->unknown_thread) { in intel_pt_process_auxtrace_info()
3424 INIT_LIST_HEAD(&pt->unknown_thread->node); in intel_pt_process_auxtrace_info()
3426 err = thread__set_comm(pt->unknown_thread, "unknown", 0); in intel_pt_process_auxtrace_info()
3429 if (thread__init_maps(pt->unknown_thread, pt->machine)) { in intel_pt_process_auxtrace_info()
3434 pt->auxtrace.process_event = intel_pt_process_event; in intel_pt_process_auxtrace_info()
3435 pt->auxtrace.process_auxtrace_event = intel_pt_process_auxtrace_event; in intel_pt_process_auxtrace_info()
3436 pt->auxtrace.queue_data = intel_pt_queue_data; in intel_pt_process_auxtrace_info()
3437 pt->auxtrace.dump_auxtrace_sample = intel_pt_dump_sample; in intel_pt_process_auxtrace_info()
3438 pt->auxtrace.flush_events = intel_pt_flush; in intel_pt_process_auxtrace_info()
3439 pt->auxtrace.free_events = intel_pt_free_events; in intel_pt_process_auxtrace_info()
3440 pt->auxtrace.free = intel_pt_free; in intel_pt_process_auxtrace_info()
3441 pt->auxtrace.evsel_is_auxtrace = intel_pt_evsel_is_auxtrace; in intel_pt_process_auxtrace_info()
3442 session->auxtrace = &pt->auxtrace; in intel_pt_process_auxtrace_info()
3447 if (pt->have_sched_switch == 1) { in intel_pt_process_auxtrace_info()
3448 pt->switch_evsel = intel_pt_find_sched_switch(session->evlist); in intel_pt_process_auxtrace_info()
3449 if (!pt->switch_evsel) { in intel_pt_process_auxtrace_info()
3454 } else if (pt->have_sched_switch == 2 && in intel_pt_process_auxtrace_info()
3462 pt->synth_opts = *session->itrace_synth_opts; in intel_pt_process_auxtrace_info()
3464 itrace_synth_opts__set_default(&pt->synth_opts, in intel_pt_process_auxtrace_info()
3468 pt->synth_opts.branches = false; in intel_pt_process_auxtrace_info()
3469 pt->synth_opts.callchain = true; in intel_pt_process_auxtrace_info()
3470 pt->synth_opts.add_callchain = true; in intel_pt_process_auxtrace_info()
3472 pt->synth_opts.thread_stack = in intel_pt_process_auxtrace_info()
3476 if (pt->synth_opts.log) in intel_pt_process_auxtrace_info()
3480 if (pt->tc.time_mult) { in intel_pt_process_auxtrace_info()
3481 u64 tsc_freq = intel_pt_ns_to_ticks(pt, 1000000000); in intel_pt_process_auxtrace_info()
3483 if (!pt->max_non_turbo_ratio) in intel_pt_process_auxtrace_info()
3484 pt->max_non_turbo_ratio = in intel_pt_process_auxtrace_info()
3488 pt->max_non_turbo_ratio); in intel_pt_process_auxtrace_info()
3489 pt->cbr2khz = tsc_freq / pt->max_non_turbo_ratio / 1000; in intel_pt_process_auxtrace_info()
3492 err = intel_pt_setup_time_ranges(pt, session->itrace_synth_opts); in intel_pt_process_auxtrace_info()
3496 if (pt->synth_opts.calls) in intel_pt_process_auxtrace_info()
3497 pt->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | in intel_pt_process_auxtrace_info()
3499 if (pt->synth_opts.returns) in intel_pt_process_auxtrace_info()
3500 pt->branches_filter |= PERF_IP_FLAG_RETURN | in intel_pt_process_auxtrace_info()
3503 if ((pt->synth_opts.callchain || pt->synth_opts.add_callchain) && in intel_pt_process_auxtrace_info()
3508 pt->synth_opts.callchain = false; in intel_pt_process_auxtrace_info()
3509 pt->synth_opts.add_callchain = false; in intel_pt_process_auxtrace_info()
3513 if (pt->synth_opts.add_callchain) { in intel_pt_process_auxtrace_info()
3514 err = intel_pt_callchain_init(pt); in intel_pt_process_auxtrace_info()
3519 if (pt->synth_opts.last_branch || pt->synth_opts.add_last_branch) { in intel_pt_process_auxtrace_info()
3520 pt->br_stack_sz = pt->synth_opts.last_branch_sz; in intel_pt_process_auxtrace_info()
3521 pt->br_stack_sz_plus = pt->br_stack_sz; in intel_pt_process_auxtrace_info()
3524 if (pt->synth_opts.add_last_branch) { in intel_pt_process_auxtrace_info()
3525 err = intel_pt_br_stack_init(pt); in intel_pt_process_auxtrace_info()
3535 if (intel_pt_tracing_kernel(pt)) in intel_pt_process_auxtrace_info()
3536 pt->br_stack_sz_plus += 1024; in intel_pt_process_auxtrace_info()
3538 pt->br_stack_sz_plus += 1; in intel_pt_process_auxtrace_info()
3541 pt->use_thread_stack = pt->synth_opts.callchain || in intel_pt_process_auxtrace_info()
3542 pt->synth_opts.add_callchain || in intel_pt_process_auxtrace_info()
3543 pt->synth_opts.thread_stack || in intel_pt_process_auxtrace_info()
3544 pt->synth_opts.last_branch || in intel_pt_process_auxtrace_info()
3545 pt->synth_opts.add_last_branch; in intel_pt_process_auxtrace_info()
3547 pt->callstack = pt->synth_opts.callchain || in intel_pt_process_auxtrace_info()
3548 pt->synth_opts.add_callchain || in intel_pt_process_auxtrace_info()
3549 pt->synth_opts.thread_stack; in intel_pt_process_auxtrace_info()
3551 err = intel_pt_synth_events(pt, session); in intel_pt_process_auxtrace_info()
3555 intel_pt_setup_pebs_events(pt); in intel_pt_process_auxtrace_info()
3557 if (pt->sampling_mode || list_empty(&session->auxtrace_index)) in intel_pt_process_auxtrace_info()
3560 err = auxtrace_queues__process_index(&pt->queues, session); in intel_pt_process_auxtrace_info()
3564 if (pt->queues.populated) in intel_pt_process_auxtrace_info()
3565 pt->data_queued = true; in intel_pt_process_auxtrace_info()
3567 if (pt->timeless_decoding) in intel_pt_process_auxtrace_info()
3573 zfree(&pt->chain); in intel_pt_process_auxtrace_info()
3574 thread__zput(pt->unknown_thread); in intel_pt_process_auxtrace_info()
3577 auxtrace_queues__free(&pt->queues); in intel_pt_process_auxtrace_info()
3580 addr_filters__exit(&pt->filts); in intel_pt_process_auxtrace_info()
3581 zfree(&pt->filter); in intel_pt_process_auxtrace_info()
3582 zfree(&pt->time_ranges); in intel_pt_process_auxtrace_info()
3583 free(pt); in intel_pt_process_auxtrace_info()