Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp77008pxk; Wed, 23 Sep 2020 23:15:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeY7aq43zrfGpWZs1rZG4qVgobgJ3bXzqhs57TOTyvTDHEUf7m+oN+RCON7QIHlaG/k4rw X-Received: by 2002:a17:907:2139:: with SMTP id qo25mr503696ejb.547.1600928140394; Wed, 23 Sep 2020 23:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600928140; cv=none; d=google.com; s=arc-20160816; b=MSTVYQHtG1PwNHbLrIwVKIbiMmGNu42cYWgFRmWNGaq5DezDmk2iO5zuj/xEdc9joT YqiZT3AsXAoCyV3IxeX3XNg8MUW9GvV0IhP1hor78JajxECUiEYNdM86jZCrHR88HFbz kGFtyF/BcUaE0D4Yq5RDB5fvg2cRZWqmosGRDTLwrqKppTM73grMC9vdbRokV5r/mCJ2 SL2zUY4BNkpq+EFojz9OXOwXHs9gJ9xnPj9A/uhdKRoff3NDy4V/Y9fEXwr+xArQFUMs e4ULef/rQPYHNx2XN6BrA4aAU6cMbYuQeWhJ3a2atCvqKrkKAihlR2K21GO80u6QGEFy LN+A== 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=fEu4mM7THRR80ad3BD5klkVeVKyLjYSInqdBNEEZ9aM=; b=LPnBUmu0y/t7/08w4Dzc+DXNVvFhK9e6HSflblsllQ624xcqgxb7K3fpXPBih1GV7c aARzmYGxuvWTFlbUUsY4NeXnnHd2M1UXyN4RuRmGRHQUZoCx7InAQvJddi9yFqqOReNY 2O00TW4Suu5AQiYlnbafRgKskqlenkJ4GNv+jQwWC9o3xdGg2spX7SH2XyTf9z+YRRZ9 OZjaGt8ZUG2LTcqEGiHT2QzXmzhWlqixRqjE02QezQT+FiZnSMFKU6IakouKWtGXP1Ro fhzAI+b1vNAgovgK4aD8V01g8h/8Vqg/eUa8YonXgvbpbZW8yE2h21ArLalg0qC57yaD uLWw== 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 c5si1440528edv.513.2020.09.23.23.15.14; Wed, 23 Sep 2020 23:15:40 -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 S1726862AbgIXGLn (ORCPT + 99 others); Thu, 24 Sep 2020 02:11:43 -0400 Received: from mail.loongson.cn ([114.242.206.163]:51380 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726683AbgIXGLn (ORCPT ); Thu, 24 Sep 2020 02:11:43 -0400 Received: from loongson.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxb8eAOGxfkqwXAA--.2579S2; Thu, 24 Sep 2020 14:11:12 +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 , Ravi Bangoria , Ian Rogers , linux-kernel@vger.kernel.org, jiaxun.yang@flygoat.com Subject: [PATCH v2] perf annotate mips: Add perf arch instructions annotate handlers Date: Thu, 24 Sep 2020 14:11:08 +0800 Message-Id: <1600927868-18486-1-git-send-email-fanpeng@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9Dxb8eAOGxfkqwXAA--.2579S2 X-Coremail-Antispam: 1UD129K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enderInfo: xidq1vtqj6z05rqj20fqof0/1tbiAQAJEl3QvMT3nwABsG 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: https://lore.kernel.org/patchwork/patch/1180480/ Signed-off-by: Dengcheng Zhu Signed-off-by: Peng Fan [fanpeng@loongson.cn: Add missing "bgtzl", "bltzl", "bgezl", "blezl", "beql" and "bnel" for pre-R6processors] --- tools/perf/arch/mips/Build | 2 +- tools/perf/arch/mips/annotate/instructions.c | 46 ++++++++++++++++++++++++++++ tools/perf/util/annotate.c | 8 +++++ 3 files changed, 55 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..340993f --- /dev/null +++ b/tools/perf/arch/mips/annotate/instructions.c @@ -0,0 +1,46 @@ +// 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, "bgtzal", 6) || + !strncmp(name, "blezal", 6) || + !strncmp(name, "beqzal", 6) || + !strncmp(name, "bnezal", 6) || + !strncmp(name, "bgtzl", 5) || + !strncmp(name, "bltzl", 5) || + !strncmp(name, "bgezl", 5) || + !strncmp(name, "blezl", 5) || + !strncmp(name, "jialc", 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