Lines Matching refs:bts

72 	struct intel_bts	*bts;  member
91 static void intel_bts_dump(struct intel_bts *bts __maybe_unused, in intel_bts_dump()
129 static void intel_bts_dump_event(struct intel_bts *bts, unsigned char *buf, in intel_bts_dump_event() argument
133 intel_bts_dump(bts, buf, len); in intel_bts_dump_event()
136 static int intel_bts_lost(struct intel_bts *bts, struct perf_sample *sample) in intel_bts_lost() argument
145 err = perf_session__deliver_synth_event(bts->session, &event, NULL); in intel_bts_lost()
153 static struct intel_bts_queue *intel_bts_alloc_queue(struct intel_bts *bts, in intel_bts_alloc_queue() argument
162 btsq->bts = bts; in intel_bts_alloc_queue()
171 static int intel_bts_setup_queue(struct intel_bts *bts, in intel_bts_setup_queue() argument
181 btsq = intel_bts_alloc_queue(bts, queue_nr); in intel_bts_setup_queue()
191 if (bts->sampling_mode) in intel_bts_setup_queue()
201 ret = auxtrace_heap__add(&bts->heap, queue_nr, in intel_bts_setup_queue()
211 static int intel_bts_setup_queues(struct intel_bts *bts) in intel_bts_setup_queues() argument
216 for (i = 0; i < bts->queues.nr_queues; i++) { in intel_bts_setup_queues()
217 ret = intel_bts_setup_queue(bts, &bts->queues.queue_array[i], in intel_bts_setup_queues()
225 static inline int intel_bts_update_queues(struct intel_bts *bts) in intel_bts_update_queues() argument
227 if (bts->queues.new_data) { in intel_bts_update_queues()
228 bts->queues.new_data = false; in intel_bts_update_queues()
229 return intel_bts_setup_queues(bts); in intel_bts_update_queues()
274 struct intel_bts *bts = btsq->bts; in intel_bts_synth_branch_sample() local
286 sample.id = btsq->bts->branches_id; in intel_bts_synth_branch_sample()
287 sample.stream_id = btsq->bts->branches_id; in intel_bts_synth_branch_sample()
293 if (bts->synth_opts.inject) { in intel_bts_synth_branch_sample()
294 event.sample.header.size = bts->branches_event_size; in intel_bts_synth_branch_sample()
296 bts->branches_sample_type, in intel_bts_synth_branch_sample()
298 bts->synth_needs_swap); in intel_bts_synth_branch_sample()
303 ret = perf_session__deliver_synth_event(bts->session, &event, &sample); in intel_bts_synth_branch_sample()
313 struct machine *machine = btsq->bts->machine; in intel_bts_get_next_insn()
356 static int intel_bts_synth_error(struct intel_bts *bts, int cpu, pid_t pid, in intel_bts_synth_error() argument
366 err = perf_session__deliver_synth_event(bts->session, &event, NULL); in intel_bts_synth_error()
395 if (!btsq->bts->synth_opts.errors) in intel_bts_get_branch_type()
397 err = intel_bts_synth_error(btsq->bts, btsq->cpu, in intel_bts_get_branch_type()
404 if (!machine__kernel_ip(btsq->bts->machine, branch->from) && in intel_bts_get_branch_type()
405 machine__kernel_ip(btsq->bts->machine, branch->to) && in intel_bts_get_branch_type()
423 u32 filter = btsq->bts->branches_filter; in intel_bts_process_buffer()
434 if (!btsq->bts->sample_branches) in intel_bts_process_buffer()
461 thread = machine__find_thread(btsq->bts->machine, -1, in intel_bts_process_queue()
466 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid, in intel_bts_process_queue()
470 queue = &btsq->bts->queues.queue_array[btsq->queue_nr]; in intel_bts_process_queue()
476 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
489 int fd = perf_data_file__fd(btsq->bts->session->file); in intel_bts_process_queue()
498 if (btsq->bts->snapshot_mode && !buffer->consecutive && in intel_bts_process_queue()
504 if (!btsq->bts->synth_opts.callchain && thread && in intel_bts_process_queue()
505 (!old_buffer || btsq->bts->sampling_mode || in intel_bts_process_queue()
506 (btsq->bts->snapshot_mode && !buffer->consecutive))) in intel_bts_process_queue()
518 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
541 static int intel_bts_process_tid_exit(struct intel_bts *bts, pid_t tid) in intel_bts_process_tid_exit() argument
543 struct auxtrace_queues *queues = &bts->queues; in intel_bts_process_tid_exit()
547 struct auxtrace_queue *queue = &bts->queues.queue_array[i]; in intel_bts_process_tid_exit()
556 static int intel_bts_process_queues(struct intel_bts *bts, u64 timestamp) in intel_bts_process_queues() argument
565 if (!bts->heap.heap_cnt) in intel_bts_process_queues()
568 if (bts->heap.heap_array[0].ordinal > timestamp) in intel_bts_process_queues()
571 queue_nr = bts->heap.heap_array[0].queue_nr; in intel_bts_process_queues()
572 queue = &bts->queues.queue_array[queue_nr]; in intel_bts_process_queues()
575 auxtrace_heap__pop(&bts->heap); in intel_bts_process_queues()
579 auxtrace_heap__add(&bts->heap, queue_nr, ts); in intel_bts_process_queues()
584 ret = auxtrace_heap__add(&bts->heap, queue_nr, ts); in intel_bts_process_queues()
600 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_process_event() local
614 timestamp = perf_time_to_tsc(sample->time, &bts->tc); in intel_bts_process_event()
618 err = intel_bts_update_queues(bts); in intel_bts_process_event()
622 err = intel_bts_process_queues(bts, timestamp); in intel_bts_process_event()
626 err = intel_bts_process_tid_exit(bts, event->fork.tid); in intel_bts_process_event()
633 bts->synth_opts.errors) in intel_bts_process_event()
634 err = intel_bts_lost(bts, sample); in intel_bts_process_event()
643 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_process_auxtrace_event() local
646 if (bts->sampling_mode) in intel_bts_process_auxtrace_event()
649 if (!bts->data_queued) { in intel_bts_process_auxtrace_event()
663 err = auxtrace_queues__add_event(&bts->queues, session, event, in intel_bts_process_auxtrace_event()
671 intel_bts_dump_event(bts, buffer->data, in intel_bts_process_auxtrace_event()
684 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_flush() local
688 if (dump_trace || bts->sampling_mode) in intel_bts_flush()
694 ret = intel_bts_update_queues(bts); in intel_bts_flush()
698 return intel_bts_process_queues(bts, MAX_TIMESTAMP); in intel_bts_flush()
712 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_free_events() local
714 struct auxtrace_queues *queues = &bts->queues; in intel_bts_free_events()
726 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_free() local
729 auxtrace_heap__free(&bts->heap); in intel_bts_free()
732 free(bts); in intel_bts_free()
764 static int intel_bts_synth_events(struct intel_bts *bts, in intel_bts_synth_events() argument
775 if (evsel->attr.type == bts->pmu_type && evsel->ids) { in intel_bts_synth_events()
806 if (bts->synth_opts.branches) { in intel_bts_synth_events()
818 bts->sample_branches = true; in intel_bts_synth_events()
819 bts->branches_sample_type = attr.sample_type; in intel_bts_synth_events()
820 bts->branches_id = id; in intel_bts_synth_events()
825 bts->branches_event_size = sizeof(struct sample_event) + in intel_bts_synth_events()
829 bts->synth_needs_swap = evsel->needs_swap; in intel_bts_synth_events()
861 struct intel_bts *bts; in intel_bts_process_auxtrace_info() local
868 bts = zalloc(sizeof(struct intel_bts)); in intel_bts_process_auxtrace_info()
869 if (!bts) in intel_bts_process_auxtrace_info()
872 err = auxtrace_queues__init(&bts->queues); in intel_bts_process_auxtrace_info()
876 bts->session = session; in intel_bts_process_auxtrace_info()
877 bts->machine = &session->machines.host; /* No kvm support */ in intel_bts_process_auxtrace_info()
878 bts->auxtrace_type = auxtrace_info->type; in intel_bts_process_auxtrace_info()
879 bts->pmu_type = auxtrace_info->priv[INTEL_BTS_PMU_TYPE]; in intel_bts_process_auxtrace_info()
880 bts->tc.time_shift = auxtrace_info->priv[INTEL_BTS_TIME_SHIFT]; in intel_bts_process_auxtrace_info()
881 bts->tc.time_mult = auxtrace_info->priv[INTEL_BTS_TIME_MULT]; in intel_bts_process_auxtrace_info()
882 bts->tc.time_zero = auxtrace_info->priv[INTEL_BTS_TIME_ZERO]; in intel_bts_process_auxtrace_info()
883 bts->cap_user_time_zero = in intel_bts_process_auxtrace_info()
885 bts->snapshot_mode = auxtrace_info->priv[INTEL_BTS_SNAPSHOT_MODE]; in intel_bts_process_auxtrace_info()
887 bts->sampling_mode = false; in intel_bts_process_auxtrace_info()
889 bts->auxtrace.process_event = intel_bts_process_event; in intel_bts_process_auxtrace_info()
890 bts->auxtrace.process_auxtrace_event = intel_bts_process_auxtrace_event; in intel_bts_process_auxtrace_info()
891 bts->auxtrace.flush_events = intel_bts_flush; in intel_bts_process_auxtrace_info()
892 bts->auxtrace.free_events = intel_bts_free_events; in intel_bts_process_auxtrace_info()
893 bts->auxtrace.free = intel_bts_free; in intel_bts_process_auxtrace_info()
894 session->auxtrace = &bts->auxtrace; in intel_bts_process_auxtrace_info()
903 bts->synth_opts = *session->itrace_synth_opts; in intel_bts_process_auxtrace_info()
905 itrace_synth_opts__set_default(&bts->synth_opts); in intel_bts_process_auxtrace_info()
907 if (bts->synth_opts.calls) in intel_bts_process_auxtrace_info()
908 bts->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | in intel_bts_process_auxtrace_info()
910 if (bts->synth_opts.returns) in intel_bts_process_auxtrace_info()
911 bts->branches_filter |= PERF_IP_FLAG_RETURN | in intel_bts_process_auxtrace_info()
914 err = intel_bts_synth_events(bts, session); in intel_bts_process_auxtrace_info()
918 err = auxtrace_queues__process_index(&bts->queues, session); in intel_bts_process_auxtrace_info()
922 if (bts->queues.populated) in intel_bts_process_auxtrace_info()
923 bts->data_queued = true; in intel_bts_process_auxtrace_info()
928 auxtrace_queues__free(&bts->queues); in intel_bts_process_auxtrace_info()
931 free(bts); in intel_bts_process_auxtrace_info()