Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp424132rwp; Wed, 12 Jul 2023 16:00:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlHOWPnCCIoCGDdYsU/mvn5Bna0ucyDrV/c4FaAH6zzsB5/QeDonSf+N44KiVCcZA/dD7gVQ X-Received: by 2002:a05:6a20:8f05:b0:128:ffb7:dcfe with SMTP id b5-20020a056a208f0500b00128ffb7dcfemr314054pzk.1.1689202817954; Wed, 12 Jul 2023 16:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689202817; cv=none; d=google.com; s=arc-20160816; b=ZZk7RhLrBTQNdRIfNJjV1NmxBTUBusU48u+ZlX8F/hV81te776EqEWv+9RVN7t01LW Y8gumXUSUcTje3RhJ75jLLeiFTKs9bskkYITaeAJhyu9eQ1KNY7UL0131st+hbmYj/JV L08CVSlACMvYL0KHZiLa9Mhu5g95GUwWnT8aXZWP2ofNV0KFrqtGi3hXOSsRkPrrn01r YCowpeL6UJg3chjy73MZMB+yl3khgnO6EneRE01WA/lSJb+NOlKbMHbuVC+0Ev49VAqG 65gqgV7N3cSbYyT+rrthC0aBl7/QAqIJKFSjua1fwtRy2m7Ks/Xinq08xT/2+jHXL9a6 GBAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=RSLm7OgvDjCIbcXOw5uuAV7h48kPlKZpDxLeFUfyiq4=; fh=RhDSudOu4/NN7P/gbksvAgCfDnWbxID89xULrI8VPf4=; b=a67HWtyYjlBBf/nQGtrXoQKekcaAbh2ZgrZdOX0OPKhgyRODjXr3xuDIO0mNKCHc5q U6/tGvyjLK34xA6wC/GZHIgfHZspdWaWks/ZzW1+VNfJOJhB5N5C0fsS+myg6Ap4lhQG bN3jhwEEOubNjKVO8XvBnnWpt7M5OAvk6WJRt3EkuW8mzu3uhqmm0iOuoaHpCpyqPcfj QG5N2zgh4SKv/bEWA2dkBchOjoAh+pL6kH1FDdbbZo3hXBbeDyIiWfOb6GXRr1rZTIi0 g8y12/a/WQXg9MkFhLprryRNKf5kfzvwVIVAFjJyOWO73C4yFZGSPyQQGkzT9oLFwbd5 aGmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=rnQ9o0E2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ei17-20020a056a0080d100b0066887057a46si3832906pfb.120.2023.07.12.16.00.02; Wed, 12 Jul 2023 16:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=rnQ9o0E2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbjGLWhx (ORCPT + 99 others); Wed, 12 Jul 2023 18:37:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjGLWhv (ORCPT ); Wed, 12 Jul 2023 18:37:51 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22D2C1FDB for ; Wed, 12 Jul 2023 15:37:49 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-4036bd4fff1so59111cf.0 for ; Wed, 12 Jul 2023 15:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689201468; x=1691793468; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RSLm7OgvDjCIbcXOw5uuAV7h48kPlKZpDxLeFUfyiq4=; b=rnQ9o0E2l/BiQrlY+riM1wbukDiYm1B48anGRuDdYPOxCaotBOlbTDOO8nAHSy2B6a fNyQAt8/reux4SzDQmE5JW0MF65yecvSCO+embQk0rQq41N5BYc9Dqs7Db0v/w605Kg8 PfSC7f7xFOYzyz+/n3CZtnU/jGwKQlLlAh+2vMvMSP3l5EqB++UphBZkrAyKuGS6iFrE hmdPG10EKrbRyzKPRiDg2c29TjTMJJbLlDzAIJcPOiHVXYwUCvjhAVA5jYRBQEVH5tI+ +KuWX5z2t7lk/J0pA9vD4t0JSBrBBzrGmPGzgmYFfawsOyMj7Ln4pHNu2W40bc01DCbt fVgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689201468; x=1691793468; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RSLm7OgvDjCIbcXOw5uuAV7h48kPlKZpDxLeFUfyiq4=; b=VNnVsUhRpM28K5r4lj5Vk332F43OZqdmbMpTDV7VdXi4BBqGetdStRKWXM4tiDqc+c 8/tkkD5JK4kG6/QOh2/+fckNZ4qwx2VN+KuyOy+pdz8mYFFTOajfI5TuJUqm2e2UF4ZS isTSjAavZUllWHz6zPdnbXmPW47k+DeCESLh5z3O7odrpalgV0JD5BYXRjtjcCt9YUb6 VBFUWulh4On5iIL+Wl56nsMSFTNnoSVgc9kAS9cpa87OFAfUwIOFJ0zzWf4q/jLOvroo jMLLryOiBy30hwUopkhcT7lMZu6rhI78PikR/YgBwcIXLc2YsB7bWn+tUSu5qF1Lje29 epxw== X-Gm-Message-State: ABy/qLYiomh7loUIB7vFMwnNP7ka/46VFhpy4viGzNl92093E412+03h hGQ06oXTSBHe22sD5O3khoP+RUlwV/0kBGjSoU08uA== X-Received: by 2002:ac8:5bd1:0:b0:3f8:1db6:201c with SMTP id b17-20020ac85bd1000000b003f81db6201cmr354287qtb.13.1689201468137; Wed, 12 Jul 2023 15:37:48 -0700 (PDT) MIME-Version: 1.0 References: <20230606014559.21783-1-leo.yan@linaro.org> In-Reply-To: <20230606014559.21783-1-leo.yan@linaro.org> From: Ian Rogers Date: Wed, 12 Jul 2023 15:37:36 -0700 Message-ID: Subject: Re: [PATCH v2 0/6] perf parse-regs: Refactor architecture functions To: Leo Yan Cc: Arnaldo Carvalho de Melo , John Garry , Will Deacon , James Clark , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Huacai Chen , Ming Wang , Eric Lin , Kan Liang , Sandipan Das , Ivan Babrou , Fangrui Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 5, 2023 at 6:46=E2=80=AFPM Leo Yan wrote: > > This patch series is to refactor arch related functions for register > parsing, which follows up the discussion for v1: > https://lore.kernel.org/lkml/20230520025537.1811986-1-leo.yan@linaro.org/ > > Compared to patch series v1, this patch series introduces new functions > perf_arch_reg_{ip|sp}(), so this can allow the tool to support cross > analysis. > > To verify the cross analysis, I used below steps: > > - Firstly, I captured perf data on Arm64 machine: > > $ perf record --call-graph fp -- ./test_program > > Or ... > > $ perf record --call-graph dwarf -- ./test_program > > Then, I also archived associated debug data: > > $ perf archive > > - Secondly, I copied the perf data file and debug tar file on my x86 > machine: > > $ scp perf.data perf.data.tar.bz2 leoy@IP_ADDRESS:/target/path/ > > - On x86 machine, I need to build perf for support multi-arch unwinding: > > $ git clone http://git.savannah.gnu.org/r/libunwind.git > $ cd libunwind > $ autoreconf -i > > # Build and install libunwind aarch64: > $ ./configure prefix=3D/home/leoy/Work/tools/libunwind/install/ \ > --target=3Daarch64-linux-gnu CC=3Dx86_64-linux-gnu-gcc > $ make && make install > > # Build and install libunwind x86: > $ ./configure prefix=3D/home/leoy/Work/tools/libunwind/install/ \ > --target=3Dx86_64-linux-gnu CC=3Dx86_64-linux-gnu-gcc > $ make && make install > > - Build perf tool for support multi-archs: > > $ cd $LINUX/tools/perf > $ make VF=3D1 DEBUG=3D1 LIBUNWIND_DIR=3D/home/leoy/Work/tools/libunwind= /install > > At the end, I verified the x86 perf tool can do cross analysis for aarch6= 4's > perf data file. > > Note, I still see x86 perf tool cannot display the complete callgraph > for aarch64, but it should not the issue caused by this series, which > will be addressed by separate patches. > > I also built this patch series on my Arm64 and x86 machines, both can > compile perf tool successfully; but I have no chance to build other > archs natively. > > Changes from v1: > - For support cross analysis for IP/SP registers, introduced patch 0002 > (James Clark, Ian Rogers). > > > Leo Yan (6): > perf parse-regs: Refactor arch register parsing functions > perf parse-regs: Introduce functions perf_arch_reg_{ip|sp}() > perf unwind: Use perf_arch_reg_{ip|sp}() to substitute macros > perf parse-regs: Remove unused macros PERF_REG_{IP|SP} > perf parse-regs: Remove PERF_REGS_{MAX|MASK} from common code > perf parse-regs: Move out arch specific header from util/perf_regs.h Sorry for the slow review. For the series: Acked-by: Ian Rogers Some thoughts: uint64_t __perf_reg_ip_arm(void) uint64_t seems like we're giving a lot of space for future register encodings. I think some of the other functions use this size of value due to returning a bitmap/mask, but here it isn't clear and just feels excessive. Do we need the "__" prefix on all the functions? In Makefile.config there are NO_PERF_REGS and CONFIG_PERF_REGS then the define HAVE_PERF_REGS_SUPPORT. Is this still relevant? If we had an architecture with no support, couldn't it still read a perf.data file from a supported architecture? It would be nice to remove at least NO_PERF_REGS and HAVE_PERF_REGS_SUPPORT. This change is very worthwhile fix and cleanup, it didn't introduce what is pondered above, hence the acked-by. Thanks! Ian > tools/perf/arch/arm/include/perf_regs.h | 3 - > tools/perf/arch/arm/util/perf_regs.c | 11 + > tools/perf/arch/arm/util/unwind-libdw.c | 1 + > tools/perf/arch/arm64/include/perf_regs.h | 3 - > tools/perf/arch/arm64/util/machine.c | 1 + > tools/perf/arch/arm64/util/perf_regs.c | 6 + > tools/perf/arch/arm64/util/unwind-libdw.c | 1 + > tools/perf/arch/csky/include/perf_regs.h | 3 - > tools/perf/arch/csky/util/perf_regs.c | 11 + > tools/perf/arch/csky/util/unwind-libdw.c | 1 + > tools/perf/arch/loongarch/include/perf_regs.h | 2 - > tools/perf/arch/loongarch/util/perf_regs.c | 11 + > tools/perf/arch/loongarch/util/unwind-libdw.c | 1 + > tools/perf/arch/mips/include/perf_regs.h | 2 - > tools/perf/arch/mips/util/perf_regs.c | 11 + > tools/perf/arch/powerpc/include/perf_regs.h | 3 - > tools/perf/arch/powerpc/util/perf_regs.c | 6 + > tools/perf/arch/powerpc/util/unwind-libdw.c | 1 + > tools/perf/arch/riscv/include/perf_regs.h | 3 - > tools/perf/arch/riscv/util/perf_regs.c | 11 + > tools/perf/arch/riscv/util/unwind-libdw.c | 1 + > tools/perf/arch/s390/include/perf_regs.h | 3 - > tools/perf/arch/s390/util/perf_regs.c | 11 + > tools/perf/arch/s390/util/unwind-libdw.c | 1 + > tools/perf/arch/x86/include/perf_regs.h | 2 - > tools/perf/arch/x86/util/perf_regs.c | 6 + > tools/perf/arch/x86/util/unwind-libdw.c | 1 + > tools/perf/util/Build | 1 + > tools/perf/util/evsel.c | 6 +- > tools/perf/util/libunwind/arm64.c | 2 - > tools/perf/util/libunwind/x86_32.c | 2 - > tools/perf/util/perf-regs-arch/Build | 9 + > .../util/perf-regs-arch/perf_regs_aarch64.c | 96 +++ > .../perf/util/perf-regs-arch/perf_regs_arm.c | 60 ++ > .../perf/util/perf-regs-arch/perf_regs_csky.c | 100 +++ > .../util/perf-regs-arch/perf_regs_loongarch.c | 91 +++ > .../perf/util/perf-regs-arch/perf_regs_mips.c | 87 ++ > .../util/perf-regs-arch/perf_regs_powerpc.c | 145 ++++ > .../util/perf-regs-arch/perf_regs_riscv.c | 92 +++ > .../perf/util/perf-regs-arch/perf_regs_s390.c | 96 +++ > .../perf/util/perf-regs-arch/perf_regs_x86.c | 98 +++ > tools/perf/util/perf_regs.c | 772 ++---------------- > tools/perf/util/perf_regs.h | 49 +- > tools/perf/util/unwind-libdw.c | 7 +- > tools/perf/util/unwind-libunwind-local.c | 6 +- > tools/perf/util/unwind.h | 8 - > 46 files changed, 1078 insertions(+), 766 deletions(-) > create mode 100644 tools/perf/util/perf-regs-arch/Build > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_aarch64.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_arm.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_csky.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_loongarch.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_mips.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_powerpc.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_riscv.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_s390.c > create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_x86.c > > -- > 2.34.1 >