Lines Matching refs:btsq

151 	struct intel_bts_queue *btsq;  in intel_bts_alloc_queue()  local
153 btsq = zalloc(sizeof(struct intel_bts_queue)); in intel_bts_alloc_queue()
154 if (!btsq) in intel_bts_alloc_queue()
157 btsq->bts = bts; in intel_bts_alloc_queue()
158 btsq->queue_nr = queue_nr; in intel_bts_alloc_queue()
159 btsq->pid = -1; in intel_bts_alloc_queue()
160 btsq->tid = -1; in intel_bts_alloc_queue()
161 btsq->cpu = -1; in intel_bts_alloc_queue()
163 return btsq; in intel_bts_alloc_queue()
170 struct intel_bts_queue *btsq = queue->priv; in intel_bts_setup_queue() local
175 if (!btsq) { in intel_bts_setup_queue()
176 btsq = intel_bts_alloc_queue(bts, queue_nr); in intel_bts_setup_queue()
177 if (!btsq) in intel_bts_setup_queue()
179 queue->priv = btsq; in intel_bts_setup_queue()
182 btsq->cpu = queue->cpu; in intel_bts_setup_queue()
183 btsq->tid = queue->tid; in intel_bts_setup_queue()
189 if (!btsq->on_heap && !btsq->buffer) { in intel_bts_setup_queue()
192 btsq->buffer = auxtrace_buffer__next(queue, NULL); in intel_bts_setup_queue()
193 if (!btsq->buffer) in intel_bts_setup_queue()
197 btsq->buffer->reference); in intel_bts_setup_queue()
200 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()
286 sample.pid = btsq->pid; in intel_bts_synth_branch_sample()
287 sample.tid = btsq->tid; 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()
292 sample.cpu = btsq->cpu; in intel_bts_synth_branch_sample()
293 sample.flags = btsq->sample_flags; in intel_bts_synth_branch_sample()
294 sample.insn_len = btsq->intel_pt_insn.length; in intel_bts_synth_branch_sample()
295 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()
327 thread = machine__find_thread(machine, -1, btsq->tid); in intel_bts_get_next_insn()
335 if (intel_pt_get_insn(buf, len, x86_64, &btsq->intel_pt_insn)) in intel_bts_get_next_insn()
362 static int intel_bts_get_branch_type(struct intel_bts_queue *btsq, in intel_bts_get_branch_type() argument
369 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
372 btsq->sample_flags = 0; in intel_bts_get_branch_type()
373 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
375 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
377 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
379 err = intel_bts_get_next_insn(btsq, branch->from); in intel_bts_get_branch_type()
381 btsq->sample_flags = 0; in intel_bts_get_branch_type()
382 btsq->intel_pt_insn.length = 0; in intel_bts_get_branch_type()
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()
386 btsq->pid, btsq->tid, in intel_bts_get_branch_type()
390 btsq->sample_flags = intel_pt_insn_type(btsq->intel_pt_insn.op); 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()
394 btsq->sample_flags != (PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
397 btsq->sample_flags = PERF_IP_FLAG_BRANCH | in intel_bts_get_branch_type()
406 static int intel_bts_process_buffer(struct intel_bts_queue *btsq, in intel_bts_process_buffer() argument
412 u32 filter = btsq->bts->branches_filter; in intel_bts_process_buffer()
423 if (!btsq->bts->sample_branches) in intel_bts_process_buffer()
429 intel_bts_get_branch_type(btsq, branch); in intel_bts_process_buffer()
430 if (btsq->bts->synth_opts.thread_stack) in intel_bts_process_buffer()
431 thread_stack__event(thread, btsq->cpu, btsq->sample_flags, in intel_bts_process_buffer()
434 btsq->intel_pt_insn.length, in intel_bts_process_buffer()
436 if (filter && !(filter & btsq->sample_flags)) in intel_bts_process_buffer()
438 err = intel_bts_synth_branch_sample(btsq, branch); in intel_bts_process_buffer()
445 static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp) in intel_bts_process_queue() argument
447 struct auxtrace_buffer *buffer = btsq->buffer, *old_buffer = buffer; in intel_bts_process_queue()
452 if (btsq->done) in intel_bts_process_queue()
455 if (btsq->pid == -1) { in intel_bts_process_queue()
456 thread = machine__find_thread(btsq->bts->machine, -1, in intel_bts_process_queue()
457 btsq->tid); in intel_bts_process_queue()
459 btsq->pid = thread->pid_; in intel_bts_process_queue()
461 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid, in intel_bts_process_queue()
462 btsq->tid); 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()
472 btsq->done = 1; 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()
503 thread_stack__set_trace_nr(thread, btsq->cpu, buffer->buffer_nr + 1); in intel_bts_process_queue()
505 err = intel_bts_process_buffer(btsq, buffer, thread); in intel_bts_process_queue()
509 btsq->buffer = auxtrace_buffer__next(queue, buffer); in intel_bts_process_queue()
510 if (btsq->buffer) { in intel_bts_process_queue()
512 *timestamp = btsq->buffer->reference; in intel_bts_process_queue()
514 if (!btsq->bts->sampling_mode) in intel_bts_process_queue()
515 btsq->done = 1; in intel_bts_process_queue()
522 static int intel_bts_flush_queue(struct intel_bts_queue *btsq) in intel_bts_flush_queue() argument
528 ret = intel_bts_process_queue(btsq, &ts); in intel_bts_flush_queue()
544 struct intel_bts_queue *btsq = queue->priv; in intel_bts_process_tid_exit() local
546 if (btsq && btsq->tid == tid) in intel_bts_process_tid_exit()
547 return intel_bts_flush_queue(btsq); in intel_bts_process_tid_exit()
557 struct intel_bts_queue *btsq; in intel_bts_process_queues() local
569 btsq = queue->priv; in intel_bts_process_queues()
573 ret = intel_bts_process_queue(btsq, &ts); in intel_bts_process_queues()
584 btsq->on_heap = false; in intel_bts_process_queues()
699 struct intel_bts_queue *btsq = priv; in intel_bts_free_queue() local
701 if (!btsq) in intel_bts_free_queue()
703 free(btsq); in intel_bts_free_queue()