From patchwork Sat May 20 02:55:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13249076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DECD7C77B7A for ; Sat, 20 May 2023 02:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=12IgS52ihLXNioHB9MoEVOzX8u1ANhwZzor/tpdspaE=; b=isgMQhen06W+lL KZ0GPWSvX/bsgsmZD0QANbQ0XH3E9W2p2f8J52mw+qPaAG1czXcNGC0EgZivE1qMVIiW36h+uhq9d zcKO36p7jRAehqpsbpNVzaW0CJupG462UnmgHsxiFLpoeic38UANkvWVbQdAEuRdpUTh706r+a6lE RW10Kg8l1Xl99YoBkrcjqaOEGPrZvt1tl0JRatG3XAGuIUzwMjxOK4+0JIoox4spL4rtNOF/vs08H 6ANrYItGqEerDex7ISfvtJg33gEG35pSJKDQpkhX4kFZJANQ4lCfpss4lJ/ptKrWjBrQPzH/F6wwl Oq7l1BPhfo7LUkViaN3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q0ClA-000V9a-0X; Sat, 20 May 2023 02:55:56 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q0Cl7-000V84-0j for linux-arm-kernel@lists.infradead.org; Sat, 20 May 2023 02:55:54 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64d3fdcadb8so637723b3a.3 for ; Fri, 19 May 2023 19:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684551351; x=1687143351; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jdSvKOAXL7sdlLkGjTnnuwOA/VbKrzGOIijIH+Tf82k=; b=xE8Cw7jDANx3AqisU3EyAG8VrY1HFl5eTc84ib3IPvWx968QS3Aqj/Ee18o/QUglQP UszG3vCgAkfxlpn24AYf27GDUNEpDUU405dBM4CRA3h8+FitTO/SBDzvJWZohdd9WMLY LlB5bRSYIqKKW99Sh5peZrcLWc7wdoMhBI73p1LoJD0GczzjXTxjHq7j43K/Ucc7J07N /T8M7u9SSX2dC1wxkylvNVAaEV21EFnFFUg9hVEp2dPyi2C4gmII2Na3uJhIeOhcvik+ suQheC48KkYjXO9ht32iBrWY5zMNStb7YZh7p6/TO3FsUr0JII5JTkg8mgpaglK/b+Av Hpxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684551351; x=1687143351; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jdSvKOAXL7sdlLkGjTnnuwOA/VbKrzGOIijIH+Tf82k=; b=F1rFVEykRmv2znR3shSVUpn/e5mARFYEHCPXgQLDBtLpnTR0gekwMP9Y05fjS2vWG1 bxXdKKXSToviCy/9iIwe4TlErNn9LjHvR4rS+gE4eZCMfYh80ox8XImif21RMdYJgZz7 ygaHPf92/yHgZuZ55Zhq01kJuvcpRMYLx8Yqbl0FrFzuXtmpqMYDBLFjHBpZIyiPRp8U vnZCVC41UDB9UNhGS9X75+OKekZLMm4eMADu5N/eN58QbkXUwdhAu5MzMtH64TxDpHaI qEf4BSlp+ZmNQSc7v5Ydp2e4GoVx9Lxo2sitT/JrWCvZx8gZCTCeDdXfA0FgsM8Oia/D sagw== X-Gm-Message-State: AC+VfDyGVzZg8bNM49jbHzIa2LNo1yvxKlpZ0bZ82sKW8weUJC7Qr1cT qGew9+EbJB/P66ypzxUZvrmQPA== X-Google-Smtp-Source: ACHHUZ6RpF/8FxxuZkieXS5msDgwv84HNNcHwRibxyaBrbA0VudSU3lWns+f544SUGcVsGNFXYsn6Q== X-Received: by 2002:a17:903:18b:b0:1ac:8be5:8787 with SMTP id z11-20020a170903018b00b001ac8be58787mr4699376plg.21.1684551351025; Fri, 19 May 2023 19:55:51 -0700 (PDT) Received: from leoy-yangtze.lan ([156.59.236.113]) by smtp.gmail.com with ESMTPSA id b6-20020a170902d50600b001a95aef9728sm346100plg.19.2023.05.19.19.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 19:55:50 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , John Garry , Will Deacon , James Clark , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Lin , Kan Liang , Qi Liu , Sandipan Das , 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 Cc: Leo Yan Subject: [PATCH v1 0/5] perf parse-regs: Refactor arch related functions Date: Sat, 20 May 2023 10:55:32 +0800 Message-Id: <20230520025537.1811986-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230519_195553_315948_FE696D66 X-CRM114-Status: GOOD ( 16.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The register parsing have two levels: one level is under 'arch' folder, another level is under 'util' folder. A good design is 'arch' folder handles architecture specific operations and provides APIs for upper layer, on the other hand, 'util' folder should be general and simply calls APIs to talk to arch layer. The current code mixes these two layers, e.g. util/perf_regs.h includes architecture's perf_regs.h, so it implicitly couples with specific architecture during building time. Furthermore, util/perf_regs.c includes all architectures' perf_regs.h, this is easily to cause conflict due to duplicated definitions from any two different archs. So this patch series is to refactor arch related functions for register parsing: Firstly, it creates a new folder util/perf-regs-arch and uses dedicated source file for every arch, note, all of these source files will be built in tool to support cross analysis (e.g. we can run perf on x86 machine for parsing aarch64's perf data file). Secondly, rather than directly referring macros, we introduce new functions, these functions are provided by architecture and then will be invoked by perf common code. At the end, we can generalize the register parsing in 'util' folder. This patch series has been compiled successfully on my Arm64 and x86 machine. Leo Yan (5): perf parse-regs: Refactor arch register parsing functions perf parse-regs: Introduce functions arch__reg_{ip|sp}() 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 tools/perf/arch/arm/include/perf_regs.h | 3 - tools/perf/arch/arm/util/perf_regs.c | 21 + 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 | 16 + 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 | 21 + tools/perf/arch/csky/util/unwind-libdw.c | 1 + tools/perf/arch/mips/include/perf_regs.h | 2 - tools/perf/arch/mips/util/perf_regs.c | 21 + tools/perf/arch/powerpc/include/perf_regs.h | 3 - tools/perf/arch/powerpc/util/perf_regs.c | 16 + 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 | 21 + 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 | 21 + 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 | 16 + tools/perf/arch/x86/util/unwind-libdw.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 2 +- tools/perf/util/perf-regs-arch/Build | 8 + .../util/perf-regs-arch/perf_regs_aarch64.c | 86 +++ .../perf/util/perf-regs-arch/perf_regs_arm.c | 50 ++ .../perf/util/perf-regs-arch/perf_regs_csky.c | 90 +++ .../perf/util/perf-regs-arch/perf_regs_mips.c | 77 +++ .../util/perf-regs-arch/perf_regs_powerpc.c | 135 ++++ .../util/perf-regs-arch/perf_regs_riscv.c | 82 +++ .../perf/util/perf-regs-arch/perf_regs_s390.c | 86 +++ .../perf/util/perf-regs-arch/perf_regs_x86.c | 88 +++ tools/perf/util/perf_regs.c | 646 +----------------- tools/perf/util/perf_regs.h | 18 +- tools/perf/util/unwind-libdw.c | 2 +- tools/perf/util/unwind.h | 4 +- 39 files changed, 887 insertions(+), 671 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_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