Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp408815ybd; Tue, 25 Jun 2019 23:57:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbH9zrfDHGJylo8dXkgOOOUletd8bFclCOjC0bmm9iwebH3ZbRWGhN1oPZMgbs7ELrLb/z X-Received: by 2002:a17:902:e282:: with SMTP id cf2mr3531215plb.301.1561532263604; Tue, 25 Jun 2019 23:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561532263; cv=none; d=google.com; s=arc-20160816; b=gkUPl7zB6NvShUAwYihszO98hnslpd9m8y9funv/fe9GLBBkVqFMtkwljYZDHKihk/ O9zWhi8efETnVb6WLrgMzS622PnOD7AyyjXNBE04yz+rbaSnnq3jRg4RtQvYt8MqRv+Q xhy3+XU+uuftj9cef1fgl+tj7EsNutqMDsoF8ck5lOl08KGR94swGrfv3BG4z8p68UCW Z8/ylc0F/2FszDRNgYx1Kfa7X6sLlrFO7lpCxQ6MswbxaC62IY7DaB/YsyUECJzPD9aO VDSFIZ11jvOWXABiBbYZussTY0P/M2WfWQuTNg+0OzsAE4jySFwGZo3A04oW9i3eyRME CREQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gj+GiJ6Pzl6qMsnRaOF3/+EeBqJxEfjVshoAgm2cRYs=; b=agz1lx7wQ1edWd7XHCN89647kzcHqFZhgt+KEDisBQj+7JBmJZlOoWHl4woWdwjTRo iHh7ySEHCBk0Ju71+wlR+4/YJMwRpt3jIgUm8i4yQEP9/3yKZkZFIkJB+yVp87A0W2Hg k+oPIbDQCSkSE+rwaFW0xMlIVg3rYYd9iS+CCxF+akp9wKrqXJCuiYgxe7NUK3aA4K9F ALv9eFDNsOUkb73ehi5anzjCcHsV25jFZorsd8+xgv6rIj98o+bqoM0qD49+xYh9E8y5 ApRymme9Pk0K5MxGuNAV8CR+JPFlw5PEKMV8zI0IAISPCoBKGe77xnlRZLkqbD7OOhl6 6gcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HupmX+5R; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35si15148936pgy.255.2019.06.25.23.57.27; Tue, 25 Jun 2019 23:57:43 -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=@kernel.org header.s=default header.b=HupmX+5R; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbfFZG5L (ORCPT + 99 others); Wed, 26 Jun 2019 02:57:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:43978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbfFZG5K (ORCPT ); Wed, 26 Jun 2019 02:57:10 -0400 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 928EF2086D; Wed, 26 Jun 2019 06:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561532228; bh=h270XSQR4HolgMBKtPYzDJLyOe03vdnKPXJi7f/tNRM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HupmX+5Rtg9kMo0+c7MtqHspj5yq0C1i+GHhqAfPjXpvRXGFlJmGNWUbzYG4I4Vrf Xc2a11E3p3qv2IjffyBBtc+hzBXn9wpdwWBB5O83bL9WUAaI462ArX8xxDF70mac3X jG83M2a3D2nE4EQACKx7oBSWIzyjwwLvLTLN70TI= Received: by mail-wr1-f48.google.com with SMTP id k11so1348331wrl.1; Tue, 25 Jun 2019 23:57:08 -0700 (PDT) X-Gm-Message-State: APjAAAXypLMPFrVhEEXSu1lNP3GcgX2bEbQVUnPw3F7HTbnrCLFcc3MV ONvMZiZnYDXqV1QX5u4Nr8jxvk/9YTZbvU0FFNM= X-Received: by 2002:adf:f28a:: with SMTP id k10mr2189723wro.343.1561532227206; Tue, 25 Jun 2019 23:57:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Guo Ren Date: Wed, 26 Jun 2019 14:56:55 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] perf annotate csky: Add perf annotate support To: Mao Han Cc: linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thx Mao, Approved! Best Regards Guo Ren On Wed, Jun 26, 2019 at 2:53 PM Mao Han wrote: > > This patch add basic arch initialization and instruction associate suppor= t > 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) > =E2=86=93 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 > =E2=86=91 bf 14 > mov r0, r0 > mov r0, r0 > mov sp, r8 > ld.w r8, (sp, 0x0) > addi sp, sp, 4 > =E2=86=90 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/ar= ch/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 =3D 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 =3D &jump_ops; > + > + /* catch function call */ > + if (!strcmp(name, "bsr") || > + !strcmp(name, "jsri") || > + !strcmp(name, "jsr")) > + ops =3D &call_ops; > + > + /* catch function return */ > + if (!strcmp(name, "rts")) > + ops =3D &ret_ops; > + > + if (ops) > + arch__associate_ins_ops(arch, name, ops); > + return ops; > +} > + > +static int csky__annotate_init(struct arch *arch, char *cpuid __maybe_un= used) > +{ > + arch->initialized =3D true; > + arch->objdump.comment_char =3D '/'; > + arch->associate_instruction_ops =3D 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[] =3D { > .init =3D arm64__annotate_init, > }, > { > + .name =3D "csky", > + .init =3D csky__annotate_init, > + }, > + { > .name =3D "x86", > .init =3D x86__annotate_init, > .instructions =3D x86__instructions, > -- > 2.7.4 > --=20 Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/