From: Dengcheng Zhu <dzhu@wavecomp.com> To: "peterz@infradead.org" <peterz@infradead.org>, "mingo@redhat.com" <mingo@redhat.com>, "acme@kernel.org" <acme@kernel.org>, "mark.rutland@arm.com" <mark.rutland@arm.com>, "alexander.shishkin@linux.intel.com" <alexander.shishkin@linux.intel.com>, "jolsa@redhat.com" <jolsa@redhat.com>, "namhyung@kernel.org" <namhyung@kernel.org>, "paulburton@kernel.org" <paulburton@kernel.org> Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>, Dengcheng Zhu <dzhu@wavecomp.com> Subject: [PATCH v2] MIPS: perf: Initial annotation support Date: Wed, 15 Jan 2020 21:54:42 +0000 [thread overview] Message-ID: <20200115215433.12793-1-dzhu@wavecomp.com> (raw) 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@kernel.org> Signed-off-by: Dengcheng Zhu <dzhu@wavecomp.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
reply other threads:[~2020-01-15 21:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200115215433.12793-1-dzhu@wavecomp.com \ --to=dzhu@wavecomp.com \ --cc=acme@kernel.org \ --cc=alexander.shishkin@linux.intel.com \ --cc=jolsa@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mips@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mingo@redhat.com \ --cc=namhyung@kernel.org \ --cc=paulburton@kernel.org \ --cc=peterz@infradead.org \ --subject='Re: [PATCH v2] MIPS: perf: Initial annotation support' \ /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
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).