[PATCH v2 10/14] perf arm-spe: Store operation types in packet

From: Leo Yan
Date: Tue Sep 01 2020 - 04:39:18 EST


This patch is to store operation types into packet structure, this can
be used by frontend to generate memory accessing info for samples.

Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>
---
tools/perf/util/arm-spe-decoder/arm-spe-decoder.c | 11 +++++++++++
tools/perf/util/arm-spe-decoder/arm-spe-decoder.h | 6 ++++++
2 files changed, 17 insertions(+)

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
index 1c430657939f..7bf787c47f5b 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
@@ -170,6 +170,17 @@ static int arm_spe_read_record(struct arm_spe_decoder *decoder)
case ARM_SPE_CONTEXT:
break;
case ARM_SPE_OP_TYPE:
+ /*
+ * When operation type packet header's class equals 1,
+ * the payload's least significant bit (LSB) indicates
+ * the operation type: load/swap or store.
+ */
+ if (idx == 1) {
+ if (payload & 0x1)
+ decoder->record.op = ARM_SPE_ST;
+ else
+ decoder->record.op = ARM_SPE_LD;
+ }
break;
case ARM_SPE_EVENTS:
if (payload & SPE_EVT_PKT_L1D_REFILL)
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
index 31d1776785de..3273cee95ea1 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
@@ -24,9 +24,15 @@ enum arm_spe_sample_type {
ARM_SPE_REMOTE_ACCESS = 1 << 7,
};

+enum arm_spe_op_type {
+ ARM_SPE_LD = 1 << 0,
+ ARM_SPE_ST = 1 << 1,
+};
+
struct arm_spe_record {
enum arm_spe_sample_type type;
int err;
+ u32 op;
u64 from_ip;
u64 to_ip;
u64 timestamp;
--
2.20.1