Lines Matching refs:btsq

156 	struct intel_bts_queue *btsq;  in intel_bts_alloc_queue()  local
158 btsq = zalloc(sizeof(struct intel_bts_queue)); in intel_bts_alloc_queue()
159 if (!btsq) in intel_bts_alloc_queue()
162 btsq->bts = bts; in intel_bts_alloc_queue()
163 btsq->queue_nr = queue_nr; in intel_bts_alloc_queue()
164 btsq->pid = -1; in intel_bts_alloc_queue()
165 btsq->tid = -1; in intel_bts_alloc_queue()
166 btsq->cpu = -1; in intel_bts_alloc_queue()
168 return btsq; in intel_bts_alloc_queue()
175 struct intel_bts_queue *btsq = queue->priv; in intel_bts_setup_queue() local
180 if (!btsq) { in intel_bts_setup_queue()
181 btsq = intel_bts_alloc_queue(bts, queue_nr); in intel_bts_setup_queue()
182 if (!btsq) in intel_bts_setup_queue()
184 queue->priv = btsq; in intel_bts_setup_queue()
187 btsq->cpu = queue->cpu; in intel_bts_setup_queue()
188 btsq->tid = queue->tid; in intel_bts_setup_queue()
194 if (!btsq->on_heap && !btsq->buffer) { in intel_bts_setup_queue()
197 btsq->buffer = auxtrace_buffer__next(queue, NULL); in intel_bts_setup_queue()
198 if (!btsq->buffer) in intel_bts_setup_queue()
202 btsq->buffer->reference); in intel_bts_setup_queue()
205 btsq->on_heap = true; in intel_bts_setup_queue()
270 static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, in intel_bts_synth_branch_sample() argument
274 struct intel_bts *bts = btsq->bts; in intel_bts_synth_branch_sample()
283 sample.pid = btsq->pid; in intel_bts_synth_branch_sample()
284 sample.tid = btsq->tid; in intel_bts_synth_branch_sample()
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()
289 sample.cpu = btsq->cpu; in intel_bts_synth_branch_sample()
290 sample.flags = btsq->sample_flags; in intel_bts_synth_branch_sample()
291 sample.insn_len = btsq->intel_pt_insn.length; in intel_bts_synth_branch_sample()
311 static int intel_bts_get_next_insn(struct intel_bts_queue *btsq, u64 ip) in intel_bts_get_next_insn() argument
313 struct machine *machine = btsq->bts->machine; in intel_bts_get_next_insn()
330 thread = machine__find_thread(machine, -1, btsq->tid); in intel_bts_get_next_insn()
347 if (intel_pt_get_insn(buf, len, x86_64, &btsq->intel_pt_insn)) in intel_bts_get_next_insn()
374 static int intel_bts_get_branch_type(struct intel_bts_queue *btsq, in intel_bts_get_branch_type() argument
381 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
384 btsq->sample_flags = 0; in intel_bts_get_branch_type()
385 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
387 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
389 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
391 err = intel_bts_get_next_insn(btsq, branch->from); in intel_bts_get_branch_type()
393 btsq->sample_flags = 0; in intel_bts_get_branch_type()
394 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
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()
398 btsq->pid, btsq->tid, in intel_bts_get_branch_type()
402 btsq->sample_flags = intel_pt_insn_type(btsq->intel_pt_insn.op); 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()
406 btsq->sample_flags != (PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
409 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
418 static int intel_bts_process_buffer(struct intel_bts_queue *btsq, in intel_bts_process_buffer() argument
423 u32 filter = btsq->bts->branches_filter; in intel_bts_process_buffer()
434 if (!btsq->bts->sample_branches) in intel_bts_process_buffer()
440 intel_bts_get_branch_type(btsq, branch); in intel_bts_process_buffer()
441 if (filter && !(filter & btsq->sample_flags)) in intel_bts_process_buffer()
443 err = intel_bts_synth_branch_sample(btsq, branch); in intel_bts_process_buffer()
450 static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp) in intel_bts_process_queue() argument
452 struct auxtrace_buffer *buffer = btsq->buffer, *old_buffer = buffer; in intel_bts_process_queue()
457 if (btsq->done) in intel_bts_process_queue()
460 if (btsq->pid == -1) { in intel_bts_process_queue()
461 thread = machine__find_thread(btsq->bts->machine, -1, in intel_bts_process_queue()
462 btsq->tid); in intel_bts_process_queue()
464 btsq->pid = thread->pid_; in intel_bts_process_queue()
466 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid, in intel_bts_process_queue()
467 btsq->tid); 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()
477 btsq->done = 1; 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()
509 err = intel_bts_process_buffer(btsq, buffer); in intel_bts_process_queue()
513 btsq->buffer = auxtrace_buffer__next(queue, buffer); in intel_bts_process_queue()
514 if (btsq->buffer) { in intel_bts_process_queue()
516 *timestamp = btsq->buffer->reference; in intel_bts_process_queue()
518 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
519 btsq->done = 1; in intel_bts_process_queue()
526 static int intel_bts_flush_queue(struct intel_bts_queue *btsq) in intel_bts_flush_queue() argument
532 ret = intel_bts_process_queue(btsq, &ts); in intel_bts_flush_queue()
548 struct intel_bts_queue *btsq = queue->priv; in intel_bts_process_tid_exit() local
550 if (btsq && btsq->tid == tid) in intel_bts_process_tid_exit()
551 return intel_bts_flush_queue(btsq); in intel_bts_process_tid_exit()
561 struct intel_bts_queue *btsq; in intel_bts_process_queues() local
573 btsq = queue->priv; in intel_bts_process_queues()
577 ret = intel_bts_process_queue(btsq, &ts); in intel_bts_process_queues()
588 btsq->on_heap = false; in intel_bts_process_queues()
703 struct intel_bts_queue *btsq = priv; in intel_bts_free_queue() local
705 if (!btsq) in intel_bts_free_queue()
707 free(btsq); in intel_bts_free_queue()