[PATCH 6.12 0434/1276] perf arm-spe: Correctly set sample flags
Greg Kroah-Hartman
gregkh at linuxfoundation.org
Tue Jul 21 08:14:37 PDT 2026
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Graham Woodward <graham.woodward at arm.com>
[ Upstream commit edff8dad3f9a483259140fb814586b39da430a38 ]
Set flags on all synthesized instruction and branch samples.
Signed-off-by: Graham Woodward <graham.woodward at arm.com>
Reviewed-by: James Clark <james.clark at linaro.org>
Tested-by: Leo Yan <leo.yan at arm.com>
Cc: nd at arm.com
Cc: mike.leach at linaro.org
Cc: linux-arm-kernel at lists.infradead.org
Link: https://lore.kernel.org/r/20241025143009.25419-4-graham.woodward@arm.com
Signed-off-by: Namhyung Kim <namhyung at kernel.org>
Stable-dep-of: 059e9100d82a ("perf event: Fix size of synthesized sample with branch stacks")
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
tools/perf/builtin-script.c | 1 +
tools/perf/util/arm-spe.c | 17 +++++++++++++++++
tools/perf/util/event.h | 1 +
3 files changed, 19 insertions(+)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index a644787fa9e1dc..6f3db073786f96 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1728,6 +1728,7 @@ static struct {
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "tr end"},
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_VMENTRY, "vmentry"},
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_VMEXIT, "vmexit"},
+ {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_BRANCH_MISS, "br miss"},
{0, NULL}
};
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index ce34cc5a2e7163..a004e1721a1ff1 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -98,6 +98,7 @@ struct arm_spe_queue {
u64 timestamp;
struct thread *thread;
u64 period_instructions;
+ u32 flags;
};
static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
@@ -392,6 +393,7 @@ static int arm_spe__synth_branch_sample(struct arm_spe_queue *speq,
sample.stream_id = spe_events_id;
sample.addr = record->to_ip;
sample.weight = record->latency;
+ sample.flags = speq->flags;
return arm_spe_deliver_synth_event(spe, speq, event, &sample);
}
@@ -421,6 +423,7 @@ static int arm_spe__synth_instruction_sample(struct arm_spe_queue *speq,
sample.data_src = data_src;
sample.period = spe->instructions_sample_period;
sample.weight = record->latency;
+ sample.flags = speq->flags;
return arm_spe_deliver_synth_event(spe, speq, event, &sample);
}
@@ -432,6 +435,19 @@ static const struct midr_range common_ds_encoding_cpus[] = {
{},
};
+static void arm_spe__sample_flags(struct arm_spe_queue *speq)
+{
+ const struct arm_spe_record *record = &speq->decoder->record;
+
+ speq->flags = 0;
+ if (record->op & ARM_SPE_OP_BRANCH_ERET) {
+ speq->flags = PERF_IP_FLAG_BRANCH;
+
+ if (record->type & ARM_SPE_BRANCH_MISS)
+ speq->flags |= PERF_IP_FLAG_BRANCH_MISS;
+ }
+}
+
static void arm_spe__synth_data_source_common(const struct arm_spe_record *record,
union perf_mem_data_src *data_src)
{
@@ -618,6 +634,7 @@ static int arm_spe_sample(struct arm_spe_queue *speq)
u64 data_src;
int err;
+ arm_spe__sample_flags(speq);
data_src = arm_spe__synth_data_source(speq, record);
if (spe->sample_flc) {
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index f8742e6230a5ab..2744c54f404e7b 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -66,6 +66,7 @@ enum {
PERF_IP_FLAG_VMEXIT = 1ULL << 12,
PERF_IP_FLAG_INTR_DISABLE = 1ULL << 13,
PERF_IP_FLAG_INTR_TOGGLE = 1ULL << 14,
+ PERF_IP_FLAG_BRANCH_MISS = 1ULL << 15,
};
#define PERF_IP_FLAG_CHARS "bcrosyiABExghDt"
--
2.53.0
More information about the linux-arm-kernel
mailing list