mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	James Clark <james.clark@linaro.org>,
	Mike Leach <mike.leach@linaro.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Liang, Kan" <kan.liang@linux.intel.com>,
	Will Deacon <will@kernel.org>,
	Graham Woodward <graham.woodward@arm.com>,
	Paschalis.Mpeis@arm.com, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: Leo Yan <leo.yan@arm.com>
Subject: [PATCH v3 06/12] perf arm-spe: Fix load-store operation checking
Date: Mon, 17 Feb 2025 19:59:02 +0000	[thread overview]
Message-ID: <20250217195908.176207-7-leo.yan@arm.com> (raw)
In-Reply-To: <20250217195908.176207-1-leo.yan@arm.com>

The ARM_SPE_OP_LD and ARM_SPE_OP_ST operations are secondary operation
type, they are overlapping with other second level's operation types
belonging to SVE and branch operations.  As a result, a non load-store
operation can be parsed for data source and memory sample.

To fix the issue, this commit introduces a is_ldst_op() macro for
checking LDST operation, and apply the checking when synthesize data
source and memory samples.

Fixes: a89dbc9b988f ("perf arm-spe: Set sample's data source field")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/util/arm-spe.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 251d214adf7f..0e8e05c87fd7 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -37,6 +37,8 @@
 #include "../../arch/arm64/include/asm/cputype.h"
 #define MAX_TIMESTAMP (~0ULL)
 
+#define is_ldst_op(op)		(!!((op) & ARM_SPE_OP_LDST))
+
 struct arm_spe {
 	struct auxtrace			auxtrace;
 	struct auxtrace_queues		queues;
@@ -681,6 +683,10 @@ static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
 {
 	union perf_mem_data_src	data_src = { .mem_op = PERF_MEM_OP_NA };
 
+	/* Only synthesize data source for LDST operations */
+	if (!is_ldst_op(record->op))
+		return 0;
+
 	if (record->op & ARM_SPE_OP_LD)
 		data_src.mem_op = PERF_MEM_OP_LOAD;
 	else if (record->op & ARM_SPE_OP_ST)
@@ -779,7 +785,7 @@ static int arm_spe_sample(struct arm_spe_queue *speq)
 	 * When data_src is zero it means the record is not a memory operation,
 	 * skip to synthesize memory sample for this case.
 	 */
-	if (spe->sample_memory && data_src) {
+	if (spe->sample_memory && is_ldst_op(record->op)) {
 		err = arm_spe__synth_mem_sample(speq, spe->memory_id, data_src);
 		if (err)
 			return err;
-- 
2.34.1


  parent reply	other threads:[~2025-02-17 19:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 19:58 [PATCH v3 00/12] perf script: Refactor branch flags for Arm SPE Leo Yan
2025-02-17 19:58 ` [PATCH v3 01/12] perf script: Make printing flags reliable Leo Yan
2025-03-03 10:44   ` Adrian Hunter
2025-03-03 16:22     ` Leo Yan
2025-03-03 15:05       ` Adrian Hunter
2025-03-03 18:11         ` Leo Yan
2025-03-03 16:56           ` Adrian Hunter
2025-03-03 18:49             ` Leo Yan
2025-02-17 19:58 ` [PATCH v3 02/12] perf script: Refactor sample_flags_to_name() function Leo Yan
2025-02-17 19:58 ` [PATCH v3 03/12] perf script: Separate events from branch types Leo Yan
2025-02-17 19:59 ` [PATCH v3 04/12] perf script: Add not taken event for branches Leo Yan
2025-02-17 19:59 ` [PATCH v3 05/12] perf script: Add not taken event for branch stack Leo Yan
2025-02-17 19:59 ` Leo Yan [this message]
2025-02-26 13:33   ` [PATCH v3 06/12] perf arm-spe: Fix load-store operation checking James Clark
2025-02-17 19:59 ` [PATCH v3 07/12] perf arm-spe: Extend branch operations Leo Yan
2025-02-17 19:59 ` [PATCH v3 08/12] perf arm-spe: Decode transactional event Leo Yan
2025-02-17 19:59 ` [PATCH v3 09/12] perf arm-spe: Fill branch operations and events to record Leo Yan
2025-02-17 19:59 ` [PATCH v3 10/12] perf arm-spe: Set sample flags with supplement info Leo Yan
2025-02-17 19:59 ` [PATCH v3 11/12] perf arm-spe: Add branch stack Leo Yan
2025-02-17 19:59 ` [PATCH v3 12/12] perf arm-spe: Support previous branch target (PBT) address Leo Yan
2025-03-03  9:38 ` [PATCH v3 00/12] perf script: Refactor branch flags for Arm SPE Leo Yan
2025-03-03 21:00   ` Namhyung Kim
2025-03-04 11:33     ` Leo Yan
2025-03-04 18:43       ` Namhyung Kim
2025-03-05  9:53         ` Leo Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250217195908.176207-7-leo.yan@arm.com \
    --to=leo.yan@arm.com \
    --cc=Paschalis.Mpeis@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=graham.woodward@arm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@linaro.org \
    --cc=namhyung@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®