Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp309261pxk; Wed, 23 Sep 2020 03:59:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwutfZfnZCXmapA0eVw6HiqVlQFm6GDlzL0o/zQGCN9wJl+iUSrEETGymkaCwvgiWy7WZ/h X-Received: by 2002:aa7:d805:: with SMTP id v5mr9104683edq.29.1600858778552; Wed, 23 Sep 2020 03:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600858778; cv=none; d=google.com; s=arc-20160816; b=izUbdHh8/Ime+k4h2QmJlQ7U3SYKLqEyQcXGI3vww/DrRFg/MzuN4jyndeq8JOcky3 XrQucXHp/uXv8NpdCBnATx4sp4OdaFEpuabXx4Qp/jUT74mqwBj7fY6dYasIa1tH9cr/ UlOKElwQhkMTfjG/GJwvOg8odv39hxHTgNYNYITIA+ChBuf+flS6NkXBhxxnuj+58W1x JlOsV2jWseAzcPXUyTIZVNH7r0srOlmpoUD6glyUZwP+X5Ra8kDOMrls+r7VFTfkJEgX 2CcVeRE4AIObZjg7/+I1MJny3Np5I7qHRb16+/TsOr5Eoc/FZmAVaxwoOlK/E9KWvdJY BR3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=lQ9gwnx6teVLVqBKEvoasPSd5jyOqLKdLg7x2SzQxhU=; b=oIjDZvKel0gXC2CeXT+glABHV27gen4hzZJOrDwhpLNCsKh6PPsR1jGUBy9/okT+ii XzzHCGGrP3BA2QpJddK1sdbFceeP56+7yHgU8zPwshh2Ii35ZAz+FCDkiBOzZjQW/GiA xYNrok0UsN3GzH6wvbqgb8dBrvKREGrOztnQrL9zLTAsIId4vQmplWX6Ctf6LSWpAPa5 oIz1OnhwfA2iNlSKxMlEk7j3mq8k2wmr8DDNNiZIioUtZwQzRx8q5iPM6goJYodg1z3x ucbpyVdnkULU05suT3gUEgzNflUhzqz/JTrbTDK636vh91QJhezHBOEdGjGl7utIwZwC vlEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci4si11870805ejc.612.2020.09.23.03.59.14; Wed, 23 Sep 2020 03:59:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbgIWK4t (ORCPT + 99 others); Wed, 23 Sep 2020 06:56:49 -0400 Received: from mail.loongson.cn ([114.242.206.163]:37214 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726422AbgIWK4t (ORCPT ); Wed, 23 Sep 2020 06:56:49 -0400 Received: from loongson.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxP9zeKWtfCXgXAA--.2403S2; Wed, 23 Sep 2020 18:56:30 +0800 (CST) From: Peng Fan To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Dengcheng Zhu , Paul Burton , Ravi Bangoria , Ian Rogers , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH] perf annotate mips: Add perf arch instructions annotate handlers Date: Wed, 23 Sep 2020 18:56:24 +0800 Message-Id: <1600858584-6161-1-git-send-email-fanpeng@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9DxP9zeKWtfCXgXAA--.2403S2 X-Coremail-Antispam: 1UD129K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05rqj20fqof0/1tbiAQAIEl3QvMTtRgAAsF Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dengcheng Zhu Support the MIPS architecture using the ins_ops association method. With this patch, perf-annotate can work well on MIPS. Testing it with a perf.data file collected on a mips machine: $./perf annotate -i perf.data : Disassembly of section .text: : : 00000000000be6a0 : : get_next_seq(): 0.00 : be6a0: lw v0,0(a0) 0.00 : be6a4: daddiu sp,sp,-128 0.00 : be6a8: ld a7,72(a0) 0.00 : be6ac: gssq s5,s4,80(sp) 0.00 : be6b0: gssq s1,s0,48(sp) 0.00 : be6b4: gssq s8,gp,112(sp) 0.00 : be6b8: gssq s7,s6,96(sp) 0.00 : be6bc: gssq s3,s2,64(sp) 0.00 : be6c0: sd a3,0(sp) 0.00 : be6c4: move s0,a0 0.00 : be6c8: sd v0,32(sp) 0.00 : be6cc: sd a5,8(sp) 0.00 : be6d0: sd zero,8(a0) 0.00 : be6d4: sd a6,16(sp) 0.00 : be6d8: ld s2,48(a0) 8.53 : be6dc: ld s1,40(a0) 9.42 : be6e0: ld v1,32(a0) 0.00 : be6e4: nop 0.00 : be6e8: ld s4,24(a0) 0.00 : be6ec: ld s5,16(a0) 0.00 : be6f0: sd a7,40(sp) 10.11 : be6f4: ld s6,64(a0) ... The original patch link is: https://lore.kernel.org/patchwork/patch/1180480/ Signed-off-by: Dengcheng Zhu Signed-off-by: Peng Fan --- Add "bgtzl", "bltzl", "bgezl", "blezl", "beql" and "bnel", remove "bgtzal", "blezal", "beqzal", "bnezal" and "jialc". Because these five can not be found in the instruction manual. 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 1bb8bf6..e4e5f33 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 0000000..8fae8a1 --- /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_ins_ops(struct arch *arch, const char *name) +{ + struct ins_ops *ops = NULL; + + if (!strncmp(name, "bal", 3) || + !strncmp(name, "bgezal", 6) || + !strncmp(name, "bltzal", 6) || + !strncmp(name, "bgtzl", 5) || + !strncmp(name, "bltzl", 5) || + !strncmp(name, "bgezl", 5) || + !strncmp(name, "blezl", 5) || + !strncmp(name, "beql", 4) || + !strncmp(name, "bnel", 4) || + !strncmp(name, "jal", 3)) + ops = &call_ops; + else if (!strncmp(name, "jr", 2)) + 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_ins_ops; + arch->initialized = true; + arch->objdump.comment_char = '#'; + } + + return 0; +} diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0a1fcf7..80a4a3d 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -152,6 +152,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[] = { .init = csky__annotate_init, }, { + .name = "mips", + .init = mips__annotate_init, + .objdump = { + .comment_char = '#', + }, + }, + { .name = "x86", .init = x86__annotate_init, .instructions = x86__instructions, -- 2.1.0