[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201022145816.14069-14-leo.yan@linaro.org>
Date: Thu, 22 Oct 2020 15:58:09 +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 13/20] perf arm-spe: Add new function arm_spe_pkt_desc_event()
This patch moves out the event packet parsing from arm_spe_pkt_desc()
to the new function arm_spe_pkt_desc_event().
Signed-off-by: Leo Yan <leo.yan@...aro.org>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 136 ++++++++++--------
1 file changed, 73 insertions(+), 63 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 6eebd30f3d78..8a6b50f32a52 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
@@ -266,6 +266,78 @@ static int arm_spe_pkt_snprintf(char **buf_p, size_t *blen,
return ret;
}
+static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ u64 payload = packet->payload;
+ size_t blen = buf_len;
+ int ret;
+
+ ret = arm_spe_pkt_snprintf(&buf, &blen, "EV");
+ if (ret < 0)
+ return ret;
+
+ if (payload & 0x1) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " EXCEPTION-GEN");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x2) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " RETIRED");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x4) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-ACCESS");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x8) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-REFILL");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x10) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-ACCESS");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x20) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-REFILL");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x40) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " NOT-TAKEN");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x80) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " MISPRED");
+ if (ret < 0)
+ return ret;
+ }
+ if (packet->index > 1) {
+ if (payload & 0x100) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-ACCESS");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x200) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-REFILL");
+ if (ret < 0)
+ return ret;
+ }
+ if (payload & 0x400) {
+ ret = arm_spe_pkt_snprintf(&buf, &blen, " REMOTE-ACCESS");
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return buf_len - blen;
+}
+
static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
char *buf, size_t buf_len)
{
@@ -344,69 +416,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
case ARM_SPE_END:
return arm_spe_pkt_snprintf(&buf, &blen, "%s", name);
case ARM_SPE_EVENTS:
- ret = arm_spe_pkt_snprintf(&buf, &blen, "EV");
- if (ret < 0)
- return ret;
-
- if (payload & 0x1) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " EXCEPTION-GEN");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x2) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " RETIRED");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x4) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-ACCESS");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x8) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-REFILL");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x10) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-ACCESS");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x20) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-REFILL");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x40) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " NOT-TAKEN");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x80) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " MISPRED");
- if (ret < 0)
- return ret;
- }
- if (idx > 1) {
- if (payload & 0x100) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-ACCESS");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x200) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-REFILL");
- if (ret < 0)
- return ret;
- }
- if (payload & 0x400) {
- ret = arm_spe_pkt_snprintf(&buf, &blen, " REMOTE-ACCESS");
- if (ret < 0)
- return ret;
- }
- }
- return buf_len - blen;
-
+ return arm_spe_pkt_desc_event(packet, buf, buf_len);
case ARM_SPE_OP_TYPE:
switch (idx) {
case 0:
--
2.17.1
Powered by blists - more mailing lists