From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: acme@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com,
irogers@google.com, namhyung@kernel.org,
segher@kernel.crashing.org, christophe.leroy@csgroup.eu
Cc: linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com,
kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org, akanksha@linux.ibm.com
Subject: [PATCH V2 7/9] tools/perf: Update instruction tracking with add instruction
Date: Mon, 6 May 2024 17:49:04 +0530 [thread overview]
Message-ID: <20240506121906.76639-8-atrajeev@linux.vnet.ibm.com> (raw)
In-Reply-To: <20240506121906.76639-1-atrajeev@linux.vnet.ibm.com>
Update instruction tracking with add instruction. Apart from "mr"
instruction, the register state is carried on by other insns, ie,
"add, addi, addis". Since these are not memory instructions and doesn't
fall in the range of (32 to 63), add these as part of nmemonic table.
For now, add* instructions are added. There is possibility of getting
more added here. But to extract regs, still the binary code will be
used. So associate this with "load_store_ops" itself and no other
changes required.
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
.../perf/arch/powerpc/annotate/instructions.c | 21 +++++++++++++++++++
tools/perf/util/disasm.c | 1 +
2 files changed, 22 insertions(+)
diff --git a/tools/perf/arch/powerpc/annotate/instructions.c b/tools/perf/arch/powerpc/annotate/instructions.c
index cce7023951fe..1f35d8a65bb4 100644
--- a/tools/perf/arch/powerpc/annotate/instructions.c
+++ b/tools/perf/arch/powerpc/annotate/instructions.c
@@ -1,6 +1,17 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>
+/*
+ * powerpc instruction nmemonic table to associate load/store instructions with
+ * move_ops. mov_ops is used to identify add/mr to do instruction tracking.
+ */
+static struct ins powerpc__instructions[] = {
+ { .name = "mr", .ops = &load_store_ops, },
+ { .name = "addi", .ops = &load_store_ops, },
+ { .name = "addis", .ops = &load_store_ops, },
+ { .name = "add", .ops = &load_store_ops, },
+};
+
static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arch, const char *name)
{
int i;
@@ -75,6 +86,9 @@ static void update_insn_state_powerpc(struct type_state *state,
if (annotate_get_insn_location(dloc->arch, dl, &loc) < 0)
return;
+ if (!strncmp(dl->ins.name, "add", 3))
+ goto regs_check;
+
if (strncmp(dl->ins.name, "mr", 2))
return;
@@ -85,6 +99,7 @@ static void update_insn_state_powerpc(struct type_state *state,
dst->reg1 = src_reg;
}
+regs_check:
if (!has_reg_type(state, dst->reg1))
return;
@@ -115,6 +130,12 @@ static void update_insn_state_powerpc(struct type_state *state __maybe_unused, s
static int powerpc__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
{
if (!arch->initialized) {
+ arch->nr_instructions = ARRAY_SIZE(powerpc__instructions);
+ arch->instructions = calloc(arch->nr_instructions, sizeof(struct ins));
+ if (!arch->instructions)
+ return -ENOMEM;
+ memcpy(arch->instructions, powerpc__instructions, sizeof(struct ins) * arch->nr_instructions);
+ arch->nr_instructions_allocated = arch->nr_instructions;
arch->initialized = true;
arch->associate_instruction_ops = powerpc__associate_instruction_ops;
arch->objdump.comment_char = '#';
diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index ac6b8b8da38a..32cf506a9010 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -36,6 +36,7 @@ static struct ins_ops mov_ops;
static struct ins_ops nop_ops;
static struct ins_ops lock_ops;
static struct ins_ops ret_ops;
+static struct ins_ops load_store_ops;
static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops, int max_ins_name);
--
2.43.0
next prev parent reply other threads:[~2024-05-06 12:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 12:18 [PATCH V2 0/9] Add data type profiling support for powerpc Athira Rajeev
2024-05-06 12:18 ` [PATCH V2 1/9] tools/perf: Move the data structures related to register type to header file Athira Rajeev
2024-05-06 12:18 ` [PATCH V2 2/9] tools/perf: Add "update_insn_state" callback function to handle arch specific instruction tracking Athira Rajeev
2024-05-06 12:19 ` [PATCH V2 3/9] tools/perf: Fix a comment about multi_regs in extract_reg_offset function Athira Rajeev
2024-05-07 4:40 ` Namhyung Kim
2024-05-07 14:52 ` Arnaldo Carvalho de Melo
2024-05-06 12:19 ` [PATCH V2 4/9] tools/perf: Add support to capture and parse raw instruction in objdump Athira Rajeev
2024-05-07 4:57 ` Namhyung Kim
2024-05-07 9:35 ` Christophe Leroy
2024-05-09 17:26 ` Athira Rajeev
2024-05-09 20:55 ` Namhyung Kim
2024-05-10 14:26 ` Arnaldo Carvalho de Melo
2024-05-22 13:58 ` Athira Rajeev
2024-05-06 12:19 ` [PATCH V2 5/9] tools/perf: Update parameters for reg extract functions to use raw instruction on powerpc Athira Rajeev
2024-05-07 9:48 ` Christophe Leroy
2024-05-22 14:06 ` Athira Rajeev
2024-05-06 12:19 ` [PATCH V2 6/9] tools/perf: Update instruction tracking for powerpc Athira Rajeev
2024-05-07 9:52 ` Christophe Leroy
2024-05-23 13:58 ` Athira Rajeev
2024-05-06 12:19 ` Athira Rajeev [this message]
2024-05-07 9:58 ` [PATCH V2 7/9] tools/perf: Update instruction tracking with add instruction Christophe Leroy
2024-05-23 13:55 ` Athira Rajeev
2024-05-06 12:19 ` [PATCH V2 8/9] tools/perf: Add support to find global register variables using find_data_type_global_reg Athira Rajeev
2024-05-07 10:03 ` Christophe Leroy
2024-05-24 12:17 ` Athira Rajeev
2024-05-24 12:47 ` Christophe Leroy
2024-05-06 12:19 ` [PATCH V2 9/9] tools/perf: Add support for global_die to capture name of variable in case of register defined variable Athira Rajeev
2024-05-07 4:39 ` [PATCH V2 0/9] Add data type profiling support for powerpc Namhyung Kim
2024-05-13 7:32 ` Athira Rajeev
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=20240506121906.76639-8-atrajeev@linux.vnet.ibm.com \
--to=atrajeev@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=akanksha@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=disgoel@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=namhyung@kernel.org \
--cc=segher@kernel.crashing.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;
as well as URLs for NNTP newsgroup(s).