Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp980680ybi; Wed, 3 Jul 2019 07:33:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqYRUjIdbS83HyV6ZiA8GvxHkdG8HZKCJURm9XapsrW5I3+OTOkIk5P40iZrih3c4UYXx6 X-Received: by 2002:a63:4d50:: with SMTP id n16mr37778297pgl.146.1562164398874; Wed, 03 Jul 2019 07:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562164398; cv=none; d=google.com; s=arc-20160816; b=Um0Od0HsOhROa6Xljl9mOipmYIY6JjZnIfUFYhIxQdrGssqNMIail2YpDb3EvRER3k 0kWqwCsRSJ2C8zDEqVd6iEmkZRAGzmM4NnZ6Z9oQddj1Numl4a8C8Nd9TTVg7KNgxe7I BxFKvrSK8bRT3XjKWY7DHrqZ9pT6bZmvBo8P3BS/gD1cmSqJytk6D8H65KusK7HEFFgq o/MJ5hVZOflCyOEOeaNvM0+PzAvsRlE8KLlIie5f0ja+0L7lkf8Cs22A2/QfKLaZsssq Ap0+Xlh68HQ1QE04DxeJKA7X6f8Ok09LmH1s8+KQvwsDQdEgkhAB0v8lmKhACc7GbKBM nkLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=81ITF5dckdrW/ARPcWsImVFzm1NqFtIWApIUoUxVpUs=; b=KZkHXLTV5WQe6BIlQdH/fpB9kl40JFtmn+LOBlLOm8AJ88iM1rgXH4K0ch6XlvWeHr 1N7JdlHkfhZX+lrvB7WpMbHkJhzunZIDYeoQljvkkVrhWkHDugp5FVokdFDw4oErOPPh 0wukCfMRzRoMRWxFtrUHjt981JQ+SDmuUWEgHQNm8LTHImkqxWTLTiOr6LN3oZeM8Hh4 VMT4h+wLAnf4plcGN1leQ+thbVute32Dm8FrJDUKkgEsniyqUNlXFOceWWSXhu6CMGGc 6UtmFES/xYENmRE5Td3V7QGnMZKrwO/lmUInNiSgknQH2n5acfBxqpv1qKcGOBAion7p zjFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=mGIZ32Xk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68si2572481pfb.75.2019.07.03.07.33.03; Wed, 03 Jul 2019 07:33:18 -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; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=mGIZ32Xk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727223AbfGCObM (ORCPT + 99 others); Wed, 3 Jul 2019 10:31:12 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45035 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbfGCObL (ORCPT ); Wed, 3 Jul 2019 10:31:11 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x63EUhnG3327371 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 3 Jul 2019 07:30:43 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x63EUhnG3327371 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1562164244; bh=81ITF5dckdrW/ARPcWsImVFzm1NqFtIWApIUoUxVpUs=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=mGIZ32XkE3n1k2Vblbl18TbjfidYpqZah0gs5OuVj4GB9jbq1U8PrgRH92Mt53vHK T+wGRb83tld31qt7Ci88Pood44Q3sCQeqtZUF0dCvVNF4AhpIuH1EJFbnYNmsR21uR rkYAD0wL1PgEj5uq3HQFj3323KsVtiRVbDbIbs4yoLiNV62DaFTyPRANVub1lJ3hXK 8nV2N6MDmQelaeDOmZOstyaGEjulSa+fj8dPI0R7d4h26g6Yg7uD+ZrFb/vi2DI0hI U5oYEM9bTtj3ZU/qitf0wU8Z7Y5W2ccac/wq+O0au5vrJesBOaGn0gKMaIB/OsDPNv TkPWtVo60S2dA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x63EUgfn3327365; Wed, 3 Jul 2019 07:30:42 -0700 Date: Wed, 3 Jul 2019 07:30:42 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Mao Han Message-ID: Cc: acme@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, namhyung@kernel.org, mingo@kernel.org, guoren@kernel.org, hpa@zytor.com, han_mao@c-sky.com, tglx@linutronix.de Reply-To: linux-kernel@vger.kernel.org, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, han_mao@c-sky.com, namhyung@kernel.org, guoren@kernel.org, acme@redhat.com, jolsa@redhat.com, alexander.shishkin@linux.intel.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf annotate: Add csky support Git-Commit-ID: aa23aa55166c2865ac430168c4b9d405cf8c6980 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: aa23aa55166c2865ac430168c4b9d405cf8c6980 Gitweb: https://git.kernel.org/tip/aa23aa55166c2865ac430168c4b9d405cf8c6980 Author: Mao Han AuthorDate: Wed, 26 Jun 2019 14:52:19 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 1 Jul 2019 22:50:41 -0300 perf annotate: Add csky support This patch add basic arch initialization and instruction associate support for the csky CPU architecture. E.g.: $ 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 Acked-by: Guo Ren Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: linux-csky@vger.kernel.org Link: http://lkml.kernel.org/r/d874d7782d9acdad5d98f2f5c4a6fb26fbe41c5d.1561531557.git.han_mao@c-sky.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/csky/annotate/instructions.c | 48 ++++++++++++++++++++++++++++ tools/perf/util/annotate.c | 5 +++ 2 files changed, 53 insertions(+) diff --git a/tools/perf/arch/csky/annotate/instructions.c b/tools/perf/arch/csky/annotate/instructions.c new file mode 100644 index 000000000000..5337bfb7d5fc --- /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 2d08c4b62c63..ec7aaf31c2b2 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -145,6 +145,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[] = { .name = "arm64", .init = arm64__annotate_init, }, + { + .name = "csky", + .init = csky__annotate_init, + }, { .name = "x86", .init = x86__annotate_init,