Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf arm-spe: Correctly set sample flags

Set flags on all synthesized instruction and branch samples.

Signed-off-by: Graham Woodward <graham.woodward@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Tested-by: Leo Yan <leo.yan@arm.com>
Cc: nd@arm.com
Cc: mike.leach@linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20241025143009.25419-4-graham.woodward@arm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Graham Woodward and committed by
Namhyung Kim
edff8dad c1b67c85

+19
+1
tools/perf/builtin-script.c
··· 1728 1728 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "tr end"}, 1729 1729 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_VMENTRY, "vmentry"}, 1730 1730 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_VMEXIT, "vmexit"}, 1731 + {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_BRANCH_MISS, "br miss"}, 1731 1732 {0, NULL} 1732 1733 }; 1733 1734
+17
tools/perf/util/arm-spe.c
··· 100 100 u64 timestamp; 101 101 struct thread *thread; 102 102 u64 period_instructions; 103 + u32 flags; 103 104 }; 104 105 105 106 static void arm_spe_dump(struct arm_spe *spe __maybe_unused, ··· 395 394 sample.stream_id = spe_events_id; 396 395 sample.addr = record->to_ip; 397 396 sample.weight = record->latency; 397 + sample.flags = speq->flags; 398 398 399 399 return arm_spe_deliver_synth_event(spe, speq, event, &sample); 400 400 } ··· 425 423 sample.data_src = data_src; 426 424 sample.period = spe->instructions_sample_period; 427 425 sample.weight = record->latency; 426 + sample.flags = speq->flags; 428 427 429 428 return arm_spe_deliver_synth_event(spe, speq, event, &sample); 430 429 } ··· 442 439 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V2), 443 440 {}, 444 441 }; 442 + 443 + static void arm_spe__sample_flags(struct arm_spe_queue *speq) 444 + { 445 + const struct arm_spe_record *record = &speq->decoder->record; 446 + 447 + speq->flags = 0; 448 + if (record->op & ARM_SPE_OP_BRANCH_ERET) { 449 + speq->flags = PERF_IP_FLAG_BRANCH; 450 + 451 + if (record->type & ARM_SPE_BRANCH_MISS) 452 + speq->flags |= PERF_IP_FLAG_BRANCH_MISS; 453 + } 454 + } 445 455 446 456 static void arm_spe__synth_data_source_common(const struct arm_spe_record *record, 447 457 union perf_mem_data_src *data_src) ··· 638 622 u64 data_src; 639 623 int err; 640 624 625 + arm_spe__sample_flags(speq); 641 626 data_src = arm_spe__synth_data_source(speq, record); 642 627 643 628 if (spe->sample_flc) {
+1
tools/perf/util/event.h
··· 66 66 PERF_IP_FLAG_VMEXIT = 1ULL << 12, 67 67 PERF_IP_FLAG_INTR_DISABLE = 1ULL << 13, 68 68 PERF_IP_FLAG_INTR_TOGGLE = 1ULL << 14, 69 + PERF_IP_FLAG_BRANCH_MISS = 1ULL << 15, 69 70 }; 70 71 71 72 #define PERF_IP_FLAG_CHARS "bcrosyiABExghDt"