Lines Matching refs:btsq

158 	struct intel_bts_queue *btsq;  in intel_bts_alloc_queue()  local
160 btsq = zalloc(sizeof(struct intel_bts_queue)); in intel_bts_alloc_queue()
161 if (!btsq) in intel_bts_alloc_queue()
164 btsq->bts = bts; in intel_bts_alloc_queue()
165 btsq->queue_nr = queue_nr; in intel_bts_alloc_queue()
166 btsq->pid = -1; in intel_bts_alloc_queue()
167 btsq->tid = -1; in intel_bts_alloc_queue()
168 btsq->cpu = -1; in intel_bts_alloc_queue()
170 return btsq; in intel_bts_alloc_queue()
177 struct intel_bts_queue *btsq = queue->priv; in intel_bts_setup_queue() local
182 if (!btsq) { in intel_bts_setup_queue()
183 btsq = intel_bts_alloc_queue(bts, queue_nr); in intel_bts_setup_queue()
184 if (!btsq) in intel_bts_setup_queue()
186 queue->priv = btsq; in intel_bts_setup_queue()
189 btsq->cpu = queue->cpu; in intel_bts_setup_queue()
190 btsq->tid = queue->tid; in intel_bts_setup_queue()
196 if (!btsq->on_heap && !btsq->buffer) { in intel_bts_setup_queue()
199 btsq->buffer = auxtrace_buffer__next(queue, NULL); in intel_bts_setup_queue()
200 if (!btsq->buffer) in intel_bts_setup_queue()
204 btsq->buffer->reference); in intel_bts_setup_queue()
207 btsq->on_heap = true; in intel_bts_setup_queue()
272 static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, in intel_bts_synth_branch_sample() argument
276 struct intel_bts *bts = btsq->bts; in intel_bts_synth_branch_sample()
290 sample.pid = btsq->pid; in intel_bts_synth_branch_sample()
291 sample.tid = btsq->tid; 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()
296 sample.cpu = btsq->cpu; in intel_bts_synth_branch_sample()
297 sample.flags = btsq->sample_flags; in intel_bts_synth_branch_sample()
298 sample.insn_len = btsq->intel_pt_insn.length; in intel_bts_synth_branch_sample()
299 memcpy(sample.insn, btsq->intel_pt_insn.buf, INTEL_PT_INSN_BUF_SZ); in intel_bts_synth_branch_sample()
318 static int intel_bts_get_next_insn(struct intel_bts_queue *btsq, u64 ip) in intel_bts_get_next_insn() argument
320 struct machine *machine = btsq->bts->machine; in intel_bts_get_next_insn()
334 thread = machine__find_thread(machine, -1, btsq->tid); in intel_bts_get_next_insn()
351 if (intel_pt_get_insn(buf, len, x86_64, &btsq->intel_pt_insn)) in intel_bts_get_next_insn()
378 static int intel_bts_get_branch_type(struct intel_bts_queue *btsq, in intel_bts_get_branch_type() argument
385 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
388 btsq->sample_flags = 0; in intel_bts_get_branch_type()
389 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
391 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
393 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
395 err = intel_bts_get_next_insn(btsq, branch->from); in intel_bts_get_branch_type()
397 btsq->sample_flags = 0; in intel_bts_get_branch_type()
398 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
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()
402 btsq->pid, btsq->tid, in intel_bts_get_branch_type()
406 btsq->sample_flags = intel_pt_insn_type(btsq->intel_pt_insn.op); 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()
410 btsq->sample_flags != (PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
413 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
422 static int intel_bts_process_buffer(struct intel_bts_queue *btsq, in intel_bts_process_buffer() argument
428 u32 filter = btsq->bts->branches_filter; in intel_bts_process_buffer()
439 if (!btsq->bts->sample_branches) in intel_bts_process_buffer()
445 intel_bts_get_branch_type(btsq, branch); in intel_bts_process_buffer()
446 if (btsq->bts->synth_opts.thread_stack) in intel_bts_process_buffer()
447 thread_stack__event(thread, btsq->sample_flags, in intel_bts_process_buffer()
450 btsq->intel_pt_insn.length, in intel_bts_process_buffer()
452 if (filter && !(filter & btsq->sample_flags)) in intel_bts_process_buffer()
454 err = intel_bts_synth_branch_sample(btsq, branch); in intel_bts_process_buffer()
461 static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp) in intel_bts_process_queue() argument
463 struct auxtrace_buffer *buffer = btsq->buffer, *old_buffer = buffer; in intel_bts_process_queue()
468 if (btsq->done) in intel_bts_process_queue()
471 if (btsq->pid == -1) { in intel_bts_process_queue()
472 thread = machine__find_thread(btsq->bts->machine, -1, in intel_bts_process_queue()
473 btsq->tid); in intel_bts_process_queue()
475 btsq->pid = thread->pid_; in intel_bts_process_queue()
477 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid, in intel_bts_process_queue()
478 btsq->tid); 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()
488 btsq->done = 1; 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()
521 err = intel_bts_process_buffer(btsq, buffer, thread); in intel_bts_process_queue()
525 btsq->buffer = auxtrace_buffer__next(queue, buffer); in intel_bts_process_queue()
526 if (btsq->buffer) { in intel_bts_process_queue()
528 *timestamp = btsq->buffer->reference; in intel_bts_process_queue()
530 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
531 btsq->done = 1; in intel_bts_process_queue()
538 static int intel_bts_flush_queue(struct intel_bts_queue *btsq) in intel_bts_flush_queue() argument
544 ret = intel_bts_process_queue(btsq, &ts); in intel_bts_flush_queue()
560 struct intel_bts_queue *btsq = queue->priv; in intel_bts_process_tid_exit() local
562 if (btsq && btsq->tid == tid) in intel_bts_process_tid_exit()
563 return intel_bts_flush_queue(btsq); in intel_bts_process_tid_exit()
573 struct intel_bts_queue *btsq; in intel_bts_process_queues() local
585 btsq = queue->priv; in intel_bts_process_queues()
589 ret = intel_bts_process_queue(btsq, &ts); in intel_bts_process_queues()
600 btsq->on_heap = false; in intel_bts_process_queues()
715 struct intel_bts_queue *btsq = priv; in intel_bts_free_queue() local
717 if (!btsq) in intel_bts_free_queue()
719 free(btsq); in intel_bts_free_queue()