[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201106014136.14103-10-leo.yan@linaro.org>
Date: Fri, 6 Nov 2020 09:41:23 +0800
From: Leo Yan <leo.yan@...aro.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Andre Przywara <andre.przywara@....com>,
Dave Martin <Dave.Martin@....com>,
James Clark <james.clark@....com>,
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>,
Al Grant <Al.Grant@....com>, Wei Li <liwei391@...wei.com>,
linux-kernel@...r.kernel.org
Cc: Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v7 09/22] perf arm-spe: Add new function arm_spe_pkt_desc_addr()
This patch moves out the address parsing code from arm_spe_pkt_desc()
and uses the new introduced function arm_spe_pkt_desc_addr() to process
address packet.
Signed-off-by: Leo Yan <leo.yan@...aro.org>
Reviewed-by: Andre Przywara <andre.przywara@....com>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 64 +++++++++++--------
1 file changed, 38 insertions(+), 26 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 6608a73a7cbe..81f19966643d 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
@@ -288,10 +288,46 @@ static int arm_spe_pkt_snprintf(int *err, char **buf_p, size_t *blen,
return ret;
}
+static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ int ns, el, idx = packet->index;
+ u64 payload = packet->payload;
+ int err = 0;
+
+ switch (idx) {
+ case 0:
+ case 1:
+ ns = !!(packet->payload & NS_FLAG);
+ el = (packet->payload & EL_FLAG) >> 61;
+ payload &= ~(0xffULL << 56);
+ arm_spe_pkt_snprintf(&err, &buf, &buf_len,
+ "%s 0x%llx el%d ns=%d",
+ (idx == 1) ? "TGT" : "PC", payload, el, ns);
+ break;
+ case 2:
+ arm_spe_pkt_snprintf(&err, &buf, &buf_len,
+ "VA 0x%llx", payload);
+ break;
+ case 3:
+ ns = !!(packet->payload & NS_FLAG);
+ payload &= ~(0xffULL << 56);
+ arm_spe_pkt_snprintf(&err, &buf, &buf_len,
+ "PA 0x%llx ns=%d", payload, ns);
+ break;
+ default:
+ /* Unknown index */
+ err = -1;
+ break;
+ }
+
+ return err;
+}
+
int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
size_t buf_len)
{
- int ns, el, idx = packet->index;
+ int idx = packet->index;
unsigned long long payload = packet->payload;
const char *name = arm_spe_pkt_name(packet->type);
char *buf_orig = buf;
@@ -373,31 +409,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
arm_spe_pkt_snprintf(&err, &buf, &blen, "%s %lld", name, payload);
break;
case ARM_SPE_ADDRESS:
- switch (idx) {
- case 0:
- case 1:
- ns = !!(packet->payload & NS_FLAG);
- el = (packet->payload & EL_FLAG) >> 61;
- payload &= ~(0xffULL << 56);
- arm_spe_pkt_snprintf(&err, &buf, &blen,
- "%s 0x%llx el%d ns=%d",
- (idx == 1) ? "TGT" : "PC", payload, el, ns);
- break;
- case 2:
- arm_spe_pkt_snprintf(&err, &buf, &blen,
- "VA 0x%llx", payload);
- break;
- case 3:
- ns = !!(packet->payload & NS_FLAG);
- payload &= ~(0xffULL << 56);
- arm_spe_pkt_snprintf(&err, &buf, &blen,
- "PA 0x%llx ns=%d", payload, ns);
- break;
- default:
- /* Unknown index */
- err = -1;
- break;
- }
+ err = arm_spe_pkt_desc_addr(packet, buf, buf_len);
break;
case ARM_SPE_CONTEXT:
arm_spe_pkt_snprintf(&err, &buf, &blen, "%s 0x%lx el%d",
--
2.17.1
Powered by blists - more mailing lists