kernel/patches/0036-perf-arm-spe-Add-new-function-arm_spe_pkt_desc_op_ty.patch
2023-10-31 11:32:10 +08:00

147 lines
4.5 KiB
Diff

From 5428287200dbce2d9e5dbd50e4f32c5cf81a953f Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Fri, 31 Dec 2021 13:32:13 +0800
Subject: [PATCH 16/21] perf arm-spe: Add new function
arm_spe_pkt_desc_op_type()
mainline inclusion
from mainline-v5.11-rc1
commit 7488ffc4d981e19feddfe36a619051bf6216c7a1
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4NGPV
CVE: NA
-------------------------------------------------
The operation type packet is complex and contains subclass; the parsing
flow causes deep indentation; for more readable, this patch introduces
a new function arm_spe_pkt_desc_op_type() which is used for operation
type parsing.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Will Deacon <will@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Al Grant <Al.Grant@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wei Li <liwei391@huawei.com>
Link: https://lore.kernel.org/r/20201119152441.6972-13-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Wei Li <liwei391@huawei.com>
Reviewed-by: Yang Jihong <yangjihong1@huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 79 +++++++++++--------
1 file changed, 45 insertions(+), 34 deletions(-)
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index 88bcf7e5be76..d6c060f119b4 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -321,6 +321,50 @@ static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,
return err;
}
+static int arm_spe_pkt_desc_op_type(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ u64 payload = packet->payload;
+ int err = 0;
+
+ switch (packet->index) {
+ case 0:
+ arm_spe_pkt_out_string(&err, &buf, &buf_len,
+ payload & 0x1 ? "COND-SELECT" : "INSN-OTHER");
+ break;
+ case 1:
+ arm_spe_pkt_out_string(&err, &buf, &buf_len,
+ payload & 0x1 ? "ST" : "LD");
+
+ if (payload & 0x2) {
+ if (payload & 0x4)
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, " AT");
+ if (payload & 0x8)
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, " EXCL");
+ if (payload & 0x10)
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, " AR");
+ } else if (payload & 0x4) {
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, " SIMD-FP");
+ }
+ break;
+ case 2:
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, "B");
+
+ if (payload & 0x1)
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, " COND");
+ if (payload & 0x2)
+ arm_spe_pkt_out_string(&err, &buf, &buf_len, " IND");
+
+ break;
+ default:
+ /* Unknown index */
+ err = -1;
+ break;
+ }
+
+ return err;
+}
+
static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
char *buf, size_t buf_len)
{
@@ -404,40 +448,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
err = arm_spe_pkt_desc_event(packet, buf, buf_len);
break;
case ARM_SPE_OP_TYPE:
- switch (idx) {
- case 0:
- arm_spe_pkt_out_string(&err, &buf, &blen,
- payload & 0x1 ? "COND-SELECT" : "INSN-OTHER");
- break;
- case 1:
- arm_spe_pkt_out_string(&err, &buf, &blen,
- payload & 0x1 ? "ST" : "LD");
-
- if (payload & 0x2) {
- if (payload & 0x4)
- arm_spe_pkt_out_string(&err, &buf, &blen, " AT");
- if (payload & 0x8)
- arm_spe_pkt_out_string(&err, &buf, &blen, " EXCL");
- if (payload & 0x10)
- arm_spe_pkt_out_string(&err, &buf, &blen, " AR");
- } else if (payload & 0x4) {
- arm_spe_pkt_out_string(&err, &buf, &blen, " SIMD-FP");
- }
- break;
- case 2:
- arm_spe_pkt_out_string(&err, &buf, &blen, "B");
-
- if (payload & 0x1)
- arm_spe_pkt_out_string(&err, &buf, &blen, " COND");
- if (payload & 0x2)
- arm_spe_pkt_out_string(&err, &buf, &blen, " IND");
-
- break;
- default:
- /* Unknown index */
- err = -1;
- break;
- }
+ err = arm_spe_pkt_desc_op_type(packet, buf, buf_len);
break;
case ARM_SPE_DATA_SOURCE:
case ARM_SPE_TIMESTAMP:
--
2.27.0