Lines Matching refs:spe
84 struct arm_spe *spe; member
101 static void arm_spe_dump(struct arm_spe *spe __maybe_unused, in arm_spe_dump()
140 static void arm_spe_dump_event(struct arm_spe *spe, unsigned char *buf, in arm_spe_dump_event() argument
144 arm_spe_dump(spe, buf, len); in arm_spe_dump_event()
154 queue = &speq->spe->queues.queue_array[speq->queue_nr]; in arm_spe_get_trace()
170 int fd = perf_data__fd(speq->spe->session->data); in arm_spe_get_trace()
192 static struct arm_spe_queue *arm_spe__alloc_queue(struct arm_spe *spe, in arm_spe__alloc_queue() argument
206 speq->spe = spe; in arm_spe__alloc_queue()
231 static inline u8 arm_spe_cpumode(struct arm_spe *spe, u64 ip) in arm_spe_cpumode() argument
233 return ip >= spe->kernel_start ? in arm_spe_cpumode()
238 static void arm_spe_set_pid_tid_cpu(struct arm_spe *spe, in arm_spe_set_pid_tid_cpu() argument
244 tid = machine__get_current_tid(spe->machine, speq->cpu); in arm_spe_set_pid_tid_cpu()
252 speq->thread = machine__find_thread(spe->machine, -1, in arm_spe_set_pid_tid_cpu()
265 struct arm_spe *spe = speq->spe; in arm_spe_set_tid() local
266 int err = machine__set_current_tid(spe->machine, speq->cpu, -1, tid); in arm_spe_set_tid()
271 arm_spe_set_pid_tid_cpu(spe, &spe->queues.queue_array[speq->queue_nr]); in arm_spe_set_tid()
276 static void arm_spe_prep_sample(struct arm_spe *spe, in arm_spe_prep_sample() argument
283 if (!spe->timeless_decoding) in arm_spe_prep_sample()
284 sample->time = tsc_to_perf_time(record->timestamp, &spe->tc); in arm_spe_prep_sample()
287 sample->cpumode = arm_spe_cpumode(spe, sample->ip); in arm_spe_prep_sample()
305 arm_spe_deliver_synth_event(struct arm_spe *spe, in arm_spe_deliver_synth_event() argument
312 if (spe->synth_opts.inject) { in arm_spe_deliver_synth_event()
313 ret = arm_spe__inject_event(event, sample, spe->sample_type); in arm_spe_deliver_synth_event()
318 ret = perf_session__deliver_synth_event(spe->session, event, sample); in arm_spe_deliver_synth_event()
328 struct arm_spe *spe = speq->spe; in arm_spe__synth_mem_sample() local
333 arm_spe_prep_sample(spe, speq, event, &sample); in arm_spe__synth_mem_sample()
342 return arm_spe_deliver_synth_event(spe, speq, event, &sample); in arm_spe__synth_mem_sample()
348 struct arm_spe *spe = speq->spe; in arm_spe__synth_branch_sample() local
353 arm_spe_prep_sample(spe, speq, event, &sample); in arm_spe__synth_branch_sample()
360 return arm_spe_deliver_synth_event(spe, speq, event, &sample); in arm_spe__synth_branch_sample()
366 struct arm_spe *spe = speq->spe; in arm_spe__synth_instruction_sample() local
375 if (speq->period_instructions < spe->instructions_sample_period) in arm_spe__synth_instruction_sample()
379 arm_spe_prep_sample(spe, speq, event, &sample); in arm_spe__synth_instruction_sample()
386 sample.period = spe->instructions_sample_period; in arm_spe__synth_instruction_sample()
389 return arm_spe_deliver_synth_event(spe, speq, event, &sample); in arm_spe__synth_instruction_sample()
530 struct arm_spe *spe = speq->spe; in arm_spe_sample() local
534 data_src = arm_spe__synth_data_source(record, spe->midr); in arm_spe_sample()
536 if (spe->sample_flc) { in arm_spe_sample()
538 err = arm_spe__synth_mem_sample(speq, spe->l1d_miss_id, in arm_spe_sample()
545 err = arm_spe__synth_mem_sample(speq, spe->l1d_access_id, in arm_spe_sample()
552 if (spe->sample_llc) { in arm_spe_sample()
554 err = arm_spe__synth_mem_sample(speq, spe->llc_miss_id, in arm_spe_sample()
561 err = arm_spe__synth_mem_sample(speq, spe->llc_access_id, in arm_spe_sample()
568 if (spe->sample_tlb) { in arm_spe_sample()
570 err = arm_spe__synth_mem_sample(speq, spe->tlb_miss_id, in arm_spe_sample()
577 err = arm_spe__synth_mem_sample(speq, spe->tlb_access_id, in arm_spe_sample()
584 if (spe->sample_branch && (record->type & ARM_SPE_BRANCH_MISS)) { in arm_spe_sample()
585 err = arm_spe__synth_branch_sample(speq, spe->branch_miss_id); in arm_spe_sample()
590 if (spe->sample_remote_access && in arm_spe_sample()
592 err = arm_spe__synth_mem_sample(speq, spe->remote_access_id, in arm_spe_sample()
602 if (spe->sample_memory && data_src) { in arm_spe_sample()
603 err = arm_spe__synth_mem_sample(speq, spe->memory_id, data_src); in arm_spe_sample()
608 if (spe->sample_instructions) { in arm_spe_sample()
609 err = arm_spe__synth_instruction_sample(speq, spe->instructions_id, data_src); in arm_spe_sample()
619 struct arm_spe *spe = speq->spe; in arm_spe_run_decoder() local
623 if (!spe->kernel_start) in arm_spe_run_decoder()
624 spe->kernel_start = machine__kernel_start(spe->machine); in arm_spe_run_decoder()
651 if (!spe->timeless_decoding && record->context_id != (u64)-1) { in arm_spe_run_decoder()
656 spe->use_ctx_pkt_for_pid = true; in arm_spe_run_decoder()
687 if (!spe->timeless_decoding && speq->timestamp >= *timestamp) { in arm_spe_run_decoder()
696 static int arm_spe__setup_queue(struct arm_spe *spe, in arm_spe__setup_queue() argument
706 speq = arm_spe__alloc_queue(spe, queue_nr); in arm_spe__setup_queue()
719 if (spe->timeless_decoding) in arm_spe__setup_queue()
734 ret = auxtrace_heap__add(&spe->heap, queue_nr, speq->timestamp); in arm_spe__setup_queue()
743 static int arm_spe__setup_queues(struct arm_spe *spe) in arm_spe__setup_queues() argument
748 for (i = 0; i < spe->queues.nr_queues; i++) { in arm_spe__setup_queues()
749 ret = arm_spe__setup_queue(spe, &spe->queues.queue_array[i], i); in arm_spe__setup_queues()
757 static int arm_spe__update_queues(struct arm_spe *spe) in arm_spe__update_queues() argument
759 if (spe->queues.new_data) { in arm_spe__update_queues()
760 spe->queues.new_data = false; in arm_spe__update_queues()
761 return arm_spe__setup_queues(spe); in arm_spe__update_queues()
767 static bool arm_spe__is_timeless_decoding(struct arm_spe *spe) in arm_spe__is_timeless_decoding() argument
770 struct evlist *evlist = spe->session->evlist; in arm_spe__is_timeless_decoding()
785 static int arm_spe_process_queues(struct arm_spe *spe, u64 timestamp) in arm_spe_process_queues() argument
795 if (!spe->heap.heap_cnt) in arm_spe_process_queues()
798 if (spe->heap.heap_array[0].ordinal >= timestamp) in arm_spe_process_queues()
801 queue_nr = spe->heap.heap_array[0].queue_nr; in arm_spe_process_queues()
802 queue = &spe->queues.queue_array[queue_nr]; in arm_spe_process_queues()
805 auxtrace_heap__pop(&spe->heap); in arm_spe_process_queues()
807 if (spe->heap.heap_cnt) { in arm_spe_process_queues()
808 ts = spe->heap.heap_array[0].ordinal + 1; in arm_spe_process_queues()
819 if (!spe->use_ctx_pkt_for_pid) in arm_spe_process_queues()
820 arm_spe_set_pid_tid_cpu(spe, queue); in arm_spe_process_queues()
824 auxtrace_heap__add(&spe->heap, queue_nr, ts); in arm_spe_process_queues()
829 ret = auxtrace_heap__add(&spe->heap, queue_nr, ts); in arm_spe_process_queues()
840 static int arm_spe_process_timeless_queues(struct arm_spe *spe, pid_t tid, in arm_spe_process_timeless_queues() argument
843 struct auxtrace_queues *queues = &spe->queues; in arm_spe_process_timeless_queues()
848 struct auxtrace_queue *queue = &spe->queues.queue_array[i]; in arm_spe_process_timeless_queues()
853 arm_spe_set_pid_tid_cpu(spe, queue); in arm_spe_process_timeless_queues()
860 static int arm_spe_context_switch(struct arm_spe *spe, union perf_event *event, in arm_spe_context_switch() argument
876 return machine__set_current_tid(spe->machine, cpu, pid, tid); in arm_spe_context_switch()
886 struct arm_spe *spe = container_of(session->auxtrace, in arm_spe_process_event() local
898 timestamp = perf_time_to_tsc(sample->time, &spe->tc); in arm_spe_process_event()
902 if (timestamp || spe->timeless_decoding) { in arm_spe_process_event()
903 err = arm_spe__update_queues(spe); in arm_spe_process_event()
908 if (spe->timeless_decoding) { in arm_spe_process_event()
910 err = arm_spe_process_timeless_queues(spe, in arm_spe_process_event()
915 err = arm_spe_process_queues(spe, timestamp); in arm_spe_process_event()
919 if (!spe->use_ctx_pkt_for_pid && in arm_spe_process_event()
922 err = arm_spe_context_switch(spe, event, sample); in arm_spe_process_event()
932 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, in arm_spe_process_auxtrace_event() local
935 if (!spe->data_queued) { in arm_spe_process_auxtrace_event()
949 err = auxtrace_queues__add_event(&spe->queues, session, event, in arm_spe_process_auxtrace_event()
957 arm_spe_dump_event(spe, buffer->data, in arm_spe_process_auxtrace_event()
970 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, in arm_spe_flush() local
980 ret = arm_spe__update_queues(spe); in arm_spe_flush()
984 if (spe->timeless_decoding) in arm_spe_flush()
985 return arm_spe_process_timeless_queues(spe, -1, in arm_spe_flush()
988 ret = arm_spe_process_queues(spe, MAX_TIMESTAMP); in arm_spe_flush()
992 if (!spe->use_ctx_pkt_for_pid) in arm_spe_flush()
1013 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, in arm_spe_free_events() local
1015 struct auxtrace_queues *queues = &spe->queues; in arm_spe_free_events()
1027 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, in arm_spe_free() local
1030 auxtrace_heap__free(&spe->heap); in arm_spe_free()
1033 free(spe); in arm_spe_free()
1039 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, auxtrace); in arm_spe_evsel_is_auxtrace() local
1041 return evsel->core.attr.type == spe->pmu_type; in arm_spe_evsel_is_auxtrace()
1101 arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) in arm_spe_synth_events() argument
1111 if (evsel->core.attr.type == spe->pmu_type) { in arm_spe_synth_events()
1130 if (spe->timeless_decoding) in arm_spe_synth_events()
1135 spe->sample_type = attr.sample_type; in arm_spe_synth_events()
1151 if (spe->synth_opts.flc) { in arm_spe_synth_events()
1152 spe->sample_flc = true; in arm_spe_synth_events()
1158 spe->l1d_miss_id = id; in arm_spe_synth_events()
1166 spe->l1d_access_id = id; in arm_spe_synth_events()
1171 if (spe->synth_opts.llc) { in arm_spe_synth_events()
1172 spe->sample_llc = true; in arm_spe_synth_events()
1178 spe->llc_miss_id = id; in arm_spe_synth_events()
1186 spe->llc_access_id = id; in arm_spe_synth_events()
1191 if (spe->synth_opts.tlb) { in arm_spe_synth_events()
1192 spe->sample_tlb = true; in arm_spe_synth_events()
1198 spe->tlb_miss_id = id; in arm_spe_synth_events()
1206 spe->tlb_access_id = id; in arm_spe_synth_events()
1211 if (spe->synth_opts.branches) { in arm_spe_synth_events()
1212 spe->sample_branch = true; in arm_spe_synth_events()
1218 spe->branch_miss_id = id; in arm_spe_synth_events()
1223 if (spe->synth_opts.remote_access) { in arm_spe_synth_events()
1224 spe->sample_remote_access = true; in arm_spe_synth_events()
1230 spe->remote_access_id = id; in arm_spe_synth_events()
1235 if (spe->synth_opts.mem) { in arm_spe_synth_events()
1236 spe->sample_memory = true; in arm_spe_synth_events()
1241 spe->memory_id = id; in arm_spe_synth_events()
1246 if (spe->synth_opts.instructions) { in arm_spe_synth_events()
1247 if (spe->synth_opts.period_type != PERF_ITRACE_PERIOD_INSTRUCTIONS) { in arm_spe_synth_events()
1251 if (spe->synth_opts.period > 1) in arm_spe_synth_events()
1255 spe->sample_instructions = true; in arm_spe_synth_events()
1257 attr.sample_period = spe->synth_opts.period; in arm_spe_synth_events()
1258 spe->instructions_sample_period = attr.sample_period; in arm_spe_synth_events()
1262 spe->instructions_id = id; in arm_spe_synth_events()
1278 struct arm_spe *spe; in arm_spe_process_auxtrace_info() local
1285 spe = zalloc(sizeof(struct arm_spe)); in arm_spe_process_auxtrace_info()
1286 if (!spe) in arm_spe_process_auxtrace_info()
1289 err = auxtrace_queues__init(&spe->queues); in arm_spe_process_auxtrace_info()
1293 spe->session = session; in arm_spe_process_auxtrace_info()
1294 spe->machine = &session->machines.host; /* No kvm support */ in arm_spe_process_auxtrace_info()
1295 spe->auxtrace_type = auxtrace_info->type; in arm_spe_process_auxtrace_info()
1296 spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE]; in arm_spe_process_auxtrace_info()
1297 spe->midr = midr; in arm_spe_process_auxtrace_info()
1299 spe->timeless_decoding = arm_spe__is_timeless_decoding(spe); in arm_spe_process_auxtrace_info()
1311 spe->tc.time_shift = tc->time_shift; in arm_spe_process_auxtrace_info()
1312 spe->tc.time_mult = tc->time_mult; in arm_spe_process_auxtrace_info()
1313 spe->tc.time_zero = tc->time_zero; in arm_spe_process_auxtrace_info()
1316 spe->tc.time_cycles = tc->time_cycles; in arm_spe_process_auxtrace_info()
1317 spe->tc.time_mask = tc->time_mask; in arm_spe_process_auxtrace_info()
1318 spe->tc.cap_user_time_zero = tc->cap_user_time_zero; in arm_spe_process_auxtrace_info()
1319 spe->tc.cap_user_time_short = tc->cap_user_time_short; in arm_spe_process_auxtrace_info()
1322 spe->auxtrace.process_event = arm_spe_process_event; in arm_spe_process_auxtrace_info()
1323 spe->auxtrace.process_auxtrace_event = arm_spe_process_auxtrace_event; in arm_spe_process_auxtrace_info()
1324 spe->auxtrace.flush_events = arm_spe_flush; in arm_spe_process_auxtrace_info()
1325 spe->auxtrace.free_events = arm_spe_free_events; in arm_spe_process_auxtrace_info()
1326 spe->auxtrace.free = arm_spe_free; in arm_spe_process_auxtrace_info()
1327 spe->auxtrace.evsel_is_auxtrace = arm_spe_evsel_is_auxtrace; in arm_spe_process_auxtrace_info()
1328 session->auxtrace = &spe->auxtrace; in arm_spe_process_auxtrace_info()
1336 spe->synth_opts = *session->itrace_synth_opts; in arm_spe_process_auxtrace_info()
1338 itrace_synth_opts__set_default(&spe->synth_opts, false); in arm_spe_process_auxtrace_info()
1340 err = arm_spe_synth_events(spe, session); in arm_spe_process_auxtrace_info()
1344 err = auxtrace_queues__process_index(&spe->queues, session); in arm_spe_process_auxtrace_info()
1348 if (spe->queues.populated) in arm_spe_process_auxtrace_info()
1349 spe->data_queued = true; in arm_spe_process_auxtrace_info()
1354 auxtrace_queues__free(&spe->queues); in arm_spe_process_auxtrace_info()
1357 free(spe); in arm_spe_process_auxtrace_info()