Lines Matching refs:btsq

151 	struct intel_bts_queue *btsq;
153 btsq = zalloc(sizeof(struct intel_bts_queue));
154 if (!btsq)
157 btsq->bts = bts;
158 btsq->queue_nr = queue_nr;
159 btsq->pid = -1;
160 btsq->tid = -1;
161 btsq->cpu = -1;
163 return btsq;
170 struct intel_bts_queue *btsq = queue->priv;
175 if (!btsq) {
176 btsq = intel_bts_alloc_queue(bts, queue_nr);
177 if (!btsq)
179 queue->priv = btsq;
182 btsq->cpu = queue->cpu;
183 btsq->tid = queue->tid;
189 if (!btsq->on_heap && !btsq->buffer) {
192 btsq->buffer = auxtrace_buffer__next(queue, NULL);
193 if (!btsq->buffer)
197 btsq->buffer->reference);
200 btsq->on_heap = true;
272 static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq,
276 struct intel_bts *bts = btsq->bts;
286 sample.pid = btsq->pid;
287 sample.tid = btsq->tid;
289 sample.id = btsq->bts->branches_id;
290 sample.stream_id = btsq->bts->branches_id;
292 sample.cpu = btsq->cpu;
293 sample.flags = btsq->sample_flags;
294 sample.insn_len = btsq->intel_pt_insn.length;
295 memcpy(sample.insn, btsq->intel_pt_insn.buf, INTEL_PT_INSN_BUF_SZ);
318 static int intel_bts_get_next_insn(struct intel_bts_queue *btsq, u64 ip)
320 struct machine *machine = btsq->bts->machine;
327 thread = machine__find_thread(machine, -1, btsq->tid);
335 if (intel_pt_get_insn(buf, len, x86_64, &btsq->intel_pt_insn))
362 static int intel_bts_get_branch_type(struct intel_bts_queue *btsq,
369 btsq->sample_flags = PERF_IP_FLAG_BRANCH |
372 btsq->sample_flags = 0;
373 btsq->intel_pt_insn.length = 0;
375 btsq->sample_flags = PERF_IP_FLAG_BRANCH |
377 btsq->intel_pt_insn.length = 0;
379 err = intel_bts_get_next_insn(btsq, branch->from);
381 btsq->sample_flags = 0;
382 btsq->intel_pt_insn.length = 0;
383 if (!btsq->bts->synth_opts.errors)
385 err = intel_bts_synth_error(btsq->bts, btsq->cpu,
386 btsq->pid, btsq->tid,
390 btsq->sample_flags = intel_pt_insn_type(btsq->intel_pt_insn.op);
392 if (!machine__kernel_ip(btsq->bts->machine, branch->from) &&
393 machine__kernel_ip(btsq->bts->machine, branch->to) &&
394 btsq->sample_flags != (PERF_IP_FLAG_BRANCH |
397 btsq->sample_flags = PERF_IP_FLAG_BRANCH |
406 static int intel_bts_process_buffer(struct intel_bts_queue *btsq,
412 u32 filter = btsq->bts->branches_filter;
423 if (!btsq->bts->sample_branches)
429 intel_bts_get_branch_type(btsq, branch);
430 if (btsq->bts->synth_opts.thread_stack)
431 thread_stack__event(thread, btsq->cpu, btsq->sample_flags,
434 btsq->intel_pt_insn.length,
436 if (filter && !(filter & btsq->sample_flags))
438 err = intel_bts_synth_branch_sample(btsq, branch);
445 static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp)
447 struct auxtrace_buffer *buffer = btsq->buffer, *old_buffer = buffer;
452 if (btsq->done)
455 if (btsq->pid == -1) {
456 thread = machine__find_thread(btsq->bts->machine, -1,
457 btsq->tid);
459 btsq->pid = thread__pid(thread);
461 thread = machine__findnew_thread(btsq->bts->machine, btsq->pid,
462 btsq->tid);
465 queue = &btsq->bts->queues.queue_array[btsq->queue_nr];
471 if (!btsq->bts->sampling_mode)
472 btsq->done = 1;
484 int fd = perf_data__fd(btsq->bts->session->data);
493 if (btsq->bts->snapshot_mode && !buffer->consecutive &&
499 if (!btsq->bts->synth_opts.callchain &&
500 !btsq->bts->synth_opts.thread_stack && thread &&
501 (!old_buffer || btsq->bts->sampling_mode ||
502 (btsq->bts->snapshot_mode && !buffer->consecutive)))
503 thread_stack__set_trace_nr(thread, btsq->cpu, buffer->buffer_nr + 1);
505 err = intel_bts_process_buffer(btsq, buffer, thread);
509 btsq->buffer = auxtrace_buffer__next(queue, buffer);
510 if (btsq->buffer) {
512 *timestamp = btsq->buffer->reference;
514 if (!btsq->bts->sampling_mode)
515 btsq->done = 1;
522 static int intel_bts_flush_queue(struct intel_bts_queue *btsq)
528 ret = intel_bts_process_queue(btsq, &ts);
544 struct intel_bts_queue *btsq = queue->priv;
546 if (btsq && btsq->tid == tid)
547 return intel_bts_flush_queue(btsq);
557 struct intel_bts_queue *btsq;
569 btsq = queue->priv;
573 ret = intel_bts_process_queue(btsq, &ts);
584 btsq->on_heap = false;
699 struct intel_bts_queue *btsq = priv;
701 if (!btsq)
703 free(btsq);