linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf arm-spe: Add raw decoding for SPEv1.2 previous branch address
@ 2023-01-27 20:59 Rob Herring
  2023-01-30  2:09 ` Leo Yan
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2023-01-27 20:59 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim
  Cc: James Clark, Will Deacon, linux-perf-users, linux-kernel

Arm SPEv1.2 adds a new optional address packet type: previous branch
target. The recorded address is the target virtual address of the most
recently taken branch in program order.

Add support for decoding the address packet in raw dumps.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 4 +++-
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

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 2f311189c6e8..e92e1a7c8a8e 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
@@ -422,16 +422,18 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
 	int ch, pat;
 	u64 payload = packet->payload;
 	int err = 0;
+	static const char *idx_name[] = {"PC", "TGT", "VA", "PA", "LBR" };
 
 	switch (idx) {
 	case SPE_ADDR_PKT_HDR_INDEX_INS:
 	case SPE_ADDR_PKT_HDR_INDEX_BRANCH:
+	case SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH:
 		ns = !!SPE_ADDR_PKT_GET_NS(payload);
 		el = SPE_ADDR_PKT_GET_EL(payload);
 		payload = SPE_ADDR_PKT_ADDR_GET_BYTES_0_6(payload);
 		arm_spe_pkt_out_string(&err, &buf, &buf_len,
 				"%s 0x%llx el%d ns=%d",
-				(idx == 1) ? "TGT" : "PC", payload, el, ns);
+				idx_name[idx], payload, el, ns);
 		break;
 	case SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT:
 		arm_spe_pkt_out_string(&err, &buf, &buf_len,
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
index 9b970e7bf1e2..f75ed3a8a050 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
@@ -65,6 +65,7 @@ struct arm_spe_pkt {
 #define SPE_ADDR_PKT_HDR_INDEX_BRANCH		0x1
 #define SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT	0x2
 #define SPE_ADDR_PKT_HDR_INDEX_DATA_PHYS	0x3
+#define SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH	0x4
 
 /* Address packet payload */
 #define SPE_ADDR_PKT_ADDR_BYTE7_SHIFT		56
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf arm-spe: Add raw decoding for SPEv1.2 previous branch address
  2023-01-27 20:59 [PATCH] perf arm-spe: Add raw decoding for SPEv1.2 previous branch address Rob Herring
@ 2023-01-30  2:09 ` Leo Yan
  2023-02-02  1:15   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Leo Yan @ 2023-01-30  2:09 UTC (permalink / raw)
  To: Rob Herring
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	James Clark, Will Deacon, linux-perf-users, linux-kernel

On Fri, Jan 27, 2023 at 02:59:51PM -0600, Rob Herring wrote:
> Arm SPEv1.2 adds a new optional address packet type: previous branch
> target. The recorded address is the target virtual address of the most
> recently taken branch in program order.
> 
> Add support for decoding the address packet in raw dumps.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 4 +++-
>  tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> 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 2f311189c6e8..e92e1a7c8a8e 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
> @@ -422,16 +422,18 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
>  	int ch, pat;
>  	u64 payload = packet->payload;
>  	int err = 0;
> +	static const char *idx_name[] = {"PC", "TGT", "VA", "PA", "LBR" };

I know you use the "LBR" which is a naming convention from X86 arch,
Armv8 ARM defines the name "PBT", so "PBT" would be easier for us to
match code with architecture specification.

"LBR" is also fine for me, it's up to you if you want to update for
this:

Reviewed-by: Leo Yan <leo.yan@linaro.org>


>  	switch (idx) {
>  	case SPE_ADDR_PKT_HDR_INDEX_INS:
>  	case SPE_ADDR_PKT_HDR_INDEX_BRANCH:
> +	case SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH:
>  		ns = !!SPE_ADDR_PKT_GET_NS(payload);
>  		el = SPE_ADDR_PKT_GET_EL(payload);
>  		payload = SPE_ADDR_PKT_ADDR_GET_BYTES_0_6(payload);
>  		arm_spe_pkt_out_string(&err, &buf, &buf_len,
>  				"%s 0x%llx el%d ns=%d",
> -				(idx == 1) ? "TGT" : "PC", payload, el, ns);
> +				idx_name[idx], payload, el, ns);
>  		break;
>  	case SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT:
>  		arm_spe_pkt_out_string(&err, &buf, &buf_len,
> diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> index 9b970e7bf1e2..f75ed3a8a050 100644
> --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> @@ -65,6 +65,7 @@ struct arm_spe_pkt {
>  #define SPE_ADDR_PKT_HDR_INDEX_BRANCH		0x1
>  #define SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT	0x2
>  #define SPE_ADDR_PKT_HDR_INDEX_DATA_PHYS	0x3
> +#define SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH	0x4
>  
>  /* Address packet payload */
>  #define SPE_ADDR_PKT_ADDR_BYTE7_SHIFT		56
> -- 
> 2.39.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf arm-spe: Add raw decoding for SPEv1.2 previous branch address
  2023-01-30  2:09 ` Leo Yan
@ 2023-02-02  1:15   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-02-02  1:15 UTC (permalink / raw)
  To: Leo Yan
  Cc: Rob Herring, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, James Clark,
	Will Deacon, linux-perf-users, linux-kernel

Em Mon, Jan 30, 2023 at 10:09:46AM +0800, Leo Yan escreveu:
> On Fri, Jan 27, 2023 at 02:59:51PM -0600, Rob Herring wrote:
> > Arm SPEv1.2 adds a new optional address packet type: previous branch
> > target. The recorded address is the target virtual address of the most
> > recently taken branch in program order.
> > 
> > Add support for decoding the address packet in raw dumps.
> > 
> > Signed-off-by: Rob Herring <robh@kernel.org>
> > ---
> >  tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 4 +++-
> >  tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> > 
> > 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 2f311189c6e8..e92e1a7c8a8e 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
> > @@ -422,16 +422,18 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
> >  	int ch, pat;
> >  	u64 payload = packet->payload;
> >  	int err = 0;
> > +	static const char *idx_name[] = {"PC", "TGT", "VA", "PA", "LBR" };
> 
> I know you use the "LBR" which is a naming convention from X86 arch,
> Armv8 ARM defines the name "PBT", so "PBT" would be easier for us to
> match code with architecture specification.
> 
> "LBR" is also fine for me, it's up to you if you want to update for
> this:

Waiting for a response to this.

- Arnaldo
 
> Reviewed-by: Leo Yan <leo.yan@linaro.org>
> 
> 
> >  	switch (idx) {
> >  	case SPE_ADDR_PKT_HDR_INDEX_INS:
> >  	case SPE_ADDR_PKT_HDR_INDEX_BRANCH:
> > +	case SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH:
> >  		ns = !!SPE_ADDR_PKT_GET_NS(payload);
> >  		el = SPE_ADDR_PKT_GET_EL(payload);
> >  		payload = SPE_ADDR_PKT_ADDR_GET_BYTES_0_6(payload);
> >  		arm_spe_pkt_out_string(&err, &buf, &buf_len,
> >  				"%s 0x%llx el%d ns=%d",
> > -				(idx == 1) ? "TGT" : "PC", payload, el, ns);
> > +				idx_name[idx], payload, el, ns);
> >  		break;
> >  	case SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT:
> >  		arm_spe_pkt_out_string(&err, &buf, &buf_len,
> > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > index 9b970e7bf1e2..f75ed3a8a050 100644
> > --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > @@ -65,6 +65,7 @@ struct arm_spe_pkt {
> >  #define SPE_ADDR_PKT_HDR_INDEX_BRANCH		0x1
> >  #define SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT	0x2
> >  #define SPE_ADDR_PKT_HDR_INDEX_DATA_PHYS	0x3
> > +#define SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH	0x4
> >  
> >  /* Address packet payload */
> >  #define SPE_ADDR_PKT_ADDR_BYTE7_SHIFT		56
> > -- 
> > 2.39.0
> > 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-02  1:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 20:59 [PATCH] perf arm-spe: Add raw decoding for SPEv1.2 previous branch address Rob Herring
2023-01-30  2:09 ` Leo Yan
2023-02-02  1:15   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).