From: Li Huafei <lihuafei1@huawei.com>
To: <namhyung@kernel.org>, <acme@kernel.org>, <leo.yan@linux.dev>,
<james.clark@linaro.org>, <mark.rutland@arm.com>,
<john.g.garry@oracle.com>, <will@kernel.org>,
<irogers@google.com>
Cc: <mike.leach@linaro.org>, <peterz@infradead.org>,
<mingo@redhat.com>, <alexander.shishkin@linux.intel.com>,
<jolsa@kernel.org>, <kjain@linux.ibm.com>, <mhiramat@kernel.org>,
<atrajeev@linux.vnet.ibm.com>, <sesse@google.com>,
<adrian.hunter@intel.com>, <kan.liang@linux.intel.com>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-perf-users@vger.kernel.org>, <lihuafei1@huawei.com>
Subject: [PATCH 2/7] perf annotate: Advance the mem_ref check to mov__parse()
Date: Sat, 15 Mar 2025 00:21:32 +0800 [thread overview]
Message-ID: <20250314162137.528204-3-lihuafei1@huawei.com> (raw)
In-Reply-To: <20250314162137.528204-1-lihuafei1@huawei.com>
Advance the mem_ref check on x86 to mov__parse(), along with the
multi_reg check, to make annotate_get_insn_location() more concise.
Signed-off-by: Li Huafei <lihuafei1@huawei.com>
---
tools/perf/util/annotate.c | 9 ++++-----
tools/perf/util/disasm.c | 8 ++++++++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 31bb326b07a6..860ea6c72411 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2442,18 +2442,17 @@ int annotate_get_insn_location(struct arch *arch, struct disasm_line *dl,
continue;
}
+ op_loc->mem_ref = mem_ref;
+ op_loc->multi_regs = multi_regs;
+
/*
* For powerpc, call get_powerpc_regs function which extracts the
* required fields for op_loc, ie reg1, reg2, offset from the
* raw instruction.
*/
if (arch__is(arch, "powerpc")) {
- op_loc->mem_ref = mem_ref;
- op_loc->multi_regs = multi_regs;
get_powerpc_regs(dl->raw.raw_insn, !i, op_loc);
- } else if (strchr(insn_str, arch->objdump.memory_ref_char)) {
- op_loc->mem_ref = true;
- op_loc->multi_regs = multi_regs;
+ } else if (mem_ref) {
extract_reg_offset(arch, insn_str, op_loc);
} else {
char *s, *p = NULL;
diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index 50c5c206b70e..d91526cff9df 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -607,6 +607,12 @@ static bool check_multi_regs(struct arch *arch, const char *op)
return count > 1;
}
+/* Check whether the operand accesses memory. */
+static bool check_memory_ref(struct arch *arch, const char *op)
+{
+ return strchr(op, arch->objdump.memory_ref_char) != NULL;
+}
+
static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms __maybe_unused,
struct disasm_line *dl __maybe_unused)
{
@@ -635,6 +641,7 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_sy
if (ops->source.raw == NULL)
return -1;
+ ops->source.mem_ref = check_memory_ref(arch, ops->source.raw);
ops->source.multi_regs = check_multi_regs(arch, ops->source.raw);
target = skip_spaces(++s);
@@ -657,6 +664,7 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_sy
if (ops->target.raw == NULL)
goto out_free_source;
+ ops->target.mem_ref = check_memory_ref(arch, ops->target.raw);
ops->target.multi_regs = check_multi_regs(arch, ops->target.raw);
if (comment == NULL)
--
2.25.1
next prev parent reply other threads:[~2025-03-14 8:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 16:21 [PATCH 0/7] Add data type profiling support for arm64 Li Huafei
2025-03-14 16:21 ` [PATCH 1/7] perf annotate: Handle arm64 load and store instructions Li Huafei
2025-03-18 1:32 ` Namhyung Kim
2025-03-18 17:15 ` Leo Yan
2025-03-14 16:21 ` Li Huafei [this message]
2025-03-18 18:02 ` [PATCH 2/7] perf annotate: Advance the mem_ref check to mov__parse() Leo Yan
2025-03-14 16:21 ` [PATCH 3/7] perf annotate: Add 'extract_reg_offset' callback function to extract register number and access offset Li Huafei
2025-03-14 16:21 ` [PATCH 4/7] perf annotate: Support for the 'extract_reg_offset' callback function in arm64 Li Huafei
2025-03-18 1:45 ` Namhyung Kim
2025-03-14 16:21 ` [PATCH 5/7] perf annotate-data: Support instruction tracking for arm64 Li Huafei
2025-03-18 1:51 ` Namhyung Kim
2025-03-14 16:21 ` [PATCH 6/7] perf annotate-data: Handle arm64 global variable access Li Huafei
2025-03-18 2:01 ` Namhyung Kim
2025-03-14 16:21 ` [PATCH 7/7] perf annotate-data: Handle the access to the 'current' pointer on arm64 Li Huafei
2025-03-18 2:06 ` Namhyung Kim
2025-03-18 1:25 ` [PATCH 0/7] Add data type profiling support for arm64 Namhyung Kim
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=20250314162137.528204-3-lihuafei1@huawei.com \
--to=lihuafei1@huawei.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=leo.yan@linux.dev \
--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=mhiramat@kernel.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=sesse@google.com \
--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®