Lines Matching defs:spe
33 #include "arm-spe.h"
34 #include "arm-spe-decoder/arm-spe-decoder.h"
35 #include "arm-spe-decoder/arm-spe-pkt-decoder.h"
84 struct arm_spe *spe;
101 static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
140 static void arm_spe_dump_event(struct arm_spe *spe, unsigned char *buf,
144 arm_spe_dump(spe, buf, len);
154 queue = &speq->spe->queues.queue_array[speq->queue_nr];
170 int fd = perf_data__fd(speq->spe->session->data);
192 static struct arm_spe_queue *arm_spe__alloc_queue(struct arm_spe *spe,
206 speq->spe = spe;
231 static inline u8 arm_spe_cpumode(struct arm_spe *spe, u64 ip)
233 return ip >= spe->kernel_start ?
238 static void arm_spe_set_pid_tid_cpu(struct arm_spe *spe,
244 tid = machine__get_current_tid(spe->machine, speq->cpu);
252 speq->thread = machine__find_thread(spe->machine, -1,
265 struct arm_spe *spe = speq->spe;
266 int err = machine__set_current_tid(spe->machine, speq->cpu, -1, tid);
271 arm_spe_set_pid_tid_cpu(spe, &spe->queues.queue_array[speq->queue_nr]);
295 static void arm_spe_prep_sample(struct arm_spe *spe,
302 if (!spe->timeless_decoding)
303 sample->time = tsc_to_perf_time(record->timestamp, &spe->tc);
306 sample->cpumode = arm_spe_cpumode(spe, sample->ip);
325 arm_spe_deliver_synth_event(struct arm_spe *spe,
332 if (spe->synth_opts.inject) {
333 ret = arm_spe__inject_event(event, sample, spe->sample_type);
338 ret = perf_session__deliver_synth_event(spe->session, event, sample);
348 struct arm_spe *spe = speq->spe;
353 arm_spe_prep_sample(spe, speq, event, &sample);
362 return arm_spe_deliver_synth_event(spe, speq, event, &sample);
368 struct arm_spe *spe = speq->spe;
373 arm_spe_prep_sample(spe, speq, event, &sample);
380 return arm_spe_deliver_synth_event(spe, speq, event, &sample);
386 struct arm_spe *spe = speq->spe;
395 if (speq->period_instructions < spe->instructions_sample_period)
399 arm_spe_prep_sample(spe, speq, event, &sample);
406 sample.period = spe->instructions_sample_period;
409 return arm_spe_deliver_synth_event(spe, speq, event, &sample);
550 struct arm_spe *spe = speq->spe;
554 data_src = arm_spe__synth_data_source(record, spe->midr);
556 if (spe->sample_flc) {
558 err = arm_spe__synth_mem_sample(speq, spe->l1d_miss_id,
565 err = arm_spe__synth_mem_sample(speq, spe->l1d_access_id,
572 if (spe->sample_llc) {
574 err = arm_spe__synth_mem_sample(speq, spe->llc_miss_id,
581 err = arm_spe__synth_mem_sample(speq, spe->llc_access_id,
588 if (spe->sample_tlb) {
590 err = arm_spe__synth_mem_sample(speq, spe->tlb_miss_id,
597 err = arm_spe__synth_mem_sample(speq, spe->tlb_access_id,
604 if (spe->sample_branch && (record->type & ARM_SPE_BRANCH_MISS)) {
605 err = arm_spe__synth_branch_sample(speq, spe->branch_miss_id);
610 if (spe->sample_remote_access &&
612 err = arm_spe__synth_mem_sample(speq, spe->remote_access_id,
622 if (spe->sample_memory && data_src) {
623 err = arm_spe__synth_mem_sample(speq, spe->memory_id, data_src);
628 if (spe->sample_instructions) {
629 err = arm_spe__synth_instruction_sample(speq, spe->instructions_id, data_src);
639 struct arm_spe *spe = speq->spe;
643 if (!spe->kernel_start)
644 spe->kernel_start = machine__kernel_start(spe->machine);
671 if (!spe->timeless_decoding && record->context_id != (u64)-1) {
676 spe->use_ctx_pkt_for_pid = true;
707 if (!spe->timeless_decoding && speq->timestamp >= *timestamp) {
716 static int arm_spe__setup_queue(struct arm_spe *spe,
726 speq = arm_spe__alloc_queue(spe, queue_nr);
739 if (spe->timeless_decoding)
754 ret = auxtrace_heap__add(&spe->heap, queue_nr, speq->timestamp);
763 static int arm_spe__setup_queues(struct arm_spe *spe)
768 for (i = 0; i < spe->queues.nr_queues; i++) {
769 ret = arm_spe__setup_queue(spe, &spe->queues.queue_array[i], i);
777 static int arm_spe__update_queues(struct arm_spe *spe)
779 if (spe->queues.new_data) {
780 spe->queues.new_data = false;
781 return arm_spe__setup_queues(spe);
787 static bool arm_spe__is_timeless_decoding(struct arm_spe *spe)
790 struct evlist *evlist = spe->session->evlist;
805 static int arm_spe_process_queues(struct arm_spe *spe, u64 timestamp)
815 if (!spe->heap.heap_cnt)
818 if (spe->heap.heap_array[0].ordinal >= timestamp)
821 queue_nr = spe->heap.heap_array[0].queue_nr;
822 queue = &spe->queues.queue_array[queue_nr];
825 auxtrace_heap__pop(&spe->heap);
827 if (spe->heap.heap_cnt) {
828 ts = spe->heap.heap_array[0].ordinal + 1;
839 if (!spe->use_ctx_pkt_for_pid)
840 arm_spe_set_pid_tid_cpu(spe, queue);
844 auxtrace_heap__add(&spe->heap, queue_nr, ts);
849 ret = auxtrace_heap__add(&spe->heap, queue_nr, ts);
860 static int arm_spe_process_timeless_queues(struct arm_spe *spe, pid_t tid,
863 struct auxtrace_queues *queues = &spe->queues;
868 struct auxtrace_queue *queue = &spe->queues.queue_array[i];
873 arm_spe_set_pid_tid_cpu(spe, queue);
880 static int arm_spe_context_switch(struct arm_spe *spe, union perf_event *event,
896 return machine__set_current_tid(spe->machine, cpu, pid, tid);
906 struct arm_spe *spe = container_of(session->auxtrace,
918 timestamp = perf_time_to_tsc(sample->time, &spe->tc);
922 if (timestamp || spe->timeless_decoding) {
923 err = arm_spe__update_queues(spe);
928 if (spe->timeless_decoding) {
930 err = arm_spe_process_timeless_queues(spe,
935 err = arm_spe_process_queues(spe, timestamp);
939 if (!spe->use_ctx_pkt_for_pid &&
942 err = arm_spe_context_switch(spe, event, sample);
952 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe,
955 if (!spe->data_queued) {
969 err = auxtrace_queues__add_event(&spe->queues, session, event,
977 arm_spe_dump_event(spe, buffer->data,
990 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe,
1000 ret = arm_spe__update_queues(spe);
1004 if (spe->timeless_decoding)
1005 return arm_spe_process_timeless_queues(spe, -1,
1008 ret = arm_spe_process_queues(spe, MAX_TIMESTAMP);
1012 if (!spe->use_ctx_pkt_for_pid)
1033 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe,
1035 struct auxtrace_queues *queues = &spe->queues;
1047 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe,
1050 auxtrace_heap__free(&spe->heap);
1053 free(spe);
1059 struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, auxtrace);
1061 return evsel->core.attr.type == spe->pmu_type;
1121 arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)
1131 if (evsel->core.attr.type == spe->pmu_type) {
1150 if (spe->timeless_decoding)
1155 spe->sample_type = attr.sample_type;
1171 if (spe->synth_opts.flc) {
1172 spe->sample_flc = true;
1178 spe->l1d_miss_id = id;
1186 spe->l1d_access_id = id;
1191 if (spe->synth_opts.llc) {
1192 spe->sample_llc = true;
1198 spe->llc_miss_id = id;
1206 spe->llc_access_id = id;
1211 if (spe->synth_opts.tlb) {
1212 spe->sample_tlb = true;
1218 spe->tlb_miss_id = id;
1226 spe->tlb_access_id = id;
1231 if (spe->synth_opts.branches) {
1232 spe->sample_branch = true;
1238 spe->branch_miss_id = id;
1243 if (spe->synth_opts.remote_access) {
1244 spe->sample_remote_access = true;
1250 spe->remote_access_id = id;
1255 if (spe->synth_opts.mem) {
1256 spe->sample_memory = true;
1261 spe->memory_id = id;
1266 if (spe->synth_opts.instructions) {
1267 if (spe->synth_opts.period_type != PERF_ITRACE_PERIOD_INSTRUCTIONS) {
1271 if (spe->synth_opts.period > 1)
1275 spe->sample_instructions = true;
1277 attr.sample_period = spe->synth_opts.period;
1278 spe->instructions_sample_period = attr.sample_period;
1282 spe->instructions_id = id;
1298 struct arm_spe *spe;
1305 spe = zalloc(sizeof(struct arm_spe));
1306 if (!spe)
1309 err = auxtrace_queues__init(&spe->queues);
1313 spe->session = session;
1314 spe->machine = &session->machines.host; /* No kvm support */
1315 spe->auxtrace_type = auxtrace_info->type;
1316 spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE];
1317 spe->midr = midr;
1319 spe->timeless_decoding = arm_spe__is_timeless_decoding(spe);
1325 * in "spe->tc", which is used for later conversion between clock
1331 spe->tc.time_shift = tc->time_shift;
1332 spe->tc.time_mult = tc->time_mult;
1333 spe->tc.time_zero = tc->time_zero;
1336 spe->tc.time_cycles = tc->time_cycles;
1337 spe->tc.time_mask = tc->time_mask;
1338 spe->tc.cap_user_time_zero = tc->cap_user_time_zero;
1339 spe->tc.cap_user_time_short = tc->cap_user_time_short;
1342 spe->auxtrace.process_event = arm_spe_process_event;
1343 spe->auxtrace.process_auxtrace_event = arm_spe_process_auxtrace_event;
1344 spe->auxtrace.flush_events = arm_spe_flush;
1345 spe->auxtrace.free_events = arm_spe_free_events;
1346 spe->auxtrace.free = arm_spe_free;
1347 spe->auxtrace.evsel_is_auxtrace = arm_spe_evsel_is_auxtrace;
1348 session->auxtrace = &spe->auxtrace;
1356 spe->synth_opts = *session->itrace_synth_opts;
1358 itrace_synth_opts__set_default(&spe->synth_opts, false);
1360 err = arm_spe_synth_events(spe, session);
1364 err = auxtrace_queues__process_index(&spe->queues, session);
1368 if (spe->queues.populated)
1369 spe->data_queued = true;
1374 auxtrace_queues__free(&spe->queues);
1377 free(spe);