Lines Matching refs:bts

74 	struct intel_bts	*bts;  member
93 static void intel_bts_dump(struct intel_bts *bts __maybe_unused, in intel_bts_dump()
131 static void intel_bts_dump_event(struct intel_bts *bts, unsigned char *buf, in intel_bts_dump_event() argument
135 intel_bts_dump(bts, buf, len); in intel_bts_dump_event()
138 static int intel_bts_lost(struct intel_bts *bts, struct perf_sample *sample) in intel_bts_lost() argument
147 err = perf_session__deliver_synth_event(bts->session, &event, NULL); in intel_bts_lost()
155 static struct intel_bts_queue *intel_bts_alloc_queue(struct intel_bts *bts, in intel_bts_alloc_queue() argument
164 btsq->bts = bts; in intel_bts_alloc_queue()
173 static int intel_bts_setup_queue(struct intel_bts *bts, in intel_bts_setup_queue() argument
183 btsq = intel_bts_alloc_queue(bts, queue_nr); in intel_bts_setup_queue()
193 if (bts->sampling_mode) in intel_bts_setup_queue()
203 ret = auxtrace_heap__add(&bts->heap, queue_nr, in intel_bts_setup_queue()
213 static int intel_bts_setup_queues(struct intel_bts *bts) in intel_bts_setup_queues() argument
218 for (i = 0; i < bts->queues.nr_queues; i++) { in intel_bts_setup_queues()
219 ret = intel_bts_setup_queue(bts, &bts->queues.queue_array[i], in intel_bts_setup_queues()
227 static inline int intel_bts_update_queues(struct intel_bts *bts) in intel_bts_update_queues() argument
229 if (bts->queues.new_data) { in intel_bts_update_queues()
230 bts->queues.new_data = false; in intel_bts_update_queues()
231 return intel_bts_setup_queues(bts); in intel_bts_update_queues()
276 struct intel_bts *bts = btsq->bts; in intel_bts_synth_branch_sample() local
280 if (bts->synth_opts.initial_skip && in intel_bts_synth_branch_sample()
281 bts->num_events++ <= bts->synth_opts.initial_skip) in intel_bts_synth_branch_sample()
293 sample.id = btsq->bts->branches_id; in intel_bts_synth_branch_sample()
294 sample.stream_id = btsq->bts->branches_id; in intel_bts_synth_branch_sample()
301 if (bts->synth_opts.inject) { in intel_bts_synth_branch_sample()
302 event.sample.header.size = bts->branches_event_size; in intel_bts_synth_branch_sample()
304 bts->branches_sample_type, in intel_bts_synth_branch_sample()
310 ret = perf_session__deliver_synth_event(bts->session, &event, &sample); in intel_bts_synth_branch_sample()
320 struct machine *machine = btsq->bts->machine; in intel_bts_get_next_insn()
360 static int intel_bts_synth_error(struct intel_bts *bts, int cpu, pid_t pid, in intel_bts_synth_error() argument
370 err = perf_session__deliver_synth_event(bts->session, &event, NULL); in intel_bts_synth_error()
399 if (!btsq->bts->synth_opts.errors) in intel_bts_get_branch_type()
401 err = intel_bts_synth_error(btsq->bts, btsq->cpu, in intel_bts_get_branch_type()
408 if (!machine__kernel_ip(btsq->bts->machine, branch->from) && in intel_bts_get_branch_type()
409 machine__kernel_ip(btsq->bts->machine, branch->to) && in intel_bts_get_branch_type()
428 u32 filter = btsq->bts->branches_filter; in intel_bts_process_buffer()
439 if (!btsq->bts->sample_branches) in intel_bts_process_buffer()
446 if (btsq->bts->synth_opts.thread_stack) in intel_bts_process_buffer()
472 thread = machine__find_thread(btsq->bts->machine, -1, in intel_bts_process_queue()
477 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid, in intel_bts_process_queue()
481 queue = &btsq->bts->queues.queue_array[btsq->queue_nr]; in intel_bts_process_queue()
487 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
500 int fd = perf_data__fd(btsq->bts->session->data); in intel_bts_process_queue()
509 if (btsq->bts->snapshot_mode && !buffer->consecutive && in intel_bts_process_queue()
515 if (!btsq->bts->synth_opts.callchain && in intel_bts_process_queue()
516 !btsq->bts->synth_opts.thread_stack && thread && in intel_bts_process_queue()
517 (!old_buffer || btsq->bts->sampling_mode || in intel_bts_process_queue()
518 (btsq->bts->snapshot_mode && !buffer->consecutive))) in intel_bts_process_queue()
530 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
553 static int intel_bts_process_tid_exit(struct intel_bts *bts, pid_t tid) in intel_bts_process_tid_exit() argument
555 struct auxtrace_queues *queues = &bts->queues; in intel_bts_process_tid_exit()
559 struct auxtrace_queue *queue = &bts->queues.queue_array[i]; in intel_bts_process_tid_exit()
568 static int intel_bts_process_queues(struct intel_bts *bts, u64 timestamp) in intel_bts_process_queues() argument
577 if (!bts->heap.heap_cnt) in intel_bts_process_queues()
580 if (bts->heap.heap_array[0].ordinal > timestamp) in intel_bts_process_queues()
583 queue_nr = bts->heap.heap_array[0].queue_nr; in intel_bts_process_queues()
584 queue = &bts->queues.queue_array[queue_nr]; in intel_bts_process_queues()
587 auxtrace_heap__pop(&bts->heap); in intel_bts_process_queues()
591 auxtrace_heap__add(&bts->heap, queue_nr, ts); in intel_bts_process_queues()
596 ret = auxtrace_heap__add(&bts->heap, queue_nr, ts); in intel_bts_process_queues()
612 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_process_event() local
626 timestamp = perf_time_to_tsc(sample->time, &bts->tc); in intel_bts_process_event()
630 err = intel_bts_update_queues(bts); in intel_bts_process_event()
634 err = intel_bts_process_queues(bts, timestamp); in intel_bts_process_event()
638 err = intel_bts_process_tid_exit(bts, event->fork.tid); in intel_bts_process_event()
645 bts->synth_opts.errors) in intel_bts_process_event()
646 err = intel_bts_lost(bts, sample); in intel_bts_process_event()
655 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_process_auxtrace_event() local
658 if (bts->sampling_mode) in intel_bts_process_auxtrace_event()
661 if (!bts->data_queued) { in intel_bts_process_auxtrace_event()
675 err = auxtrace_queues__add_event(&bts->queues, session, event, in intel_bts_process_auxtrace_event()
683 intel_bts_dump_event(bts, buffer->data, in intel_bts_process_auxtrace_event()
696 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_flush() local
700 if (dump_trace || bts->sampling_mode) in intel_bts_flush()
706 ret = intel_bts_update_queues(bts); in intel_bts_flush()
710 return intel_bts_process_queues(bts, MAX_TIMESTAMP); in intel_bts_flush()
724 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_free_events() local
726 struct auxtrace_queues *queues = &bts->queues; in intel_bts_free_events()
738 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_free() local
741 auxtrace_heap__free(&bts->heap); in intel_bts_free()
744 free(bts); in intel_bts_free()
776 static int intel_bts_synth_events(struct intel_bts *bts, in intel_bts_synth_events() argument
787 if (evsel->attr.type == bts->pmu_type && evsel->ids) { in intel_bts_synth_events()
818 if (bts->synth_opts.branches) { in intel_bts_synth_events()
830 bts->sample_branches = true; in intel_bts_synth_events()
831 bts->branches_sample_type = attr.sample_type; in intel_bts_synth_events()
832 bts->branches_id = id; in intel_bts_synth_events()
837 bts->branches_event_size = sizeof(struct sample_event) + in intel_bts_synth_events()
869 struct intel_bts *bts; in intel_bts_process_auxtrace_info() local
876 bts = zalloc(sizeof(struct intel_bts)); in intel_bts_process_auxtrace_info()
877 if (!bts) in intel_bts_process_auxtrace_info()
880 err = auxtrace_queues__init(&bts->queues); in intel_bts_process_auxtrace_info()
884 bts->session = session; in intel_bts_process_auxtrace_info()
885 bts->machine = &session->machines.host; /* No kvm support */ in intel_bts_process_auxtrace_info()
886 bts->auxtrace_type = auxtrace_info->type; in intel_bts_process_auxtrace_info()
887 bts->pmu_type = auxtrace_info->priv[INTEL_BTS_PMU_TYPE]; in intel_bts_process_auxtrace_info()
888 bts->tc.time_shift = auxtrace_info->priv[INTEL_BTS_TIME_SHIFT]; in intel_bts_process_auxtrace_info()
889 bts->tc.time_mult = auxtrace_info->priv[INTEL_BTS_TIME_MULT]; in intel_bts_process_auxtrace_info()
890 bts->tc.time_zero = auxtrace_info->priv[INTEL_BTS_TIME_ZERO]; in intel_bts_process_auxtrace_info()
891 bts->cap_user_time_zero = in intel_bts_process_auxtrace_info()
893 bts->snapshot_mode = auxtrace_info->priv[INTEL_BTS_SNAPSHOT_MODE]; in intel_bts_process_auxtrace_info()
895 bts->sampling_mode = false; in intel_bts_process_auxtrace_info()
897 bts->auxtrace.process_event = intel_bts_process_event; in intel_bts_process_auxtrace_info()
898 bts->auxtrace.process_auxtrace_event = intel_bts_process_auxtrace_event; in intel_bts_process_auxtrace_info()
899 bts->auxtrace.flush_events = intel_bts_flush; in intel_bts_process_auxtrace_info()
900 bts->auxtrace.free_events = intel_bts_free_events; in intel_bts_process_auxtrace_info()
901 bts->auxtrace.free = intel_bts_free; in intel_bts_process_auxtrace_info()
902 session->auxtrace = &bts->auxtrace; in intel_bts_process_auxtrace_info()
911 bts->synth_opts = *session->itrace_synth_opts; in intel_bts_process_auxtrace_info()
913 itrace_synth_opts__set_default(&bts->synth_opts); in intel_bts_process_auxtrace_info()
915 bts->synth_opts.thread_stack = in intel_bts_process_auxtrace_info()
919 if (bts->synth_opts.calls) in intel_bts_process_auxtrace_info()
920 bts->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | in intel_bts_process_auxtrace_info()
922 if (bts->synth_opts.returns) in intel_bts_process_auxtrace_info()
923 bts->branches_filter |= PERF_IP_FLAG_RETURN | in intel_bts_process_auxtrace_info()
926 err = intel_bts_synth_events(bts, session); in intel_bts_process_auxtrace_info()
930 err = auxtrace_queues__process_index(&bts->queues, session); in intel_bts_process_auxtrace_info()
934 if (bts->queues.populated) in intel_bts_process_auxtrace_info()
935 bts->data_queued = true; in intel_bts_process_auxtrace_info()
940 auxtrace_queues__free(&bts->queues); in intel_bts_process_auxtrace_info()
943 free(bts); in intel_bts_process_auxtrace_info()