[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201022145816.14069-12-leo.yan@linaro.org>
Date: Thu, 22 Oct 2020 15:58:07 +0100
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>,
Wei Li <liwei391@...wei.com>,
James Clark <james.clark@....com>,
Andre Przywara <andre.przywara@....com>,
Al Grant <Al.Grant@....com>, Dave Martin <Dave.Martin@....com>,
linux-kernel@...r.kernel.org
Cc: Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v3 11/20] perf arm-spe: Add new function arm_spe_pkt_desc_counter()
This patch moves out the counter packet parsing code from
arm_spe_pkt_desc() to the new function arm_spe_pkt_desc_counter().
Signed-off-by: Leo Yan <leo.yan@...aro.org>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 64 +++++++++++--------
1 file changed, 37 insertions(+), 27 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 1fc07c693640..023bcc9be3cc 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
@@ -293,6 +293,42 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
}
}
+static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ u64 payload = packet->payload;
+ const char *name = arm_spe_pkt_name(packet->type);
+ size_t blen = buf_len;
+ int ret;
+
+ ret = arm_spe_pkt_snprintf(&buf, &blen, "%s %d ", name,
+ (unsigned short)payload);
+ if (ret < 0)
+ return ret;
+
+ switch (packet->index) {
+ case 0:
+ ret = arm_spe_pkt_snprintf(&buf, &blen, "TOT");
+ if (ret < 0)
+ return ret;
+ break;
+ case 1:
+ ret = arm_spe_pkt_snprintf(&buf, &blen, "ISSUE");
+ if (ret < 0)
+ return ret;
+ break;
+ case 2:
+ ret = arm_spe_pkt_snprintf(&buf, &blen, "XLAT");
+ if (ret < 0)
+ return ret;
+ break;
+ default:
+ break;
+ }
+
+ return buf_len - blen;
+}
+
int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
size_t buf_len)
{
@@ -435,33 +471,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
return arm_spe_pkt_snprintf(&buf, &blen, "%s 0x%lx el%d",
name, (unsigned long)payload, idx + 1);
case ARM_SPE_COUNTER:
- ret = arm_spe_pkt_snprintf(&buf, &blen, "%s %d ", name,
- (unsigned short)payload);
- if (ret < 0)
- return ret;
-
- switch (idx) {
- case 0:
- ret = arm_spe_pkt_snprintf(&buf, &blen, "TOT");
- if (ret < 0)
- return ret;
- break;
- case 1:
- ret = arm_spe_pkt_snprintf(&buf, &blen, "ISSUE");
- if (ret < 0)
- return ret;
- break;
- case 2:
- ret = arm_spe_pkt_snprintf(&buf, &blen, "XLAT");
- if (ret < 0)
- return ret;
- break;
- default:
- break;
- }
-
- return buf_len - blen;
-
+ return arm_spe_pkt_desc_counter(packet, buf, buf_len);
default:
break;
}
--
2.17.1
Powered by blists - more mailing lists