[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201029071927.9308-18-leo.yan@linaro.org>
Date: Thu, 29 Oct 2020 15:19:23 +0800
From: Leo Yan <leo.yan@...aro.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Andre Przywara <andre.przywara@....com>,
Dave Martin <Dave.Martin@....com>,
Wei Li <liwei391@...wei.com>,
James Clark <james.clark@....com>, Al Grant <Al.Grant@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc: Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v5 17/21] perf arm-spe: Add new function arm_spe_pkt_desc_op_type()
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@...aro.org>
Reviewed-by: Andre Przywara <andre.przywara@....com>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 78 +++++++++++--------
1 file changed, 44 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 b42ba64274c1..e51b103d9973 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
@@ -304,6 +304,49 @@ static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,
return err ?: (int)(buf_len - blen);
}
+static int arm_spe_pkt_desc_op_type(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ u64 payload = packet->payload;
+ size_t blen = buf_len;
+ int err = 0;
+
+ switch (packet->index) {
+ case 0:
+ return arm_spe_pkt_snprintf(&err, &buf, &blen,
+ payload & 0x1 ? "COND-SELECT" : "INSN-OTHER");
+ case 1:
+ arm_spe_pkt_snprintf(&err, &buf, &blen,
+ payload & 0x1 ? "ST" : "LD");
+
+ if (payload & 0x2) {
+ if (payload & 0x4)
+ arm_spe_pkt_snprintf(&err, &buf, &blen, " AT");
+ if (payload & 0x8)
+ arm_spe_pkt_snprintf(&err, &buf, &blen, " EXCL");
+ if (payload & 0x10)
+ arm_spe_pkt_snprintf(&err, &buf, &blen, " AR");
+ } else if (payload & 0x4) {
+ arm_spe_pkt_snprintf(&err, &buf, &blen, " SIMD-FP");
+ }
+
+ return err ?: (int)(buf_len - blen);
+
+ case 2:
+ arm_spe_pkt_snprintf(&err, &buf, &blen, "B");
+
+ if (payload & 0x1)
+ arm_spe_pkt_snprintf(&err, &buf, &blen, " COND");
+ if (payload & 0x2)
+ arm_spe_pkt_snprintf(&err, &buf, &blen, " IND");
+
+ return err ?: (int)(buf_len - blen);
+
+ default:
+ return 0;
+ }
+}
+
static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
char *buf, size_t buf_len)
{
@@ -378,40 +421,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
case ARM_SPE_EVENTS:
return arm_spe_pkt_desc_event(packet, buf, buf_len);
case ARM_SPE_OP_TYPE:
- switch (idx) {
- case 0:
- return arm_spe_pkt_snprintf(&err, &buf, &blen,
- payload & 0x1 ? "COND-SELECT" : "INSN-OTHER");
- case 1:
- arm_spe_pkt_snprintf(&err, &buf, &blen,
- payload & 0x1 ? "ST" : "LD");
-
- if (payload & 0x2) {
- if (payload & 0x4)
- arm_spe_pkt_snprintf(&err, &buf, &blen, " AT");
- if (payload & 0x8)
- arm_spe_pkt_snprintf(&err, &buf, &blen, " EXCL");
- if (payload & 0x10)
- arm_spe_pkt_snprintf(&err, &buf, &blen, " AR");
- } else if (payload & 0x4) {
- arm_spe_pkt_snprintf(&err, &buf, &blen, " SIMD-FP");
- }
-
- return err ?: (int)(buf_len - blen);
-
- case 2:
- arm_spe_pkt_snprintf(&err, &buf, &blen, "B");
-
- if (payload & 0x1)
- arm_spe_pkt_snprintf(&err, &buf, &blen, " COND");
- if (payload & 0x2)
- arm_spe_pkt_snprintf(&err, &buf, &blen, " IND");
-
- return err ?: (int)(buf_len - blen);
-
- default:
- return 0;
- }
+ return arm_spe_pkt_desc_op_type(packet, buf, buf_len);
case ARM_SPE_DATA_SOURCE:
case ARM_SPE_TIMESTAMP:
return arm_spe_pkt_snprintf(&err, &buf, &blen, "%s %lld", name, payload);
--
2.17.1
Powered by blists - more mailing lists