[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20200115215433.12793-1-dzhu@wavecomp.com>
Date: Wed, 15 Jan 2020 21:54:42 +0000
From: Dengcheng Zhu <dzhu@...ecomp.com>
To: "peterz@...radead.org" <peterz@...radead.org>,
"mingo@...hat.com" <mingo@...hat.com>,
"acme@...nel.org" <acme@...nel.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"alexander.shishkin@...ux.intel.com"
<alexander.shishkin@...ux.intel.com>,
"jolsa@...hat.com" <jolsa@...hat.com>,
"namhyung@...nel.org" <namhyung@...nel.org>,
"paulburton@...nel.org" <paulburton@...nel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
Dengcheng Zhu <dzhu@...ecomp.com>
Subject: [PATCH v2] MIPS: perf: Initial annotation support
Add support for perf annotate on MIPS.
Example of `ls /bin` annotation:
Percent | Source code & Disassembly of libc-2.24.so for cycles (46 samples, percent: local period)
--------------------------------------------------------------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 00000000000a53a0 <strlen@@GLIBC_2.0>:
4.22 : a53a0: andi v0,a0,0x7
0.00 : a53a4: beqzc v0,a54c4 <strlen@@GLIBC_2.0+0x124>
0.00 : a53a8: lb v0,0(a0)
0.00 : a53ac: beqzc v0,a54cc <strlen@@GLIBC_2.0+0x12c>
0.00 : a53b0: move v0,a0
0.00 : a53b4: bc a53c0 <strlen@@GLIBC_2.0+0x20>
2.16 : a53b8: lb v1,0(v0)
9.07 : a53bc: beqzc v1,a5468 <strlen@@GLIBC_2.0+0xc8>
0.00 : a53c0: daddiu v0,v0,1
...
Reviewed-by: Paul Burton <paulburton@...nel.org>
Signed-off-by: Dengcheng Zhu <dzhu@...ecomp.com>
---
Changes:
v2 - v1:
* Adding compact version and branch-likely version instructions.
* Adding jalx and jr.hb instructions.
tools/perf/arch/mips/Build | 2 +-
tools/perf/arch/mips/annotate/instructions.c | 41 ++++++++++++++++++++
tools/perf/util/annotate.c | 8 ++++
3 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 tools/perf/arch/mips/annotate/instructions.c
diff --git a/tools/perf/arch/mips/Build b/tools/perf/arch/mips/Build
index 1bb8bf6d7fd4..e4e5f33c84d8 100644
--- a/tools/perf/arch/mips/Build
+++ b/tools/perf/arch/mips/Build
@@ -1 +1 @@
-# empty
+perf-y += util/
diff --git a/tools/perf/arch/mips/annotate/instructions.c b/tools/perf/arch/mips/annotate/instructions.c
new file mode 100644
index 000000000000..c479b458dc10
--- /dev/null
+++ b/tools/perf/arch/mips/annotate/instructions.c
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0
+
+static struct ins_ops *mips__associate_instruction_ops(struct arch *arch, const char *name)
+{
+ struct ins_ops *ops;
+
+ /*
+ * Including compact version (beqzalc) and branch-likely
+ * (e.g. bgezall) versions
+ */
+ if (!strncmp(name, "bal", 3) ||
+ !strncmp(name, "bgezal", 6) ||
+ !strncmp(name, "bltzal", 6) ||
+ !strncmp(name, "bgtzal", 6) ||
+ !strncmp(name, "blezal", 6) ||
+ !strncmp(name, "beqzal", 6) ||
+ !strncmp(name, "bnezal", 6) ||
+ !strncmp(name, "jal", 3) || /* jal[rx]? */
+ !strcmp(name, "jialc"))
+ ops = &call_ops;
+ else if (!strncmp(name, "jr", 2)) /* jr(\.hb)? */
+ ops = &ret_ops;
+ else if (name[0] == 'j' || name[0] == 'b')
+ ops = &jump_ops;
+ else
+ return NULL;
+
+ arch__associate_ins_ops(arch, name, ops);
+
+ return ops;
+}
+
+static int mips__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
+{
+ if (!arch->initialized) {
+ arch->associate_instruction_ops = mips__associate_instruction_ops;
+ arch->initialized = true;
+ }
+
+ return 0;
+}
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index f5e77ed237e8..aeae04a3ff0d 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -153,6 +153,7 @@ static int arch__associate_ins_ops(struct arch* arch, const char *name, struct i
#include "arch/arm/annotate/instructions.c"
#include "arch/arm64/annotate/instructions.c"
#include "arch/csky/annotate/instructions.c"
+#include "arch/mips/annotate/instructions.c"
#include "arch/x86/annotate/instructions.c"
#include "arch/powerpc/annotate/instructions.c"
#include "arch/s390/annotate/instructions.c"
@@ -175,6 +176,13 @@ static struct arch architectures[] = {
.name = "csky",
.init = csky__annotate_init,
},
+ {
+ .name = "mips",
+ .init = mips__annotate_init,
+ .objdump = {
+ .comment_char = '#',
+ },
+ },
{
.name = "x86",
.init = x86__annotate_init,
--
2.17.1
Powered by blists - more mailing lists