Lines Matching refs:bts

67 	struct intel_bts	*bts;  member
86 static void intel_bts_dump(struct intel_bts *bts __maybe_unused, in intel_bts_dump()
124 static void intel_bts_dump_event(struct intel_bts *bts, unsigned char *buf, in intel_bts_dump_event() argument
128 intel_bts_dump(bts, buf, len); in intel_bts_dump_event()
131 static int intel_bts_lost(struct intel_bts *bts, struct perf_sample *sample) in intel_bts_lost() argument
140 err = perf_session__deliver_synth_event(bts->session, &event, NULL); in intel_bts_lost()
148 static struct intel_bts_queue *intel_bts_alloc_queue(struct intel_bts *bts, in intel_bts_alloc_queue() argument
157 btsq->bts = bts; in intel_bts_alloc_queue()
166 static int intel_bts_setup_queue(struct intel_bts *bts, in intel_bts_setup_queue() argument
176 btsq = intel_bts_alloc_queue(bts, queue_nr); in intel_bts_setup_queue()
186 if (bts->sampling_mode) in intel_bts_setup_queue()
196 ret = auxtrace_heap__add(&bts->heap, queue_nr, in intel_bts_setup_queue()
206 static int intel_bts_setup_queues(struct intel_bts *bts) in intel_bts_setup_queues() argument
211 for (i = 0; i < bts->queues.nr_queues; i++) { in intel_bts_setup_queues()
212 ret = intel_bts_setup_queue(bts, &bts->queues.queue_array[i], in intel_bts_setup_queues()
220 static inline int intel_bts_update_queues(struct intel_bts *bts) in intel_bts_update_queues() argument
222 if (bts->queues.new_data) { in intel_bts_update_queues()
223 bts->queues.new_data = false; in intel_bts_update_queues()
224 return intel_bts_setup_queues(bts); in intel_bts_update_queues()
265 static inline u8 intel_bts_cpumode(struct intel_bts *bts, uint64_t ip) in intel_bts_cpumode() argument
267 return machine__kernel_ip(bts->machine, ip) ? in intel_bts_cpumode()
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()
285 sample.cpumode = intel_bts_cpumode(bts, sample.ip); in intel_bts_synth_branch_sample()
289 sample.id = btsq->bts->branches_id; in intel_bts_synth_branch_sample()
290 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()
344 static int intel_bts_synth_error(struct intel_bts *bts, int cpu, pid_t pid, in intel_bts_synth_error() argument
354 err = perf_session__deliver_synth_event(bts->session, &event, NULL); in intel_bts_synth_error()
383 if (!btsq->bts->synth_opts.errors) in intel_bts_get_branch_type()
385 err = intel_bts_synth_error(btsq->bts, btsq->cpu, in intel_bts_get_branch_type()
392 if (!machine__kernel_ip(btsq->bts->machine, branch->from) && in intel_bts_get_branch_type()
393 machine__kernel_ip(btsq->bts->machine, branch->to) && in intel_bts_get_branch_type()
412 u32 filter = btsq->bts->branches_filter; in intel_bts_process_buffer()
423 if (!btsq->bts->sample_branches) in intel_bts_process_buffer()
430 if (btsq->bts->synth_opts.thread_stack) in intel_bts_process_buffer()
456 thread = machine__find_thread(btsq->bts->machine, -1, in intel_bts_process_queue()
461 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid, in intel_bts_process_queue()
465 queue = &btsq->bts->queues.queue_array[btsq->queue_nr]; in intel_bts_process_queue()
471 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
484 int fd = perf_data__fd(btsq->bts->session->data); in intel_bts_process_queue()
493 if (btsq->bts->snapshot_mode && !buffer->consecutive && in intel_bts_process_queue()
499 if (!btsq->bts->synth_opts.callchain && in intel_bts_process_queue()
500 !btsq->bts->synth_opts.thread_stack && thread && in intel_bts_process_queue()
501 (!old_buffer || btsq->bts->sampling_mode || in intel_bts_process_queue()
502 (btsq->bts->snapshot_mode && !buffer->consecutive))) in intel_bts_process_queue()
514 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
537 static int intel_bts_process_tid_exit(struct intel_bts *bts, pid_t tid) in intel_bts_process_tid_exit() argument
539 struct auxtrace_queues *queues = &bts->queues; in intel_bts_process_tid_exit()
543 struct auxtrace_queue *queue = &bts->queues.queue_array[i]; in intel_bts_process_tid_exit()
552 static int intel_bts_process_queues(struct intel_bts *bts, u64 timestamp) in intel_bts_process_queues() argument
561 if (!bts->heap.heap_cnt) in intel_bts_process_queues()
564 if (bts->heap.heap_array[0].ordinal > timestamp) in intel_bts_process_queues()
567 queue_nr = bts->heap.heap_array[0].queue_nr; in intel_bts_process_queues()
568 queue = &bts->queues.queue_array[queue_nr]; in intel_bts_process_queues()
571 auxtrace_heap__pop(&bts->heap); in intel_bts_process_queues()
575 auxtrace_heap__add(&bts->heap, queue_nr, ts); in intel_bts_process_queues()
580 ret = auxtrace_heap__add(&bts->heap, queue_nr, ts); in intel_bts_process_queues()
596 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_process_event() local
610 timestamp = perf_time_to_tsc(sample->time, &bts->tc); in intel_bts_process_event()
614 err = intel_bts_update_queues(bts); in intel_bts_process_event()
618 err = intel_bts_process_queues(bts, timestamp); in intel_bts_process_event()
622 err = intel_bts_process_tid_exit(bts, event->fork.tid); in intel_bts_process_event()
629 bts->synth_opts.errors) in intel_bts_process_event()
630 err = intel_bts_lost(bts, sample); in intel_bts_process_event()
639 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_process_auxtrace_event() local
642 if (bts->sampling_mode) in intel_bts_process_auxtrace_event()
645 if (!bts->data_queued) { in intel_bts_process_auxtrace_event()
659 err = auxtrace_queues__add_event(&bts->queues, session, event, in intel_bts_process_auxtrace_event()
667 intel_bts_dump_event(bts, buffer->data, in intel_bts_process_auxtrace_event()
680 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_flush() local
684 if (dump_trace || bts->sampling_mode) in intel_bts_flush()
690 ret = intel_bts_update_queues(bts); in intel_bts_flush()
694 return intel_bts_process_queues(bts, MAX_TIMESTAMP); in intel_bts_flush()
708 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_free_events() local
710 struct auxtrace_queues *queues = &bts->queues; in intel_bts_free_events()
722 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_free() local
725 auxtrace_heap__free(&bts->heap); in intel_bts_free()
728 free(bts); in intel_bts_free()
734 struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, in intel_bts_evsel_is_auxtrace() local
737 return evsel->core.attr.type == bts->pmu_type; in intel_bts_evsel_is_auxtrace()
769 static int intel_bts_synth_events(struct intel_bts *bts, in intel_bts_synth_events() argument
780 if (evsel->core.attr.type == bts->pmu_type && evsel->core.ids) { in intel_bts_synth_events()
811 if (bts->synth_opts.branches) { in intel_bts_synth_events()
823 bts->sample_branches = true; in intel_bts_synth_events()
824 bts->branches_sample_type = attr.sample_type; in intel_bts_synth_events()
825 bts->branches_id = id; in intel_bts_synth_events()
830 bts->branches_event_size = sizeof(struct perf_record_sample) + in intel_bts_synth_events()
862 struct intel_bts *bts; in intel_bts_process_auxtrace_info() local
869 bts = zalloc(sizeof(struct intel_bts)); in intel_bts_process_auxtrace_info()
870 if (!bts) in intel_bts_process_auxtrace_info()
873 err = auxtrace_queues__init(&bts->queues); in intel_bts_process_auxtrace_info()
877 bts->session = session; in intel_bts_process_auxtrace_info()
878 bts->machine = &session->machines.host; /* No kvm support */ in intel_bts_process_auxtrace_info()
879 bts->auxtrace_type = auxtrace_info->type; in intel_bts_process_auxtrace_info()
880 bts->pmu_type = auxtrace_info->priv[INTEL_BTS_PMU_TYPE]; in intel_bts_process_auxtrace_info()
881 bts->tc.time_shift = auxtrace_info->priv[INTEL_BTS_TIME_SHIFT]; in intel_bts_process_auxtrace_info()
882 bts->tc.time_mult = auxtrace_info->priv[INTEL_BTS_TIME_MULT]; in intel_bts_process_auxtrace_info()
883 bts->tc.time_zero = auxtrace_info->priv[INTEL_BTS_TIME_ZERO]; in intel_bts_process_auxtrace_info()
884 bts->cap_user_time_zero = in intel_bts_process_auxtrace_info()
886 bts->snapshot_mode = auxtrace_info->priv[INTEL_BTS_SNAPSHOT_MODE]; in intel_bts_process_auxtrace_info()
888 bts->sampling_mode = false; in intel_bts_process_auxtrace_info()
890 bts->auxtrace.process_event = intel_bts_process_event; in intel_bts_process_auxtrace_info()
891 bts->auxtrace.process_auxtrace_event = intel_bts_process_auxtrace_event; in intel_bts_process_auxtrace_info()
892 bts->auxtrace.flush_events = intel_bts_flush; in intel_bts_process_auxtrace_info()
893 bts->auxtrace.free_events = intel_bts_free_events; in intel_bts_process_auxtrace_info()
894 bts->auxtrace.free = intel_bts_free; in intel_bts_process_auxtrace_info()
895 bts->auxtrace.evsel_is_auxtrace = intel_bts_evsel_is_auxtrace; in intel_bts_process_auxtrace_info()
896 session->auxtrace = &bts->auxtrace; in intel_bts_process_auxtrace_info()
905 bts->synth_opts = *session->itrace_synth_opts; in intel_bts_process_auxtrace_info()
907 itrace_synth_opts__set_default(&bts->synth_opts, in intel_bts_process_auxtrace_info()
909 bts->synth_opts.thread_stack = in intel_bts_process_auxtrace_info()
913 if (bts->synth_opts.calls) in intel_bts_process_auxtrace_info()
914 bts->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | in intel_bts_process_auxtrace_info()
916 if (bts->synth_opts.returns) in intel_bts_process_auxtrace_info()
917 bts->branches_filter |= PERF_IP_FLAG_RETURN | in intel_bts_process_auxtrace_info()
920 err = intel_bts_synth_events(bts, session); in intel_bts_process_auxtrace_info()
924 err = auxtrace_queues__process_index(&bts->queues, session); in intel_bts_process_auxtrace_info()
928 if (bts->queues.populated) in intel_bts_process_auxtrace_info()
929 bts->data_queued = true; in intel_bts_process_auxtrace_info()
934 auxtrace_queues__free(&bts->queues); in intel_bts_process_auxtrace_info()
937 free(bts); in intel_bts_process_auxtrace_info()