Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp406545ybd; Tue, 25 Jun 2019 23:54:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPtmpmIUhXHcysDIr57cnjt41bJNuMcm1fyk1XlnYMr4m6graanQmzj7HkUWPEDniHquUf X-Received: by 2002:a63:205b:: with SMTP id r27mr1424779pgm.330.1561532085148; Tue, 25 Jun 2019 23:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561532085; cv=none; d=google.com; s=arc-20160816; b=TEdr40MkfmmfeiO5z7CIlf48F8SSuXJYnUZ5ThXFWO+jMhma8W5+88qCxoMnxwCTek LPBBOcfY7fL/3CzuBHzgoOAaHqT9aRvqBxI6LdieOkPVP9AXG6ShJLaBkTOsuFtaKovO szE4wqAwW1Bvm1eVf5MV9sYEwCOVU+YQ0p09G67WjIMsyb9IMoFO0YIRhPly33wInXPr as82ZygyLra4uJPRzhMIgc3Zx1lnf/eU2s12xLkDfPyUvLOQ8rrf0k+LdkbqU13riUI5 eR/0vsDhcVGVnNLsUfP8Qe9H8qfN9GD6ZkOBx0XVttYTF6rYvZJTRVA0s+nEbqBOpyHs URxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rYEVkALhJUspIVsytGlnvwmH7ipxxb/6/IlYoebtXXU=; b=n7/yUDsTFMz18Lzf5CEb/2YMl5pcipUUilIrNRLQ8m8Zqa0QSUX8CMVXcWThsCF1KT ppHFQe2o4XfTV2zLcstk1cTmL7iis2S+sgQufjZI0X4SNlp6iQr6hdh17dr1vRVmM6tt 6CNmtCwFkZ4azjrLph8FLoSw/gXsmRSKIvhrpYKpoXa6M/Eu97B04rFVAQtrpEaUZzQV x9HvYtMhn6/pcIkWpbSrwv9tUKLE7T8FE0aYHjM6ADTgaRg7iCOzPWjU+Ws6BXHd38xo WVAVy+Jq8KtLpipRhQWjqmgU7An3fRdErSI6cdM1kscOXZwSPriONXM2ITZ37CTvxWrN 3Ilw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si16203225pfd.156.2019.06.25.23.54.28; Tue, 25 Jun 2019 23:54:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbfFZGyE (ORCPT + 99 others); Wed, 26 Jun 2019 02:54:04 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:41934 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfFZGyE (ORCPT ); Wed, 26 Jun 2019 02:54:04 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07437235|-1;CH=green;DM=SPAM|CONTINUE|true|0.86325-0.00405368-0.132696;FP=0|0|0|0|0|-1|-1|-1;HT=e01l07440;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.EqHrgI6_1561532027; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.EqHrgI6_1561532027) by smtp.aliyun-inc.com(10.147.43.95); Wed, 26 Jun 2019 14:53:52 +0800 From: Mao Han To: linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org Cc: Mao Han , Guo Ren , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: [PATCH 1/1] perf annotate csky: Add perf annotate support Date: Wed, 26 Jun 2019 14:52:19 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add basic arch initialization and instruction associate support for csky. perf annotate --stdio2 Samples: 161 of event 'cpu-clock:pppH', 4000 Hz, Event count (approx.): 40250000, [percent: local period] test_4() /usr/lib/perf-test/callchain_test Percent Disassembly of section .text: 00008420 : test_4(): subi sp, sp, 4 st.w r8, (sp, 0x0) mov r8, sp subi sp, sp, 8 subi r3, r8, 4 movi r2, 0 st.w r2, (r3, 0x0) ↓ br 2e 100.00 14: subi r3, r8, 4 ld.w r2, (r3, 0x0) subi r3, r8, 8 st.w r2, (r3, 0x0) subi r3, r8, 4 ld.w r3, (r3, 0x0) addi r2, r3, 1 subi r3, r8, 4 st.w r2, (r3, 0x0) 2e: subi r3, r8, 4 ld.w r2, (r3, 0x0) lrw r3, 0x98967f // 8598 cmplt r3, r2 ↑ bf 14 mov r0, r0 mov r0, r0 mov sp, r8 ld.w r8, (sp, 0x0) addi sp, sp, 4 ← rts Signed-off-by: Mao Han Cc: Guo Ren Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim --- tools/perf/arch/csky/annotate/instructions.c | 48 ++++++++++++++++++++++++++++ tools/perf/util/annotate.c | 5 +++ 2 files changed, 53 insertions(+) create mode 100644 tools/perf/arch/csky/annotate/instructions.c diff --git a/tools/perf/arch/csky/annotate/instructions.c b/tools/perf/arch/csky/annotate/instructions.c new file mode 100644 index 0000000..5337bfb --- /dev/null +++ b/tools/perf/arch/csky/annotate/instructions.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. + +#include + +static struct ins_ops *csky__associate_ins_ops(struct arch *arch, + const char *name) +{ + struct ins_ops *ops = NULL; + + /* catch all kind of jumps */ + if (!strcmp(name, "bt") || + !strcmp(name, "bf") || + !strcmp(name, "bez") || + !strcmp(name, "bnez") || + !strcmp(name, "bnezad") || + !strcmp(name, "bhsz") || + !strcmp(name, "bhz") || + !strcmp(name, "blsz") || + !strcmp(name, "blz") || + !strcmp(name, "br") || + !strcmp(name, "jmpi") || + !strcmp(name, "jmp")) + ops = &jump_ops; + + /* catch function call */ + if (!strcmp(name, "bsr") || + !strcmp(name, "jsri") || + !strcmp(name, "jsr")) + ops = &call_ops; + + /* catch function return */ + if (!strcmp(name, "rts")) + ops = &ret_ops; + + if (ops) + arch__associate_ins_ops(arch, name, ops); + return ops; +} + +static int csky__annotate_init(struct arch *arch, char *cpuid __maybe_unused) +{ + arch->initialized = true; + arch->objdump.comment_char = '/'; + arch->associate_instruction_ops = csky__associate_ins_ops; + + return 0; +} diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 79db038..eb2456e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -144,6 +144,7 @@ static int arch__associate_ins_ops(struct arch* arch, const char *name, struct i #include "arch/arc/annotate/instructions.c" #include "arch/arm/annotate/instructions.c" #include "arch/arm64/annotate/instructions.c" +#include "arch/csky/annotate/instructions.c" #include "arch/x86/annotate/instructions.c" #include "arch/powerpc/annotate/instructions.c" #include "arch/s390/annotate/instructions.c" @@ -163,6 +164,10 @@ static struct arch architectures[] = { .init = arm64__annotate_init, }, { + .name = "csky", + .init = csky__annotate_init, + }, + { .name = "x86", .init = x86__annotate_init, .instructions = x86__instructions, -- 2.7.4