From patchwork Mon Feb 6 06:51:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Zhan X-Patchwork-Id: 13129369 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 6B7E7C636D3 for ; Mon, 6 Feb 2023 06:54:32 +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=59i6HONJ5g2YuURq++aqnHklbH+X7iJFlhQVe3wukP4=; b=g+MBLcr/u835YA 6sKp0kT9m/sGklvW+I/+WQqOyIcJpuBzEzc3mWM6vTrqWfryFTju+4urXw2IBALydKcNZIg6W5Suj ENGFqzqcSPfYO6LKUuA+fAfgDfiBrcfy21HoDD28SP83J1J3UWw6sNjRczAd5TNRWUEmvqlggJ1JM zqbntaloSpIh6z4ikoBAqFEcl2R6ciHaAjC2a3ioDQALRJNTMiZe53RQEkpBzhV2pz5iBgeKFP17A UnIiqPBfFEOf1Y52/ZPh4WOJQYwDacVIZ2zTJm1EgPhnmDm8vsYrjBjqmun52Io5PDrOmffv7mz3R CwHxhXxqjI9c3Xnm1hEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOvNf-007UQo-3C; Mon, 06 Feb 2023 06:53:35 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOvNJ-007UIv-Th for linux-arm-kernel@lists.infradead.org; Mon, 06 Feb 2023 06:53:17 +0000 Received: from dggpeml500019.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4P9H2q29WszRp9s; Mon, 6 Feb 2023 14:50:43 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by dggpeml500019.china.huawei.com (7.185.36.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 6 Feb 2023 14:53:03 +0800 From: Jie Zhan To: , , , , , , , , , , , , CC: , , , , , , , , , , , , Subject: [RFC PATCH v1 0/4] HiSilicon Performance Monitor Control Unit Date: Mon, 6 Feb 2023 14:51:42 +0800 Message-ID: <20230206065146.645505-1-zhanjie9@hisilicon.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500019.china.huawei.com (7.185.36.137) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230205_225314_382236_039F5001 X-CRM114-Status: GOOD ( 19.32 ) 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 HiSilicon Performance Monitor Control Unit (PMCU) is a device that offloads PMU accesses from CPUs, handling the configuration, event switching, and counter reading of core PMUs on Kunpeng SoC. It facilitates fine-grained and multi-PMU-event CPU profiling, in which scenario the current 'perf' scheme may lose events or drop sampling frequency. With PMCU, users can reliably obtain the data of up to 240 PMU events with the sample interval of events down to 1ms, while the software overhead of accessing PMUs, as well as its impact on target workloads, is reduced. This patchset contains the documentation, driver, and user perf tool support to enable using PMCU with the 'perf_event' framework. Here are two key questions requested for comments: - How do we make it compatible with arm_pmu drivers? Hardware-wise, PMCU uses the existing core PMUs, so PMUs can be accessed from CPU and PMCU simultaneously. The current hardware can't guarantee mutual exclusive accesses. Hence, scheduling arm_pmu and PMCU events at the same time may mess up the operation of PMUs, delivering incorrect data for both events, e.g. unexpected events or sample periods. Software-wise, we probably need to prevent the two types of events from running at the same time, but currently there isn't a clear solution. - Currently we reply on a sysfs file for users to input event numbers. Is there a better way to pass many events? The perf framework only allows three 64-bit config fields for custom PMU configs. Obviously, this can't satisfy our need for passing many events at a time. As an event number is 16-bit wide, the config fields can only take up to 12 events at a time, or up to 192 events even if we do a bitmap of events (and there are more than 192 available event numbers). Hence, the current design takes an array of event numbers from a sysfs file before starting profiling. However, this may go against the common way to schedule perf events through perf commands. Jie Zhan (4): docs: perf: Add documentation for HiSilicon PMCU drivers/perf: hisi: Add driver support for HiSilicon PMCU perf tool: Add HiSilicon PMCU data recording support perf tool: Add HiSilicon PMCU data decoding support Documentation/admin-guide/perf/hisi-pmcu.rst | 183 +++ Documentation/admin-guide/perf/index.rst | 1 + drivers/perf/hisilicon/Kconfig | 15 + drivers/perf/hisilicon/Makefile | 1 + drivers/perf/hisilicon/hisi_pmcu.c | 1096 ++++++++++++++++++ tools/perf/arch/arm/util/auxtrace.c | 61 + tools/perf/arch/arm64/util/Build | 2 +- tools/perf/arch/arm64/util/hisi-pmcu.c | 145 +++ tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 4 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/hisi-pmcu.c | 305 +++++ tools/perf/util/hisi-pmcu.h | 19 + 13 files changed, 1833 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/perf/hisi-pmcu.rst create mode 100644 drivers/perf/hisilicon/hisi_pmcu.c create mode 100644 tools/perf/arch/arm64/util/hisi-pmcu.c create mode 100644 tools/perf/util/hisi-pmcu.c create mode 100644 tools/perf/util/hisi-pmcu.h base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476