From patchwork Tue Mar 12 17:34:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590441 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 3AD12C54E58 for ; Tue, 12 Mar 2024 17:34:47 +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:References:In-Reply-To: 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: List-Owner; bh=N8O2rVRga7hKD1zdjNOR7e3NM4p1146Z+MgDA9KrPTo=; b=CDpTypUaWYcYay NN1deCd4KvPoaoxx/puMAwIX1USLOzCudWFDTQjCCXUH/J8d2GrdQ5xwwxB9w5SNFmO/MV0EB62w5 7/7PqI1stl+wCA31t1KIthCKvAyiYi7jGTH0WxpiIdeKmZpIC5uDD2pdbVKzVY7nod4n60ONADC4M ZN63490gc+xjo5L1vRSZ0TsqxJZc/aubGZnM0d6L/OEAhae4aoCvarPeA7AcNJxmv9FBpEsAdTPti kP/+HA1rZZYwSWB8wg/YpOwaack3NKDsuWqX+D0bR5ZMFeloAVwyLLaAgDcYh3cbrPNmxi3FOUM+h 9BdGS/UT10Sn2tMK+iqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61I-00000006sBl-2qiT; Tue, 12 Mar 2024 17:34:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61G-00000006s9v-1sFn for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 571A315BF; Tue, 12 Mar 2024 10:35:04 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0740E3F762; Tue, 12 Mar 2024 10:34:24 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn, Shuai Xue Subject: [PATCH 01/10] perf/alibaba_uncore_drw: Use correct CPU affinity Date: Tue, 12 Mar 2024 17:34:03 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103430_567879_4987D4A6 X-CRM114-Status: GOOD ( 15.54 ) 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 Although this driver is trying to use the IRQ-multiplexing mechanism to handle context migration correctly, it's failing to make events follow the IRQ instance, instead forcing them onto a per-PMU CPU which is set once at probe time then never maintained. Fix this by using the correct CPU from the IRQ instance, and remove the erroneous per-PMU data plus the redundant check which does not mean what it thinks it means. CC: Shuai Xue Fixes: cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC") Signed-off-by: Robin Murphy --- drivers/perf/alibaba_uncore_drw_pmu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c index 19d459a36be5..b37e9794823a 100644 --- a/drivers/perf/alibaba_uncore_drw_pmu.c +++ b/drivers/perf/alibaba_uncore_drw_pmu.c @@ -96,8 +96,6 @@ struct ali_drw_pmu { struct list_head pmus_node; struct ali_drw_pmu_irq *irq; - int irq_num; - int cpu; DECLARE_BITMAP(used_mask, ALI_DRW_PMU_COMMON_MAX_COUNTERS); struct perf_event *events[ALI_DRW_PMU_COMMON_MAX_COUNTERS]; int evtids[ALI_DRW_PMU_COMMON_MAX_COUNTERS]; @@ -221,7 +219,7 @@ static ssize_t ali_drw_pmu_cpumask_show(struct device *dev, { struct ali_drw_pmu *drw_pmu = to_ali_drw_pmu(dev_get_drvdata(dev)); - return cpumap_print_to_pagebuf(true, buf, cpumask_of(drw_pmu->cpu)); + return cpumap_print_to_pagebuf(true, buf, cpumask_of(drw_pmu->irq->cpu)); } static struct device_attribute ali_drw_pmu_cpumask_attr = @@ -550,11 +548,7 @@ static int ali_drw_pmu_event_init(struct perf_event *event) return -EOPNOTSUPP; } - event->cpu = drw_pmu->cpu; - if (event->cpu < 0) { - dev_err(dev, "Per-task mode not supported!\n"); - return -EOPNOTSUPP; - } + event->cpu = drw_pmu->irq->cpu; if (event->group_leader != event && !is_software_event(event->group_leader)) { @@ -701,8 +695,6 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) /* clearing interrupt status */ writel(0xffffff, drw_pmu->cfg_base + ALI_DRW_PMU_OV_INTR_CLR); - drw_pmu->cpu = smp_processor_id(); - ret = ali_drw_pmu_init_irq(drw_pmu, pdev); if (ret) return ret; From patchwork Tue Mar 12 17:34:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590442 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 CD071C54E58 for ; Tue, 12 Mar 2024 17:34:50 +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:References:In-Reply-To: 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: List-Owner; bh=UeX81YWyy0AsNstV7Xyj8M0h5kXZ/h/2+teTngxVfxo=; b=Q7g95fM5ratJN5 z9hEB1luz3QY6OdNysREkPz7r//qn8oIgVvHsAHeJzTunaLZ/rb3geRpNJJLce1D+jZJANuL3uW+g Qv4wtwcpZipRuKdGxk2BHObvPkcp16EL745tH5e67SPRlrRMD3d1CsFKMbOXMvBAuvbh1HlGHMvE/ Nq2vTMaAuYQFtmhLVw1lfN+/ovEJYHXT9EhHVi6DbQHwnZLIMB9A70utrfG70+7SDizNByqTF9LPT FNAAKHUvx2kbOiVwoQ1pcmUsn6ttlOoCQO7ynlWZE+sw3wZN2vAd8rJ/XUOFdB/RzWLCv6MP8EE79 0l8YULwkrIvKGngKfrEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61O-00000006sFp-18ru; Tue, 12 Mar 2024 17:34:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61H-00000006sBC-3T4y for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B54E015DB; Tue, 12 Mar 2024 10:35:06 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 847BC3F762; Tue, 12 Mar 2024 10:34:27 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 02/10] perf: Add capability for common event support Date: Tue, 12 Mar 2024 17:34:04 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103431_969166_44FFE89E X-CRM114-Status: GOOD ( 12.85 ) 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 Many PMUs do not support common hardware/cache/etc. events and only handle their own PMU-specific events. Since this only depends on matching the event and PMU types, it's a prime candidate for a core capability to save more event_init boilerplate in drivers. Signed-off-by: Robin Murphy --- include/linux/perf_event.h | 1 + kernel/events/core.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index d2a15c0c6f8a..983201f21dd2 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -291,6 +291,7 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_NO_EXCLUDE 0x0040 #define PERF_PMU_CAP_AUX_OUTPUT 0x0080 #define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 +#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200 struct perf_output_handle; diff --git a/kernel/events/core.c b/kernel/events/core.c index f0f0f71213a1..7ad80826c218 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11649,6 +11649,11 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) struct perf_event_context *ctx = NULL; int ret; + /* Short-circuit if we know the PMU won't want this event */ + if (pmu->capabilities & PERF_PMU_CAP_NO_COMMON_EVENTS && + event->attr.type != pmu->type) + return -ENOENT; + if (!try_module_get(pmu->module)) return -ENODEV; From patchwork Tue Mar 12 17:34:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590446 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 4C5A9C54E58 for ; Tue, 12 Mar 2024 17:35:17 +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:References:In-Reply-To: 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: List-Owner; bh=Mk9fPS3rlH/v1/OEFBUgFP05HL94OPnTUsIqeY3E4p4=; b=1aLYR7Pjl9/utN TkodGt98Be8T3UJ2hfxqasK1SQ8uG4UIAWWugWcnNJp4cI/jQnysiQ4CFZht6Y2P8rUxP8KlI/0AG /6EM0ybygIK5QkEhRarSH3eeNZFrM4sUbOWrNGWkaAUwcBQvhi7eZClKSEi27dls1DJHD7Rq9qEgd BGwEeiy/33ZFrFMRO8nQUbezLa6Gs28Y/93Ph4+gAl2+chKFnxUbvo4hFMaFmFhCcClZcFDt9IxQJ oKn8ITC8DZODh3D7hswyBep9e405TXeO3HPHOdqUnGomPib5gnI+OFKB1FJH5rR0Bg81Xs/NunwnF jQH0Oj8pRl6OSIKEQ6sg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61g-00000006sUJ-47ag; Tue, 12 Mar 2024 17:34:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61L-00000006sDK-1eT0 for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:39 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3E89B1650; Tue, 12 Mar 2024 10:35:09 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E36593F762; Tue, 12 Mar 2024 10:34:29 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 03/10] drivers/perf: Use PERF_PMU_CAP_NO_COMMON_EVENTS Date: Tue, 12 Mar 2024 17:34:05 +0000 Message-Id: <7043be8c1de4458927414cecc86445c805cd8820.1710257512.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103435_571198_78BDA60E X-CRM114-Status: GOOD ( 17.66 ) 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 Now that we have a core capability for refusing common event types, make use of it to purge the -ENOENT boilerplate from our system PMU drivers. Signed-off-by: Robin Murphy --- drivers/perf/alibaba_uncore_drw_pmu.c | 6 ++---- drivers/perf/amlogic/meson_ddr_pmu_core.c | 6 ++---- drivers/perf/arm-cci.c | 10 ++-------- drivers/perf/arm-ccn.c | 6 ++---- drivers/perf/arm-cmn.c | 6 ++---- drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++---- drivers/perf/arm_dmc620_pmu.c | 6 ++---- drivers/perf/arm_dsu_pmu.c | 6 ++---- drivers/perf/arm_smmuv3_pmu.c | 6 ++---- drivers/perf/arm_spe_pmu.c | 7 ++----- drivers/perf/cxl_pmu.c | 7 ++----- drivers/perf/dwc_pcie_pmu.c | 6 ++---- drivers/perf/fsl_imx8_ddr_perf.c | 6 ++---- drivers/perf/fsl_imx9_ddr_perf.c | 6 ++---- drivers/perf/hisilicon/hisi_pcie_pmu.c | 7 ++----- drivers/perf/hisilicon/hisi_uncore_pmu.c | 6 ++---- drivers/perf/hisilicon/hns3_pmu.c | 6 ++---- drivers/perf/marvell_cn10k_ddr_pmu.c | 6 ++---- drivers/perf/marvell_cn10k_tad_pmu.c | 6 ++---- drivers/perf/qcom_l2_pmu.c | 10 +++------- drivers/perf/qcom_l3_pmu.c | 9 ++------- drivers/perf/thunderx2_pmu.c | 7 ++----- drivers/perf/xgene_pmu.c | 7 ++----- 23 files changed, 47 insertions(+), 107 deletions(-) diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c index b37e9794823a..606c2301bd11 100644 --- a/drivers/perf/alibaba_uncore_drw_pmu.c +++ b/drivers/perf/alibaba_uncore_drw_pmu.c @@ -535,9 +535,6 @@ static int ali_drw_pmu_event_init(struct perf_event *event) struct perf_event *sibling; struct device *dev = drw_pmu->pmu.dev; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event)) { dev_err(dev, "Sampling not supported!\n"); return -EOPNOTSUPP; @@ -709,7 +706,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) .stop = ali_drw_pmu_stop, .read = ali_drw_pmu_read, .attr_groups = ali_drw_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; ret = perf_pmu_register(&drw_pmu->pmu, name, -1); diff --git a/drivers/perf/amlogic/meson_ddr_pmu_core.c b/drivers/perf/amlogic/meson_ddr_pmu_core.c index bbc7285fd934..c19b682297f3 100644 --- a/drivers/perf/amlogic/meson_ddr_pmu_core.c +++ b/drivers/perf/amlogic/meson_ddr_pmu_core.c @@ -121,9 +121,6 @@ static int meson_ddr_perf_event_init(struct perf_event *event) u64 config1 = event->attr.config1; u64 config2 = event->attr.config2; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; @@ -492,7 +489,8 @@ int meson_ddr_pmu_create(struct platform_device *pdev) *pmu = (struct ddr_pmu) { .pmu = { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = meson_ddr_perf_event_init, diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index 61de861eaf91..f157bfd4b923 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -815,10 +815,6 @@ static int pmu_map_event(struct perf_event *event) { struct cci_pmu *cci_pmu = to_cci_pmu(event->pmu); - if (event->attr.type < PERF_TYPE_MAX || - !cci_pmu->model->validate_hw_event) - return -ENOENT; - return cci_pmu->model->validate_hw_event(cci_pmu, event->attr.config); } @@ -1316,9 +1312,6 @@ static int cci_pmu_event_init(struct perf_event *event) atomic_t *active_events = &cci_pmu->active_events; int err = 0; - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* Shared by all CPUs, no meaningful state to sample */ if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; @@ -1420,7 +1413,8 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) .stop = cci_pmu_stop, .read = pmu_read, .attr_groups = pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; cci_pmu->plat_device = pdev; diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c index 728d13d8e98a..ce26bb773a56 100644 --- a/drivers/perf/arm-ccn.c +++ b/drivers/perf/arm-ccn.c @@ -719,9 +719,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) int i; struct perf_event *sibling; - if (event->attr.type != event->pmu->type) - return -ENOENT; - ccn = pmu_to_arm_ccn(event->pmu); if (hw->sample_period) { @@ -1275,7 +1272,8 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) .read = arm_ccn_pmu_event_read, .pmu_enable = arm_ccn_pmu_enable, .pmu_disable = arm_ccn_pmu_disable, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; /* No overflow interrupt? Have to use a timer instead. */ diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index c584165b13ba..717dd90417d6 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1696,9 +1696,6 @@ static int arm_cmn_event_init(struct perf_event *event) bool bynodeid; u16 nodeid, eventid; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EINVAL; @@ -2471,7 +2468,8 @@ static int arm_cmn_probe(struct platform_device *pdev) cmn->pmu = (struct pmu) { .module = THIS_MODULE, .attr_groups = arm_cmn_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .pmu_enable = arm_cmn_pmu_enable, .pmu_disable = arm_cmn_pmu_disable, diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index 50b89b989ce7..d408cbb84ed7 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -676,9 +676,6 @@ static int arm_cspmu_event_init(struct perf_event *event) cspmu = to_arm_cspmu(event->pmu); - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* * Following other "uncore" PMUs, we do not support sampling mode or * attach to a task (per-process mode). @@ -1186,7 +1183,8 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) if (ret) return ret; - capabilities = PERF_PMU_CAP_NO_EXCLUDE; + capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS; if (cspmu->irq == 0) capabilities |= PERF_PMU_CAP_NO_INTERRUPT; diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c index 30cea6859574..dc0b5269edc1 100644 --- a/drivers/perf/arm_dmc620_pmu.c +++ b/drivers/perf/arm_dmc620_pmu.c @@ -515,9 +515,6 @@ static int dmc620_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* * DMC 620 PMUs are shared across all cpus and cannot * support task bound and sampling events. @@ -673,7 +670,8 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev) dmc620_pmu->pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = dmc620_pmu_event_init, .add = dmc620_pmu_add, diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c index 7ec4498e312f..f5ea5acaf2f3 100644 --- a/drivers/perf/arm_dsu_pmu.c +++ b/drivers/perf/arm_dsu_pmu.c @@ -544,9 +544,6 @@ static int dsu_pmu_event_init(struct perf_event *event) { struct dsu_pmu *dsu_pmu = to_dsu_pmu(event->pmu); - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* We don't support sampling */ if (is_sampling_event(event)) { dev_dbg(dsu_pmu->pmu.dev, "Can't support sampling events\n"); @@ -762,7 +759,8 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) .read = dsu_pmu_read, .attr_groups = dsu_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; rc = perf_pmu_register(&dsu_pmu->pmu, name, -1); diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 6303b82566f9..ccecde79adb4 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -401,9 +401,6 @@ static int smmu_pmu_event_init(struct perf_event *event) int group_num_events = 1; u16 event_id; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (hwc->sample_period) { dev_dbg(dev, "Sampling not supported\n"); return -EOPNOTSUPP; @@ -870,7 +867,8 @@ static int smmu_pmu_probe(struct platform_device *pdev) .stop = smmu_pmu_event_stop, .read = smmu_pmu_event_read, .attr_groups = smmu_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; smmu_pmu->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res_0); diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index b622d75d8c9e..290e98247bba 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -699,10 +699,6 @@ static int arm_spe_pmu_event_init(struct perf_event *event) struct perf_event_attr *attr = &event->attr; struct arm_spe_pmu *spe_pmu = to_spe_pmu(event->pmu); - /* This is, of course, deeply driver-specific */ - if (attr->type != event->pmu->type) - return -ENOENT; - if (event->cpu >= 0 && !cpumask_test_cpu(event->cpu, &spe_pmu->supported_cpus)) return -ENOENT; @@ -932,7 +928,8 @@ static int arm_spe_pmu_perf_init(struct arm_spe_pmu *spe_pmu) spe_pmu->pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE, + .capabilities = PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .attr_groups = arm_spe_pmu_attr_groups, /* * We hitch a ride on the software context here, so that diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c index 365d964b0f6a..57954d102a75 100644 --- a/drivers/perf/cxl_pmu.c +++ b/drivers/perf/cxl_pmu.c @@ -571,10 +571,6 @@ static int cxl_pmu_event_init(struct perf_event *event) struct cxl_pmu_info *info = pmu_to_cxl_pmu_info(event->pmu); int rc; - /* Top level type sanity check - is this a Hardware Event being requested */ - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; /* TODO: Validation of any filter */ @@ -870,7 +866,8 @@ static int cxl_pmu_probe(struct device *dev) .read = cxl_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = cxl_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; if (info->irq <= 0) diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c index 957058ad0099..161faa98f627 100644 --- a/drivers/perf/dwc_pcie_pmu.c +++ b/drivers/perf/dwc_pcie_pmu.c @@ -366,9 +366,6 @@ static int dwc_pcie_pmu_event_init(struct perf_event *event) struct perf_event *sibling; u32 lane; - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* We don't support sampling */ if (is_sampling_event(event)) return -EINVAL; @@ -636,7 +633,8 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev) .parent = &pdev->dev, .module = THIS_MODULE, .attr_groups = dwc_pcie_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = dwc_pcie_pmu_event_init, .add = dwc_pcie_pmu_event_add, diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 7dbfaee372c7..021d637aea06 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -398,9 +398,6 @@ static int ddr_perf_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; @@ -651,7 +648,8 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu) { .pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init, diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 9685645bfe04..ec03e1e69568 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -416,9 +416,6 @@ static int ddr_perf_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; @@ -528,7 +525,8 @@ static void ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu) { .pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init, diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c index b90ba8aca3fa..5a301a7db7ae 100644 --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c @@ -353,10 +353,6 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event) struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - /* Check the type first before going on, otherwise it's not our event */ - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (EXT_COUNTER_IS_USED(hisi_pcie_get_event(event))) hwc->event_base = HISI_PCIE_EXT_CNT; else @@ -813,7 +809,8 @@ static int hisi_pcie_alloc_pmu(struct pci_dev *pdev, struct hisi_pcie_pmu *pcie_ .read = hisi_pcie_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hisi_pcie_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; return 0; diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c index 04031450d5fe..0908ddd992b7 100644 --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c @@ -186,9 +186,6 @@ int hisi_uncore_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct hisi_pmu *hisi_pmu; - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* * We do not support sampling as the counters are all * shared by all CPU cores in a CPU die(SCCL). Also we @@ -548,7 +545,8 @@ void hisi_pmu_init(struct hisi_pmu *hisi_pmu, struct module *module) pmu->stop = hisi_uncore_pmu_stop; pmu->read = hisi_uncore_pmu_read; pmu->attr_groups = hisi_pmu->pmu_events.attr_groups; - pmu->capabilities = PERF_PMU_CAP_NO_EXCLUDE; + pmu->capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS; } EXPORT_SYMBOL_GPL(hisi_pmu_init); diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index 16869bf5bf4c..300345edd211 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -1236,9 +1236,6 @@ static int hns3_pmu_event_init(struct perf_event *event) int idx; int ret; - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* Sampling is not supported */ if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; @@ -1429,7 +1426,8 @@ static int hns3_pmu_alloc_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) .read = hns3_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hns3_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; return 0; diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn10k_ddr_pmu.c index 524ba82bfce2..baa0a3fbad31 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -325,9 +325,6 @@ static int cn10k_ddr_perf_event_init(struct perf_event *event) struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (is_sampling_event(event)) { dev_info(pmu->dev, "Sampling not supported!\n"); return -EOPNOTSUPP; @@ -656,7 +653,8 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev) ddr_pmu->pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = cn10k_attr_groups, .event_init = cn10k_ddr_perf_event_init, diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c index fec8e82edb95..bc2d642e87e8 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -140,9 +140,6 @@ static int tad_pmu_event_init(struct perf_event *event) { struct tad_pmu *tad_pmu = to_tad_pmu(event->pmu); - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (!event->attr.disabled) return -EINVAL; @@ -321,7 +318,8 @@ static int tad_pmu_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = tad_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_INTERRUPT, + PERF_PMU_CAP_NO_INTERRUPT | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = tad_pmu_event_init, diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c index 3f9a98c17a89..8b2617ad4bdc 100644 --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -440,12 +440,7 @@ static int l2_cache_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct cluster_pmu *cluster; struct perf_event *sibling; - struct l2cache_pmu *l2cache_pmu; - - if (event->attr.type != event->pmu->type) - return -ENOENT; - - l2cache_pmu = to_l2cache_pmu(event->pmu); + struct l2cache_pmu *l2cache_pmu = to_l2cache_pmu(event->pmu); if (hwc->sample_period) { dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, @@ -914,7 +909,8 @@ static int l2_cache_pmu_probe(struct platform_device *pdev) .stop = l2_cache_event_stop, .read = l2_cache_event_read, .attr_groups = l2_cache_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; l2cache_pmu->num_counters = get_num_counters(); diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c index f16783d03db7..72610777567d 100644 --- a/drivers/perf/qcom_l3_pmu.c +++ b/drivers/perf/qcom_l3_pmu.c @@ -480,12 +480,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event) struct l3cache_pmu *l3pmu = to_l3cache_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - /* - * Is the event for this PMU? - */ - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* * Sampling not supported since these events are not core-attributable. */ @@ -760,7 +754,8 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev) .read = qcom_l3_cache__event_read, .attr_groups = qcom_l3_cache_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; l3pmu->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &memrc); diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 1edb9c03704f..8c7a2c6113be 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -574,10 +574,6 @@ static int tx2_uncore_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct tx2_uncore_pmu *tx2_pmu; - /* Test the event attr type check for PMU enumeration */ - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode. @@ -737,7 +733,8 @@ static int tx2_uncore_pmu_register( .start = tx2_uncore_event_start, .stop = tx2_uncore_event_stop, .read = tx2_uncore_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL, diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index 7ce344248dda..16bb3dfb1636 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -888,10 +888,6 @@ static int xgene_perf_event_init(struct perf_event *event) struct hw_perf_event *hw = &event->hw; struct perf_event *sibling; - /* Test the event attr type check for PMU enumeration */ - if (event->attr.type != event->pmu->type) - return -ENOENT; - /* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode. @@ -1112,7 +1108,8 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name) .start = xgene_perf_start, .stop = xgene_perf_stop, .read = xgene_perf_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; /* Hardware counter init */ From patchwork Tue Mar 12 17:34:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590444 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 CF66AC54E5D for ; Tue, 12 Mar 2024 17:35:11 +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:References:In-Reply-To: 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: List-Owner; bh=U/d+gg+gZkAL3JUCOfqnnveJGaW+HsuE80TYQpcnEhg=; b=I4r7mC67DgXK2K oEAXgqOLRkJu3angQh48047uHYlUls95clbexV2xr936Q67KUtEGx5ac52hDr+tPKm3mLbu4yJa9z C9rWaX9tu9B+EjBtMe35DQ7u71raUbTo2+ArEwxHGmQc0I20lUMhEIZbxleQxspNAf3MUMlwxtVTO rRpDOPy9PA+jipafiH+80VDxpqeMRsoAaB9wolwx+xuyF0iMpwD0kiHHzlhFAFw269V/90J+/g4E1 FKFAWCEcSEfHZulc53TcYd4tGqWPDLX2NOBnXJupLDXNMw90IlXjBcqWb+DIode/h+XbG0kzuWddp pHG8yJAIf3GLBLw6LVhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61i-00000006sVJ-0HRi; Tue, 12 Mar 2024 17:34:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61M-00000006sEQ-25cw for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:40 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A7AA215BF; Tue, 12 Mar 2024 10:35:11 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6C6EE3F762; Tue, 12 Mar 2024 10:34:32 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 04/10] perf: Rename PERF_PMU_CAP_NO_INTERRUPT Date: Tue, 12 Mar 2024 17:34:06 +0000 Message-Id: <0999a39f0a068979dbcc6119380f63d706101b4f.1710257512.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103436_717522_6964E816 X-CRM114-Status: GOOD ( 20.35 ) 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 PERF_PMU_CAP_NO_INTERRUPT flag is used by the core solely to determine whether PMUs can support sampling events or not. It makes sense to utilise the same capability for non-CPU-affine PMUs which have no relevant state to sample, but it would be a rather confusing misnomer when such PMUs do still have interrupts for handling overflows. Let's rename it to represent what it actually means. Signed-off-by: Robin Murphy --- arch/arc/kernel/perf_event.c | 2 +- arch/csky/kernel/perf_event.c | 2 +- arch/powerpc/perf/8xx-pmu.c | 2 +- arch/powerpc/perf/hv-24x7.c | 2 +- arch/powerpc/perf/hv-gpci.c | 2 +- arch/powerpc/platforms/pseries/papr_scm.c | 2 +- arch/s390/kernel/perf_cpum_cf.c | 2 +- arch/sh/kernel/perf_event.c | 2 +- arch/x86/events/amd/uncore.c | 6 +++--- arch/x86/events/core.c | 2 +- arch/x86/events/intel/cstate.c | 6 +++--- arch/x86/events/msr.c | 2 +- drivers/fpga/dfl-fme-perf.c | 2 +- drivers/perf/arm_cspmu/arm_cspmu.c | 2 +- drivers/perf/arm_pmu_platform.c | 2 +- drivers/perf/marvell_cn10k_tad_pmu.c | 2 +- drivers/perf/riscv_pmu_sbi.c | 2 +- include/linux/perf_event.h | 2 +- kernel/events/core.c | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c index adff957962da..cd02cf7904e8 100644 --- a/arch/arc/kernel/perf_event.c +++ b/arch/arc/kernel/perf_event.c @@ -819,7 +819,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev) } if (irq == -1) - arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING; /* * perf parser doesn't really like '-' symbol in events name, so let's diff --git a/arch/csky/kernel/perf_event.c b/arch/csky/kernel/perf_event.c index e5f18420ce64..c733fb29114f 100644 --- a/arch/csky/kernel/perf_event.c +++ b/arch/csky/kernel/perf_event.c @@ -1315,7 +1315,7 @@ int csky_pmu_device_probe(struct platform_device *pdev, ret = csky_pmu_request_irq(csky_pmu_handle_irq); if (ret) { - csky_pmu.pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + csky_pmu.pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING; pr_notice("[perf] PMU request irq fail!\n"); } diff --git a/arch/powerpc/perf/8xx-pmu.c b/arch/powerpc/perf/8xx-pmu.c index 308a2e40d7be..456de23c2ea7 100644 --- a/arch/powerpc/perf/8xx-pmu.c +++ b/arch/powerpc/perf/8xx-pmu.c @@ -181,7 +181,7 @@ static struct pmu mpc8xx_pmu = { .add = mpc8xx_pmu_add, .del = mpc8xx_pmu_del, .read = mpc8xx_pmu_read, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | + .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_NMI, }; diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c index 057ec2e3451d..74821bb193c1 100644 --- a/arch/powerpc/perf/hv-24x7.c +++ b/arch/powerpc/perf/hv-24x7.c @@ -1737,7 +1737,7 @@ static int hv_24x7_init(void) return -ENOMEM; /* sampling not supported */ - h_24x7_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + h_24x7_pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING r = create_events_from_catalog(&event_group.attrs, &event_desc_group.attrs, diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c index 27f18119fda1..25842f61662c 100644 --- a/arch/powerpc/perf/hv-gpci.c +++ b/arch/powerpc/perf/hv-gpci.c @@ -984,7 +984,7 @@ static int hv_gpci_init(void) return r; /* sampling not supported */ - h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING arg = (void *)get_cpu_var(hv_gpci_reqb); memset(arg, 0, HGPCI_REQ_BUFFER_SIZE); diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c index 1a53e048ceb7..6415cdabe403 100644 --- a/arch/powerpc/platforms/pseries/papr_scm.c +++ b/arch/powerpc/platforms/pseries/papr_scm.c @@ -501,7 +501,7 @@ static void papr_scm_pmu_register(struct papr_scm_priv *p) nd_pmu->pmu.add = papr_scm_pmu_add; nd_pmu->pmu.del = papr_scm_pmu_del; - nd_pmu->pmu.capabilities = PERF_PMU_CAP_NO_INTERRUPT | + nd_pmu->pmu.capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE; /*updating the cpumask variable */ diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c index 41ed6e0f0a2a..8474aafa2075 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -1054,7 +1054,7 @@ static void cpumf_pmu_del(struct perf_event *event, int flags) /* Performance monitoring unit for s390x */ static struct pmu cpumf_pmu = { .task_ctx_nr = perf_sw_context, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_SAMPLING .pmu_enable = cpumf_pmu_enable, .pmu_disable = cpumf_pmu_disable, .event_init = cpumf_pmu_event_init, diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c index 1d2507f22437..4bade9b7d357 100644 --- a/arch/sh/kernel/perf_event.c +++ b/arch/sh/kernel/perf_event.c @@ -352,7 +352,7 @@ int register_sh_pmu(struct sh_pmu *_pmu) * no interrupts, and are therefore unable to do sampling without * further work and timer assistance. */ - pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING WARN_ON(_pmu->num_events > MAX_HWEVENTS); diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 5bf03c575812..4220bf556962 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -700,7 +700,7 @@ int amd_uncore_df_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, .module = THIS_MODULE, }; @@ -833,7 +833,7 @@ int amd_uncore_l3_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, .module = THIS_MODULE, }; @@ -958,7 +958,7 @@ int amd_uncore_umc_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_umc_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, .module = THIS_MODULE, }; diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 09050641ce5d..20cded91716f 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1812,7 +1812,7 @@ static void __init pmu_check_apic(void) * events (user-space has to fall back and * sample via a hrtimer based software event): */ - pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING } diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c index 4b50a3a9818a..3e4ab89d440c 100644 --- a/arch/x86/events/intel/cstate.c +++ b/arch/x86/events/intel/cstate.c @@ -530,7 +530,7 @@ static struct pmu cstate_core_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, .module = THIS_MODULE, }; @@ -545,7 +545,7 @@ static struct pmu cstate_pkg_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, .module = THIS_MODULE, }; @@ -560,7 +560,7 @@ static struct pmu cstate_module_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, .module = THIS_MODULE, }; diff --git a/arch/x86/events/msr.c b/arch/x86/events/msr.c index 9e237b30f017..b33c0931d61d 100644 --- a/arch/x86/events/msr.c +++ b/arch/x86/events/msr.c @@ -296,7 +296,7 @@ static struct pmu pmu_msr = { .start = msr_event_start, .stop = msr_event_stop, .read = msr_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, .attr_update = attr_update, }; diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c index 7422d2bc6f37..b5bafea06a55 100644 --- a/drivers/fpga/dfl-fme-perf.c +++ b/drivers/fpga/dfl-fme-perf.c @@ -921,7 +921,7 @@ static int fme_perf_pmu_register(struct platform_device *pdev, pmu->start = fme_perf_event_start; pmu->stop = fme_perf_event_stop; pmu->read = fme_perf_event_read; - pmu->capabilities = PERF_PMU_CAP_NO_INTERRUPT | + pmu->capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE; name = devm_kasprintf(priv->dev, GFP_KERNEL, "dfl_fme%d", pdev->id); diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index d408cbb84ed7..32ffea50cd7a 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -1186,7 +1186,7 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_COMMON_EVENTS; if (cspmu->irq == 0) - capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + capabilities |= PERF_PMU_CAP_NO_SAMPLING; cspmu->pmu = (struct pmu){ .task_ctx_nr = perf_invalid_context, diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c index 3596db36cbff..e96c003f8555 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c @@ -109,7 +109,7 @@ static int pmu_parse_irqs(struct arm_pmu *pmu) */ if (num_irqs == 0) { dev_warn(dev, "no irqs for PMU, sampling events not supported\n"); - pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + pmu->pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING; cpumask_setall(&pmu->supported_cpus); return 0; } diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c index bc2d642e87e8..aaedb5715d69 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -318,7 +318,7 @@ static int tad_pmu_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = tad_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_INTERRUPT | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 16acd4dcdb96..aa562520ecfd 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -1049,7 +1049,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) ret = pmu_sbi_setup_irqs(pmu, pdev); if (ret < 0) { pr_info("Perf sampling/filtering is not supported as sscof extension is not available\n"); - pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + pmu->pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING; pmu->pmu.capabilities |= PERF_PMU_CAP_NO_EXCLUDE; } diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 983201f21dd2..b1fd832ed8bf 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -282,7 +282,7 @@ struct perf_event_pmu_context; /** * pmu::capabilities flags */ -#define PERF_PMU_CAP_NO_INTERRUPT 0x0001 +#define PERF_PMU_CAP_NO_SAMPLING 0x0001 #define PERF_PMU_CAP_NO_NMI 0x0002 #define PERF_PMU_CAP_AUX_NO_SG 0x0004 #define PERF_PMU_CAP_EXTENDED_REGS 0x0008 diff --git a/kernel/events/core.c b/kernel/events/core.c index 7ad80826c218..892212aae85e 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12539,7 +12539,7 @@ SYSCALL_DEFINE5(perf_event_open, } if (is_sampling_event(event)) { - if (event->pmu->capabilities & PERF_PMU_CAP_NO_INTERRUPT) { + if (event->pmu->capabilities & PERF_PMU_CAP_NO_SAMPLING) { err = -EOPNOTSUPP; goto err_alloc; } From patchwork Tue Mar 12 17:34:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590449 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 B4274C54E69 for ; Tue, 12 Mar 2024 17:35:19 +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:References:In-Reply-To: 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: List-Owner; bh=GsN3JAl3nE07PtXyzAOwcVV969SKma/DKB+XGb/nJbY=; b=3xVSlkoUvEaDxZ j6Ui456woX2PlUsRRRPKf0voTEgLZwkmXfftYTYOqmXLcggikWAlNsIWkeLorebTHBCF6NnlUpd2A 0CKmVLbzrZUYJJlLRkflfloMHovWFsRzMaS7iaJEGXNvo4U7Zphxq9qx2EwEA4g/0QTI7FyZZc6N+ QWlCM1MCYsNrI9La5ClvSO9yK7HWRnhdIOqSD+KYX2mC+56/JtLweYRnXUfwpVG6ryaCIU7ztCDri R3QRW94Oa8y5qG33RYHjuTGNJ7zqcNgta+yHhoVPP9pLKyYihYrDKMIIncZvbkxWEdcKUPlFAJhtL a7TwJXJ85tJONTBLPzQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61j-00000006sWD-0esz; Tue, 12 Mar 2024 17:34:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61O-00000006sG1-3Skh for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 273761570; Tue, 12 Mar 2024 10:35:14 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CBFEA3F762; Tue, 12 Mar 2024 10:34:34 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 05/10] drivers/perf: Use PERF_PMU_CAP_NO_SAMPLING consistently Date: Tue, 12 Mar 2024 17:34:07 +0000 Message-Id: <5622df31e5f4874c2c085d1ce930f5bbad889181.1710257512.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103439_435365_2E2F5E7C X-CRM114-Status: GOOD ( 20.41 ) 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 Our system PMUs fundamentally cannot support the current notion of sampling events, so now that the core capability has been clarified, apply it consistently and purge yet more boilerplate. Signed-off-by: Robin Murphy --- drivers/perf/alibaba_uncore_drw_pmu.c | 6 +----- drivers/perf/amlogic/meson_ddr_pmu_core.c | 3 ++- drivers/perf/arm-cci.c | 3 ++- drivers/perf/arm-ccn.c | 12 +----------- drivers/perf/arm-cmn.c | 3 ++- drivers/perf/arm_cspmu/arm_cspmu.c | 17 ++++------------- drivers/perf/arm_dmc620_pmu.c | 4 ++-- drivers/perf/arm_dsu_pmu.c | 12 +----------- drivers/perf/arm_smmuv3_pmu.c | 6 +----- drivers/perf/cxl_pmu.c | 3 ++- drivers/perf/dwc_pcie_pmu.c | 5 +---- drivers/perf/fsl_imx8_ddr_perf.c | 3 ++- drivers/perf/fsl_imx9_ddr_perf.c | 3 ++- drivers/perf/hisilicon/hisi_pcie_pmu.c | 4 ++-- drivers/perf/hisilicon/hisi_uncore_pmu.c | 3 ++- drivers/perf/hisilicon/hns3_pmu.c | 4 ++-- drivers/perf/marvell_cn10k_ddr_pmu.c | 6 +----- drivers/perf/qcom_l2_pmu.c | 7 +------ drivers/perf/qcom_l3_pmu.c | 7 +------ drivers/perf/thunderx2_pmu.c | 4 ++-- drivers/perf/xgene_pmu.c | 4 ++-- 21 files changed, 36 insertions(+), 83 deletions(-) diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c index 606c2301bd11..eadf4118d1ec 100644 --- a/drivers/perf/alibaba_uncore_drw_pmu.c +++ b/drivers/perf/alibaba_uncore_drw_pmu.c @@ -535,11 +535,6 @@ static int ali_drw_pmu_event_init(struct perf_event *event) struct perf_event *sibling; struct device *dev = drw_pmu->pmu.dev; - if (is_sampling_event(event)) { - dev_err(dev, "Sampling not supported!\n"); - return -EOPNOTSUPP; - } - if (event->attach_state & PERF_ATTACH_TASK) { dev_err(dev, "Per-task counter cannot allocate!\n"); return -EOPNOTSUPP; @@ -707,6 +702,7 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) .read = ali_drw_pmu_read, .attr_groups = ali_drw_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/amlogic/meson_ddr_pmu_core.c b/drivers/perf/amlogic/meson_ddr_pmu_core.c index c19b682297f3..3bc887cde163 100644 --- a/drivers/perf/amlogic/meson_ddr_pmu_core.c +++ b/drivers/perf/amlogic/meson_ddr_pmu_core.c @@ -121,7 +121,7 @@ static int meson_ddr_perf_event_init(struct perf_event *event) u64 config1 = event->attr.config1; u64 config2 = event->attr.config2; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; if (event->cpu < 0) @@ -490,6 +490,7 @@ int meson_ddr_pmu_create(struct platform_device *pdev) .pmu = { .module = THIS_MODULE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index f157bfd4b923..cf8fa2474bed 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -1313,7 +1313,7 @@ static int cci_pmu_event_init(struct perf_event *event) int err = 0; /* Shared by all CPUs, no meaningful state to sample */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; /* @@ -1414,6 +1414,7 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) .read = pmu_read, .attr_groups = pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c index ce26bb773a56..4114349e62dd 100644 --- a/drivers/perf/arm-ccn.c +++ b/drivers/perf/arm-ccn.c @@ -713,7 +713,6 @@ static void arm_ccn_pmu_event_release(struct perf_event *event) static int arm_ccn_pmu_event_init(struct perf_event *event) { struct arm_ccn *ccn; - struct hw_perf_event *hw = &event->hw; u32 node_xp, type, event_id; int valid; int i; @@ -721,16 +720,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ccn = pmu_to_arm_ccn(event->pmu); - if (hw->sample_period) { - dev_dbg(ccn->dev, "Sampling not supported!\n"); - return -EOPNOTSUPP; - } - - if (has_branch_stack(event)) { - dev_dbg(ccn->dev, "Can't exclude execution levels!\n"); - return -EINVAL; - } - if (event->cpu < 0) { dev_dbg(ccn->dev, "Can't provide per-task data!\n"); return -EOPNOTSUPP; @@ -1273,6 +1262,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) .pmu_enable = arm_ccn_pmu_enable, .pmu_disable = arm_ccn_pmu_disable, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 717dd90417d6..e1f151f04c9f 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1696,7 +1696,7 @@ static int arm_cmn_event_init(struct perf_event *event) bool bynodeid; u16 nodeid, eventid; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EINVAL; event->cpu = cmn->cpu; @@ -2469,6 +2469,7 @@ static int arm_cmn_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = arm_cmn_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .pmu_enable = arm_cmn_pmu_enable, diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index 32ffea50cd7a..c5c7198e6921 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -680,12 +680,6 @@ static int arm_cspmu_event_init(struct perf_event *event) * Following other "uncore" PMUs, we do not support sampling mode or * attach to a task (per-process mode). */ - if (is_sampling_event(event)) { - dev_dbg(cspmu->pmu.dev, - "Can't support sampling events\n"); - return -EOPNOTSUPP; - } - if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) { dev_dbg(cspmu->pmu.dev, "Can't support per-task counters\n"); @@ -1171,7 +1165,7 @@ static int arm_cspmu_get_cpus(struct arm_cspmu *cspmu) static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) { - int ret, capabilities; + int ret; struct attribute_group **attr_groups; attr_groups = arm_cspmu_alloc_attr_group(cspmu); @@ -1183,11 +1177,6 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) if (ret) return ret; - capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_COMMON_EVENTS; - if (cspmu->irq == 0) - capabilities |= PERF_PMU_CAP_NO_SAMPLING; - cspmu->pmu = (struct pmu){ .task_ctx_nr = perf_invalid_context, .module = cspmu->impl.module, @@ -1200,7 +1189,9 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) .stop = arm_cspmu_stop, .read = arm_cspmu_read, .attr_groups = (const struct attribute_group **)attr_groups, - .capabilities = capabilities, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; /* Hardware counter init */ diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c index dc0b5269edc1..47d3a166bccc 100644 --- a/drivers/perf/arm_dmc620_pmu.c +++ b/drivers/perf/arm_dmc620_pmu.c @@ -519,8 +519,7 @@ static int dmc620_pmu_event_init(struct perf_event *event) * DMC 620 PMUs are shared across all cpus and cannot * support task bound and sampling events. */ - if (is_sampling_event(event) || - event->attach_state & PERF_ATTACH_TASK) { + if (event->attach_state & PERF_ATTACH_TASK) { dev_dbg(dmc620_pmu->pmu.dev, "Can't support per-task counters\n"); return -EOPNOTSUPP; @@ -671,6 +670,7 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev) dmc620_pmu->pmu = (struct pmu) { .module = THIS_MODULE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = dmc620_pmu_event_init, diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c index f5ea5acaf2f3..3424d165795c 100644 --- a/drivers/perf/arm_dsu_pmu.c +++ b/drivers/perf/arm_dsu_pmu.c @@ -544,23 +544,12 @@ static int dsu_pmu_event_init(struct perf_event *event) { struct dsu_pmu *dsu_pmu = to_dsu_pmu(event->pmu); - /* We don't support sampling */ - if (is_sampling_event(event)) { - dev_dbg(dsu_pmu->pmu.dev, "Can't support sampling events\n"); - return -EOPNOTSUPP; - } - /* We cannot support task bound events */ if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) { dev_dbg(dsu_pmu->pmu.dev, "Can't support per-task counters\n"); return -EINVAL; } - if (has_branch_stack(event)) { - dev_dbg(dsu_pmu->pmu.dev, "Can't support filtering\n"); - return -EINVAL; - } - if (!cpumask_test_cpu(event->cpu, &dsu_pmu->associated_cpus)) { dev_dbg(dsu_pmu->pmu.dev, "Requested cpu is not associated with the DSU\n"); @@ -760,6 +749,7 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) .attr_groups = dsu_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index ccecde79adb4..8206ba0c1637 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -401,11 +401,6 @@ static int smmu_pmu_event_init(struct perf_event *event) int group_num_events = 1; u16 event_id; - if (hwc->sample_period) { - dev_dbg(dev, "Sampling not supported\n"); - return -EOPNOTSUPP; - } - if (event->cpu < 0) { dev_dbg(dev, "Per-task mode not supported\n"); return -EOPNOTSUPP; @@ -868,6 +863,7 @@ static int smmu_pmu_probe(struct platform_device *pdev) .read = smmu_pmu_event_read, .attr_groups = smmu_pmu_attr_grps, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c index 57954d102a75..41afbbd221a9 100644 --- a/drivers/perf/cxl_pmu.c +++ b/drivers/perf/cxl_pmu.c @@ -571,7 +571,7 @@ static int cxl_pmu_event_init(struct perf_event *event) struct cxl_pmu_info *info = pmu_to_cxl_pmu_info(event->pmu); int rc; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; /* TODO: Validation of any filter */ @@ -867,6 +867,7 @@ static int cxl_pmu_probe(struct device *dev) .task_ctx_nr = perf_invalid_context, .attr_groups = cxl_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c index 161faa98f627..638ad527f252 100644 --- a/drivers/perf/dwc_pcie_pmu.c +++ b/drivers/perf/dwc_pcie_pmu.c @@ -366,10 +366,6 @@ static int dwc_pcie_pmu_event_init(struct perf_event *event) struct perf_event *sibling; u32 lane; - /* We don't support sampling */ - if (is_sampling_event(event)) - return -EINVAL; - /* We cannot support task bound events */ if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) return -EINVAL; @@ -634,6 +630,7 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev) .module = THIS_MODULE, .attr_groups = dwc_pcie_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = dwc_pcie_pmu_event_init, diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 021d637aea06..0070f2bd4d88 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -398,7 +398,7 @@ static int ddr_perf_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; if (event->cpu < 0) { @@ -649,6 +649,7 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, .pmu = (struct pmu) { .module = THIS_MODULE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index ec03e1e69568..83822abf8031 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -416,7 +416,7 @@ static int ddr_perf_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; if (event->cpu < 0) { @@ -526,6 +526,7 @@ static void ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, .pmu = (struct pmu) { .module = THIS_MODULE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c index 5a301a7db7ae..7579b93dc462 100644 --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c @@ -358,8 +358,7 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event) else hwc->event_base = HISI_PCIE_CNT; - /* Sampling is not supported. */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; if (!hisi_pcie_pmu_valid_filter(event, pcie_pmu)) @@ -810,6 +809,7 @@ static int hisi_pcie_alloc_pmu(struct pci_dev *pdev, struct hisi_pcie_pmu *pcie_ .task_ctx_nr = perf_invalid_context, .attr_groups = hisi_pcie_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c index 0908ddd992b7..7718b031f671 100644 --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c @@ -191,7 +191,7 @@ int hisi_uncore_pmu_event_init(struct perf_event *event) * shared by all CPU cores in a CPU die(SCCL). Also we * do not support attach to a task(per-process mode) */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; /* @@ -546,6 +546,7 @@ void hisi_pmu_init(struct hisi_pmu *hisi_pmu, struct module *module) pmu->read = hisi_uncore_pmu_read; pmu->attr_groups = hisi_pmu->pmu_events.attr_groups; pmu->capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS; } EXPORT_SYMBOL_GPL(hisi_pmu_init); diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index 300345edd211..3d089df22c01 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -1236,8 +1236,7 @@ static int hns3_pmu_event_init(struct perf_event *event) int idx; int ret; - /* Sampling is not supported */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; event->cpu = hns3_pmu->on_cpu; @@ -1427,6 +1426,7 @@ static int hns3_pmu_alloc_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) .task_ctx_nr = perf_invalid_context, .attr_groups = hns3_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn10k_ddr_pmu.c index baa0a3fbad31..bb16a193ff36 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -325,11 +325,6 @@ static int cn10k_ddr_perf_event_init(struct perf_event *event) struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - if (is_sampling_event(event)) { - dev_info(pmu->dev, "Sampling not supported!\n"); - return -EOPNOTSUPP; - } - if (event->cpu < 0) { dev_warn(pmu->dev, "Can't provide per-task data!\n"); return -EOPNOTSUPP; @@ -654,6 +649,7 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev) ddr_pmu->pmu = (struct pmu) { .module = THIS_MODULE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = cn10k_attr_groups, diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c index 8b2617ad4bdc..3f7837632988 100644 --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -442,12 +442,6 @@ static int l2_cache_event_init(struct perf_event *event) struct perf_event *sibling; struct l2cache_pmu *l2cache_pmu = to_l2cache_pmu(event->pmu); - if (hwc->sample_period) { - dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, - "Sampling not supported\n"); - return -EOPNOTSUPP; - } - if (event->cpu < 0) { dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, "Per-task mode not supported\n"); @@ -910,6 +904,7 @@ static int l2_cache_pmu_probe(struct platform_device *pdev) .read = l2_cache_event_read, .attr_groups = l2_cache_pmu_attr_grps, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c index 72610777567d..54fde33802f4 100644 --- a/drivers/perf/qcom_l3_pmu.c +++ b/drivers/perf/qcom_l3_pmu.c @@ -480,12 +480,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event) struct l3cache_pmu *l3pmu = to_l3cache_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - /* - * Sampling not supported since these events are not core-attributable. - */ - if (hwc->sample_period) - return -EINVAL; - /* * Task mode not available, we run the counters as socket counters, * not attributable to any CPU and therefore cannot attribute per-task. @@ -755,6 +749,7 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev) .attr_groups = qcom_l3_cache_pmu_attr_grps, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 8c7a2c6113be..06b589799536 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -577,9 +577,8 @@ static int tx2_uncore_event_init(struct perf_event *event) /* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode. - * Also, it does not support event sampling mode. */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EINVAL; if (event->cpu < 0) @@ -734,6 +733,7 @@ static int tx2_uncore_pmu_register( .stop = tx2_uncore_event_stop, .read = tx2_uncore_event_read, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index 16bb3dfb1636..7f753b8f4e93 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -891,9 +891,8 @@ static int xgene_perf_event_init(struct perf_event *event) /* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode. - * Also, it does not support event sampling mode. */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) + if (event->attach_state & PERF_ATTACH_TASK) return -EINVAL; if (event->cpu < 0) @@ -1109,6 +1108,7 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name) .stop = xgene_perf_stop, .read = xgene_perf_read, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, }; From patchwork Tue Mar 12 17:34:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590445 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 E7003C54E5D for ; Tue, 12 Mar 2024 17:35:17 +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:References:In-Reply-To: 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: List-Owner; bh=FbcqIeQkar5ZjUPH++g+EG5Y/RIXwV2Uaw8Di/DajAU=; b=30LkflqwwQSFIA oNyi4nNqZU4m2DaJ71QUqjGd4q1NvdUlHcBY6PbS89WyEUwCMP0hLVc3F/F3D2QsMZkRLPjv+gHEI 6cu7JVqz8aRoWq6yqjFEsmpNoO2Vl7EW3u613JAwyRoz7qzcNfu0WN/lJWUCwDxPDZ8wK/1WsYXEb iF7E9ySgZvQ6U3h99Y3LEhpCetRn8Y4v+dnL1WXWeL3FskWhyAULuPpPDxSfgSesIDyi2v4KYn6mi UYlWZpHU4Tqn6NQmrtQki1gQ1SqWM9wawzazhwGWIHu9OJq8LqniPeFDtmmWMJmcdZPBSo9SYZH/G vuD/MXbTarA4pUkhTSlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61l-00000006sXL-07zU; Tue, 12 Mar 2024 17:35:01 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61R-00000006sEQ-09LZ for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8607615DB; Tue, 12 Mar 2024 10:35:16 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 551FD3F762; Tue, 12 Mar 2024 10:34:37 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 06/10] drivers/perf: Clean up redundant per-task checks Date: Tue, 12 Mar 2024 17:34:08 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103441_538865_9ED5B296 X-CRM114-Status: GOOD ( 25.91 ) 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 It turns out that a while back, perf_event_alloc() grew the ability to properly refuse all per-task and cgroup events on behalf of uncore/system PMUs using perf_invalid_context, so that's a whole load more inconsistent boilerplate which can also go from our drivers. This includes a couple more cases of drivers foolishly checking event->cpu *after* overriding it with their own (necessarily valid) CPU... Signed-off-by: Robin Murphy --- drivers/perf/alibaba_uncore_drw_pmu.c | 5 ----- drivers/perf/amlogic/meson_ddr_pmu_core.c | 6 ------ drivers/perf/arm-cci.c | 6 ------ drivers/perf/arm-ccn.c | 4 ---- drivers/perf/arm-cmn.c | 5 ----- drivers/perf/arm_cspmu/arm_cspmu.c | 10 ---------- drivers/perf/arm_dmc620_pmu.c | 12 ------------ drivers/perf/arm_dsu_pmu.c | 6 ------ drivers/perf/arm_smmuv3_pmu.c | 5 ----- drivers/perf/cxl_pmu.c | 2 -- drivers/perf/dwc_pcie_pmu.c | 4 ---- drivers/perf/fsl_imx8_ddr_perf.c | 8 -------- drivers/perf/fsl_imx9_ddr_perf.c | 8 -------- drivers/perf/hisilicon/hisi_pcie_pmu.c | 3 --- drivers/perf/hisilicon/hisi_uncore_pmu.c | 15 --------------- drivers/perf/hisilicon/hns3_pmu.c | 3 --- drivers/perf/marvell_cn10k_ddr_pmu.c | 5 ----- drivers/perf/qcom_l2_pmu.c | 6 ------ drivers/perf/qcom_l3_pmu.c | 7 ------- drivers/perf/thunderx2_pmu.c | 10 ---------- drivers/perf/xgene_pmu.c | 9 --------- 21 files changed, 139 deletions(-) diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c index eadf4118d1ec..42172939721b 100644 --- a/drivers/perf/alibaba_uncore_drw_pmu.c +++ b/drivers/perf/alibaba_uncore_drw_pmu.c @@ -535,11 +535,6 @@ static int ali_drw_pmu_event_init(struct perf_event *event) struct perf_event *sibling; struct device *dev = drw_pmu->pmu.dev; - if (event->attach_state & PERF_ATTACH_TASK) { - dev_err(dev, "Per-task counter cannot allocate!\n"); - return -EOPNOTSUPP; - } - event->cpu = drw_pmu->irq->cpu; if (event->group_leader != event && diff --git a/drivers/perf/amlogic/meson_ddr_pmu_core.c b/drivers/perf/amlogic/meson_ddr_pmu_core.c index 3bc887cde163..6fcd37b11dd8 100644 --- a/drivers/perf/amlogic/meson_ddr_pmu_core.c +++ b/drivers/perf/amlogic/meson_ddr_pmu_core.c @@ -121,12 +121,6 @@ static int meson_ddr_perf_event_init(struct perf_event *event) u64 config1 = event->attr.config1; u64 config2 = event->attr.config2; - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - - if (event->cpu < 0) - return -EOPNOTSUPP; - /* check if the number of parameters is too much */ if (event->attr.config != ALL_CHAN_COUNTER_ID && hweight64(config1) + hweight64(config2) > MAX_AXI_PORTS_OF_CHANNEL) diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index cf8fa2474bed..2ccce0e66ada 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -1312,10 +1312,6 @@ static int cci_pmu_event_init(struct perf_event *event) atomic_t *active_events = &cci_pmu->active_events; int err = 0; - /* Shared by all CPUs, no meaningful state to sample */ - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - /* * Following the example set by other "uncore" PMUs, we accept any CPU * and rewrite its affinity dynamically rather than having perf core @@ -1325,8 +1321,6 @@ static int cci_pmu_event_init(struct perf_event *event) * the event being installed into its context, so the PMU's CPU can't * change under our feet. */ - if (event->cpu < 0) - return -EINVAL; event->cpu = cci_pmu->cpu; event->destroy = hw_perf_event_destroy; diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c index 4114349e62dd..2adb6a1d136f 100644 --- a/drivers/perf/arm-ccn.c +++ b/drivers/perf/arm-ccn.c @@ -720,10 +720,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ccn = pmu_to_arm_ccn(event->pmu); - if (event->cpu < 0) { - dev_dbg(ccn->dev, "Can't provide per-task data!\n"); - return -EOPNOTSUPP; - } /* * Many perf core operations (eg. events rotation) operate on a * single CPU context. This is obvious for CPU PMUs, where one diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index e1f151f04c9f..26ede1db1f72 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1696,12 +1696,7 @@ static int arm_cmn_event_init(struct perf_event *event) bool bynodeid; u16 nodeid, eventid; - if (event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; - event->cpu = cmn->cpu; - if (event->cpu < 0) - return -EINVAL; type = CMN_EVENT_TYPE(event); /* DTC events (i.e. cycles) already have everything they need */ diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index c5c7198e6921..b007e1fdd336 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -676,16 +676,6 @@ static int arm_cspmu_event_init(struct perf_event *event) cspmu = to_arm_cspmu(event->pmu); - /* - * Following other "uncore" PMUs, we do not support sampling mode or - * attach to a task (per-process mode). - */ - if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) { - dev_dbg(cspmu->pmu.dev, - "Can't support per-task counters\n"); - return -EINVAL; - } - /* * Make sure the CPU assignment is on one of the CPUs associated with * this PMU. diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c index 47d3a166bccc..98e7c2333cc6 100644 --- a/drivers/perf/arm_dmc620_pmu.c +++ b/drivers/perf/arm_dmc620_pmu.c @@ -515,16 +515,6 @@ static int dmc620_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - /* - * DMC 620 PMUs are shared across all cpus and cannot - * support task bound and sampling events. - */ - if (event->attach_state & PERF_ATTACH_TASK) { - dev_dbg(dmc620_pmu->pmu.dev, - "Can't support per-task counters\n"); - return -EOPNOTSUPP; - } - /* * Many perf core operations (eg. events rotation) operate on a * single CPU context. This is obvious for CPU PMUs, where one @@ -535,8 +525,6 @@ static int dmc620_pmu_event_init(struct perf_event *event) * processor. */ event->cpu = dmc620_pmu->irq->cpu; - if (event->cpu < 0) - return -EINVAL; /* * We can't atomically disable all HW counters so only one event allowed, diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c index 3424d165795c..740f8c958976 100644 --- a/drivers/perf/arm_dsu_pmu.c +++ b/drivers/perf/arm_dsu_pmu.c @@ -544,12 +544,6 @@ static int dsu_pmu_event_init(struct perf_event *event) { struct dsu_pmu *dsu_pmu = to_dsu_pmu(event->pmu); - /* We cannot support task bound events */ - if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) { - dev_dbg(dsu_pmu->pmu.dev, "Can't support per-task counters\n"); - return -EINVAL; - } - if (!cpumask_test_cpu(event->cpu, &dsu_pmu->associated_cpus)) { dev_dbg(dsu_pmu->pmu.dev, "Requested cpu is not associated with the DSU\n"); diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 8206ba0c1637..f4e22ff179b9 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -401,11 +401,6 @@ static int smmu_pmu_event_init(struct perf_event *event) int group_num_events = 1; u16 event_id; - if (event->cpu < 0) { - dev_dbg(dev, "Per-task mode not supported\n"); - return -EOPNOTSUPP; - } - /* Verify specified event is supported on this PMU */ event_id = get_event(event); if (event_id < SMMU_PMCG_ARCH_MAX_EVENTS && diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c index 41afbbd221a9..e78f8db8ef52 100644 --- a/drivers/perf/cxl_pmu.c +++ b/drivers/perf/cxl_pmu.c @@ -571,8 +571,6 @@ static int cxl_pmu_event_init(struct perf_event *event) struct cxl_pmu_info *info = pmu_to_cxl_pmu_info(event->pmu); int rc; - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; /* TODO: Validation of any filter */ /* diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c index 638ad527f252..c2c4a7673e58 100644 --- a/drivers/perf/dwc_pcie_pmu.c +++ b/drivers/perf/dwc_pcie_pmu.c @@ -366,10 +366,6 @@ static int dwc_pcie_pmu_event_init(struct perf_event *event) struct perf_event *sibling; u32 lane; - /* We cannot support task bound events */ - if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; - if (event->group_leader != event && !is_software_event(event->group_leader)) return -EINVAL; diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 0070f2bd4d88..612216277ea5 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -398,14 +398,6 @@ static int ddr_perf_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - - if (event->cpu < 0) { - dev_warn(pmu->dev, "Can't provide per-task data!\n"); - return -EOPNOTSUPP; - } - /* * We must NOT create groups containing mixed PMUs, although software * events are acceptable (for example to create a CCN group diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 83822abf8031..80b4703bef89 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -416,14 +416,6 @@ static int ddr_perf_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct perf_event *sibling; - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - - if (event->cpu < 0) { - dev_warn(pmu->dev, "Can't provide per-task data!\n"); - return -EOPNOTSUPP; - } - /* * We must NOT create groups containing mixed PMUs, although software * events are acceptable (for example to create a CCN group diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c index 7579b93dc462..d37c65d40a30 100644 --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c @@ -358,9 +358,6 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event) else hwc->event_base = HISI_PCIE_CNT; - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - if (!hisi_pcie_pmu_valid_filter(event, pcie_pmu)) return -EINVAL; diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c index 7718b031f671..5de53e76e42f 100644 --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c @@ -186,21 +186,6 @@ int hisi_uncore_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct hisi_pmu *hisi_pmu; - /* - * We do not support sampling as the counters are all - * shared by all CPU cores in a CPU die(SCCL). Also we - * do not support attach to a task(per-process mode) - */ - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - - /* - * The uncore counters not specific to any CPU, so cannot - * support per-task - */ - if (event->cpu < 0) - return -EINVAL; - /* * Validate if the events in group does not exceed the * available counters in hardware. diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index 3d089df22c01..09bf38e56909 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -1236,9 +1236,6 @@ static int hns3_pmu_event_init(struct perf_event *event) int idx; int ret; - if (event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - event->cpu = hns3_pmu->on_cpu; idx = hns3_pmu_get_event_idx(hns3_pmu); diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn10k_ddr_pmu.c index bb16a193ff36..ebafa39a6b24 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -325,11 +325,6 @@ static int cn10k_ddr_perf_event_init(struct perf_event *event) struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - if (event->cpu < 0) { - dev_warn(pmu->dev, "Can't provide per-task data!\n"); - return -EOPNOTSUPP; - } - /* We must NOT create groups containing mixed PMUs */ if (event->group_leader->pmu != event->pmu && !is_software_event(event->group_leader)) diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c index 3f7837632988..d85f11c9261f 100644 --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -442,12 +442,6 @@ static int l2_cache_event_init(struct perf_event *event) struct perf_event *sibling; struct l2cache_pmu *l2cache_pmu = to_l2cache_pmu(event->pmu); - if (event->cpu < 0) { - dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, - "Per-task mode not supported\n"); - return -EOPNOTSUPP; - } - if (((L2_EVT_GROUP(event->attr.config) > L2_EVT_GROUP_MAX) || ((event->attr.config & ~L2_EVT_MASK) != 0)) && (event->attr.config != L2CYCLE_CTR_RAW_CODE)) { diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c index 54fde33802f4..733067fa68e5 100644 --- a/drivers/perf/qcom_l3_pmu.c +++ b/drivers/perf/qcom_l3_pmu.c @@ -480,13 +480,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event) struct l3cache_pmu *l3pmu = to_l3cache_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - /* - * Task mode not available, we run the counters as socket counters, - * not attributable to any CPU and therefore cannot attribute per-task. - */ - if (event->cpu < 0) - return -EINVAL; - /* Validate the group */ if (!qcom_l3_cache__validate_event_group(event)) return -EINVAL; diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 06b589799536..d9da3070f27c 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -574,16 +574,6 @@ static int tx2_uncore_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; struct tx2_uncore_pmu *tx2_pmu; - /* - * SOC PMU counters are shared across all cores. - * Therefore, it does not support per-process mode. - */ - if (event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; - - if (event->cpu < 0) - return -EINVAL; - tx2_pmu = pmu_to_tx2_pmu(event->pmu); if (tx2_pmu->cpu >= nr_cpu_ids) return -EINVAL; diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index 7f753b8f4e93..b2d855866354 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -888,15 +888,6 @@ static int xgene_perf_event_init(struct perf_event *event) struct hw_perf_event *hw = &event->hw; struct perf_event *sibling; - /* - * SOC PMU counters are shared across all cores. - * Therefore, it does not support per-process mode. - */ - if (event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; - - if (event->cpu < 0) - return -EINVAL; /* * Many perf core operations (eg. events rotation) operate on a * single CPU context. This is obvious for CPU PMUs, where one From patchwork Tue Mar 12 17:34:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590447 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 86892C54E68 for ; Tue, 12 Mar 2024 17:35:19 +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:References:In-Reply-To: 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: List-Owner; bh=03EZFsR80wi1sRwB1IyJ5ZDOiD9pSM8Dj1GSJkH4zyQ=; b=CCWEgmIZEhKp2c nvocpmfCx3NyHruw8wXuCpzK/hEXHVnObukCl26+9JdqylNzCnLUqZV1GZEyMxHCYHcu/JteMVToh 1PeTSl5OnWZy5eXLHCy7gJzofu3VZj0/K5ZkiKLNUIwEXRaWjD5xs9hwkNjPjAxVbNAoua8Er5Y13 K0LKA7KBskuwQnHunf3ZZ+T378N98A7cVZyfG8dX9+HjRISC2yCnosV/lDMl2Wr09igeDoGYSK/1r 2bJcqpfVZMldS3snLSLAPeOwfIUuIOOrJOqbqd0JtCFgQ0hKQ9Raf/H+aEwD6Ast6eHL4Pc0TY3LY 7hP58K+oA6CRjGJy2ULg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61m-00000006sYe-2b6H; Tue, 12 Mar 2024 17:35:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61T-00000006sKR-1sGy for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:48 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEE1815BF; Tue, 12 Mar 2024 10:35:18 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B3A223F762; Tue, 12 Mar 2024 10:34:39 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 07/10] perf: Define common uncore capabilities Date: Tue, 12 Mar 2024 17:34:09 +0000 Message-Id: <8496411b6ae9306b70cb90edafa4134b113a3cfe.1710257512.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103443_669581_09AE5C44 X-CRM114-Status: UNSURE ( 9.11 ) X-CRM114-Notice: Please train this message. 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 Nearly all uncore/system PMUs share a common set of capbilities, so let's wrap those up in a single macro for ease of use. Signed-off-by: Robin Murphy --- include/linux/perf_event.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index b1fd832ed8bf..5d5db122005b 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -293,6 +293,9 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 #define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200 +#define PERF_PMU_UNCORE_CAPS \ +(PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_COMMON_EVENTS) + struct perf_output_handle; #define PMU_NULL_DEV ((void *)(~0UL)) From patchwork Tue Mar 12 17:34:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590448 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 4440FC54E67 for ; Tue, 12 Mar 2024 17:35:19 +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:References:In-Reply-To: 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: List-Owner; bh=VhspMa3Bz++mRDteYYC2VdNR5qzK7kFN3c6TGrmGXOY=; b=QYyffyvn+vLtPH OCweTE5rbIjufOprwcDilqHNLrvVgosIjkExNulgLWOhI9oThKT8fzZQPweCWt5Nbxbav17D+5Sqo Vwy1jBBJOs0G+IrAk8xlZMMM359NYFSCr8JNuTBXL2aKHVdqSGIFuDea/OttNXo40/Nl3GAqkliAt YaiHPM0MgvOWWONerXg7pIopqv5O5JqKWjCmp/FqdVRmYYTHxMMEqdgjcdtTE+eXZq6IWmUgMicUr sjxdu/PmYuwV2Cktm1fYgf5kufDRF7DkcRygZ2fGdX9DjPeWvaP4gVmV8SxWavpsysMc8ABaLWQKG hNdW47Xi4JsQHX/ATCMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61n-00000006sZR-2qMd; Tue, 12 Mar 2024 17:35:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61W-00000006sMK-06iy for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 599381650; Tue, 12 Mar 2024 10:35:21 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 28AB03F762; Tue, 12 Mar 2024 10:34:42 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 08/10] drivers/perf: Use common uncore capabilities Date: Tue, 12 Mar 2024 17:34:10 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103446_309084_6D80AC7D X-CRM114-Status: GOOD ( 11.83 ) 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 Now that we've ratified it, adopt PERF_PMU_UNCORE_CAPS. Signed-off-by: Robin Murphy --- drivers/perf/alibaba_uncore_drw_pmu.c | 4 +--- drivers/perf/amlogic/meson_ddr_pmu_core.c | 4 +--- drivers/perf/arm-cci.c | 4 +--- drivers/perf/arm-ccn.c | 4 +--- drivers/perf/arm-cmn.c | 4 +--- drivers/perf/arm_cspmu/arm_cspmu.c | 4 +--- drivers/perf/arm_dmc620_pmu.c | 4 +--- drivers/perf/arm_dsu_pmu.c | 4 +--- drivers/perf/arm_smmuv3_pmu.c | 4 +--- drivers/perf/cxl_pmu.c | 4 +--- drivers/perf/dwc_pcie_pmu.c | 4 +--- drivers/perf/fsl_imx8_ddr_perf.c | 4 +--- drivers/perf/fsl_imx9_ddr_perf.c | 4 +--- drivers/perf/hisilicon/hisi_pcie_pmu.c | 4 +--- drivers/perf/hisilicon/hisi_uncore_pmu.c | 4 +--- drivers/perf/hisilicon/hns3_pmu.c | 4 +--- drivers/perf/marvell_cn10k_ddr_pmu.c | 4 +--- drivers/perf/marvell_cn10k_tad_pmu.c | 4 +--- drivers/perf/qcom_l2_pmu.c | 4 +--- drivers/perf/qcom_l3_pmu.c | 4 +--- drivers/perf/thunderx2_pmu.c | 4 +--- drivers/perf/xgene_pmu.c | 4 +--- 22 files changed, 22 insertions(+), 66 deletions(-) diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c index 42172939721b..9bacb79a86c4 100644 --- a/drivers/perf/alibaba_uncore_drw_pmu.c +++ b/drivers/perf/alibaba_uncore_drw_pmu.c @@ -696,9 +696,7 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) .stop = ali_drw_pmu_stop, .read = ali_drw_pmu_read, .attr_groups = ali_drw_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; ret = perf_pmu_register(&drw_pmu->pmu, name, -1); diff --git a/drivers/perf/amlogic/meson_ddr_pmu_core.c b/drivers/perf/amlogic/meson_ddr_pmu_core.c index 6fcd37b11dd8..e6370ea08231 100644 --- a/drivers/perf/amlogic/meson_ddr_pmu_core.c +++ b/drivers/perf/amlogic/meson_ddr_pmu_core.c @@ -483,9 +483,7 @@ int meson_ddr_pmu_create(struct platform_device *pdev) *pmu = (struct ddr_pmu) { .pmu = { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = meson_ddr_perf_event_init, diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index 2ccce0e66ada..916e9881adf9 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -1407,9 +1407,7 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) .stop = cci_pmu_stop, .read = pmu_read, .attr_groups = pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; cci_pmu->plat_device = pdev; diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c index 2adb6a1d136f..3f2f41ee476e 100644 --- a/drivers/perf/arm-ccn.c +++ b/drivers/perf/arm-ccn.c @@ -1257,9 +1257,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) .read = arm_ccn_pmu_event_read, .pmu_enable = arm_ccn_pmu_enable, .pmu_disable = arm_ccn_pmu_disable, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; /* No overflow interrupt? Have to use a timer instead. */ diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 26ede1db1f72..e779da94351a 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -2463,9 +2463,7 @@ static int arm_cmn_probe(struct platform_device *pdev) cmn->pmu = (struct pmu) { .module = THIS_MODULE, .attr_groups = arm_cmn_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .pmu_enable = arm_cmn_pmu_enable, .pmu_disable = arm_cmn_pmu_disable, diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index b007e1fdd336..2d9cb2ac0213 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -1179,9 +1179,7 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) .stop = arm_cspmu_stop, .read = arm_cspmu_read, .attr_groups = (const struct attribute_group **)attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; /* Hardware counter init */ diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c index 98e7c2333cc6..047bff8733c4 100644 --- a/drivers/perf/arm_dmc620_pmu.c +++ b/drivers/perf/arm_dmc620_pmu.c @@ -657,9 +657,7 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev) dmc620_pmu->pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .event_init = dmc620_pmu_event_init, .add = dmc620_pmu_add, diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c index 740f8c958976..8d97ef86f9a8 100644 --- a/drivers/perf/arm_dsu_pmu.c +++ b/drivers/perf/arm_dsu_pmu.c @@ -742,9 +742,7 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) .read = dsu_pmu_read, .attr_groups = dsu_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; rc = perf_pmu_register(&dsu_pmu->pmu, name, -1); diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index f4e22ff179b9..34669d1314a4 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -857,9 +857,7 @@ static int smmu_pmu_probe(struct platform_device *pdev) .stop = smmu_pmu_event_stop, .read = smmu_pmu_event_read, .attr_groups = smmu_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; smmu_pmu->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res_0); diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c index e78f8db8ef52..8b7548192245 100644 --- a/drivers/perf/cxl_pmu.c +++ b/drivers/perf/cxl_pmu.c @@ -864,9 +864,7 @@ static int cxl_pmu_probe(struct device *dev) .read = cxl_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = cxl_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; if (info->irq <= 0) diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c index c2c4a7673e58..bb8d77b470ce 100644 --- a/drivers/perf/dwc_pcie_pmu.c +++ b/drivers/perf/dwc_pcie_pmu.c @@ -625,9 +625,7 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev) .parent = &pdev->dev, .module = THIS_MODULE, .attr_groups = dwc_pcie_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .event_init = dwc_pcie_pmu_event_init, .add = dwc_pcie_pmu_event_add, diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 612216277ea5..1f250ff3075b 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -640,9 +640,7 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu) { .pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init, diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 80b4703bef89..a9156f17886b 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -517,9 +517,7 @@ static void ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu) { .pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init, diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c index d37c65d40a30..35f0407f4e10 100644 --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c @@ -805,9 +805,7 @@ static int hisi_pcie_alloc_pmu(struct pci_dev *pdev, struct hisi_pcie_pmu *pcie_ .read = hisi_pcie_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hisi_pcie_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; return 0; diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c index 5de53e76e42f..25d1e704ea25 100644 --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c @@ -530,9 +530,7 @@ void hisi_pmu_init(struct hisi_pmu *hisi_pmu, struct module *module) pmu->stop = hisi_uncore_pmu_stop; pmu->read = hisi_uncore_pmu_read; pmu->attr_groups = hisi_pmu->pmu_events.attr_groups; - pmu->capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS; + pmu->capabilities = PERF_PMU_UNCORE_CAPS; } EXPORT_SYMBOL_GPL(hisi_pmu_init); diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index 09bf38e56909..34b1ca3f0bb6 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -1422,9 +1422,7 @@ static int hns3_pmu_alloc_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) .read = hns3_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hns3_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; return 0; diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn10k_ddr_pmu.c index ebafa39a6b24..ee69077a9320 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -643,9 +643,7 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev) ddr_pmu->pmu = (struct pmu) { .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .attr_groups = cn10k_attr_groups, .event_init = cn10k_ddr_perf_event_init, diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c index aaedb5715d69..c83924a094dc 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -317,9 +317,7 @@ static int tad_pmu_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = tad_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .event_init = tad_pmu_event_init, diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c index d85f11c9261f..67e69e0293aa 100644 --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -897,9 +897,7 @@ static int l2_cache_pmu_probe(struct platform_device *pdev) .stop = l2_cache_event_stop, .read = l2_cache_event_read, .attr_groups = l2_cache_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; l2cache_pmu->num_counters = get_num_counters(); diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c index 733067fa68e5..f545c01aa671 100644 --- a/drivers/perf/qcom_l3_pmu.c +++ b/drivers/perf/qcom_l3_pmu.c @@ -741,9 +741,7 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev) .read = qcom_l3_cache__event_read, .attr_groups = qcom_l3_cache_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; l3pmu->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &memrc); diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index d9da3070f27c..c1e2372f57c5 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -722,9 +722,7 @@ static int tx2_uncore_pmu_register( .start = tx2_uncore_event_start, .stop = tx2_uncore_event_stop, .read = tx2_uncore_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL, diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index b2d855866354..8cc6989857e8 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -1098,9 +1098,7 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name) .start = xgene_perf_start, .stop = xgene_perf_stop, .read = xgene_perf_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; /* Hardware counter init */ From patchwork Tue Mar 12 17:34:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590450 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 46D26C54E58 for ; Tue, 12 Mar 2024 17:35:21 +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:References:In-Reply-To: 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: List-Owner; bh=eU9QUI/Tquk9sRJ/xD/a1qXdx6AQry/7XNTmaR3JhVM=; b=qztTyvnxRNh/12 ukEvMqCgCRF1wEnBkqCDbFoVn/DmvW9ujZF7nYu0MbiR7TUEy2OLY1PT8cDvF3jv74Wypufq62zdp Zu5bRtpgpxrHLH+iG+4Rq/CQGcNlZ1BRa7lTCnMgSQO+X2N17yI7jc8r0t3tT5H1bo8czcA3BdUOO CHbGaEOdmhft8WFOpTKJvd2a4Ztw0CK2WTldbbtQyZyW/0w9EEJFU8fAffxLbE/NLGUejzNzlu3yl Y9ZMRNgsFideidwTixIpU9ORZoYbrYIgyn+DFgaNMqvy79+4Klr+CvZg+79Wj0QSjLQBb5dMbj87o YPAiZkkANW56nrUUgKbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61r-00000006scI-2c31; Tue, 12 Mar 2024 17:35:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61X-00000006sDK-1yZS for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:54 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 209621570; Tue, 12 Mar 2024 10:35:24 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 882003F762; Tue, 12 Mar 2024 10:34:44 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn, Thomas Gleixner , Borislav Petkov , Dave Hansen Subject: [PATCH 09/10] x86: Use common uncore PMU capabilities Date: Tue, 12 Mar 2024 17:34:11 +0000 Message-Id: <8a92d8b76ab0658919cd58515f68ed30c805e070.1710257512.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103447_892063_745F747C X-CRM114-Status: GOOD ( 21.54 ) 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 Switch the x86 uncore PMU drivers over to the new common capabilities, allowing to remove all the checks that perf core now takes care of. CC: Thomas Gleixner CC: Borislav Petkov CC: Dave Hansen Signed-off-by: Robin Murphy --- arch/x86/events/amd/iommu.c | 17 +---------------- arch/x86/events/amd/power.c | 10 +--------- arch/x86/events/amd/uncore.c | 12 +++--------- arch/x86/events/intel/cstate.c | 16 +++------------- arch/x86/events/intel/uncore.c | 11 +---------- arch/x86/events/intel/uncore_snb.c | 20 +++----------------- arch/x86/events/msr.c | 9 +-------- arch/x86/events/rapl.c | 9 +-------- 8 files changed, 14 insertions(+), 90 deletions(-) diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c index b15f7b950d2e..dd4cabb40865 100644 --- a/arch/x86/events/amd/iommu.c +++ b/arch/x86/events/amd/iommu.c @@ -207,21 +207,6 @@ static int perf_iommu_event_init(struct perf_event *event) { struct hw_perf_event *hwc = &event->hw; - /* test the event attr type check for PMU enumeration */ - if (event->attr.type != event->pmu->type) - return -ENOENT; - - /* - * IOMMU counters are shared across all cores. - * Therefore, it does not support per-process mode. - * Also, it does not support event sampling mode. - */ - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; - - if (event->cpu < 0) - return -EINVAL; - /* update the hw_perf_event struct with the iommu config data */ hwc->conf = event->attr.config; hwc->conf1 = event->attr.config1; @@ -412,7 +397,7 @@ static const struct pmu iommu_pmu __initconst = { .read = perf_iommu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = amd_iommu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, }; static __init int init_one_iommu(unsigned int idx) diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c index 37d5b380516e..d528517df93e 100644 --- a/arch/x86/events/amd/power.c +++ b/arch/x86/events/amd/power.c @@ -124,14 +124,6 @@ static int pmu_event_init(struct perf_event *event) { u64 cfg = event->attr.config & AMD_POWER_EVENT_MASK; - /* Only look at AMD power events. */ - if (event->attr.type != pmu_class.type) - return -ENOENT; - - /* Unsupported modes and filters. */ - if (event->attr.sample_period) - return -EINVAL; - if (cfg != AMD_POWER_EVENTSEL_PKG) return -EINVAL; @@ -212,7 +204,7 @@ static struct pmu pmu_class = { .start = pmu_event_start, .stop = pmu_event_stop, .read = pmu_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 4220bf556962..6e97ee4ccf4d 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -209,12 +209,6 @@ static int amd_uncore_event_init(struct perf_event *event) struct amd_uncore_ctx *ctx; struct hw_perf_event *hwc = &event->hw; - if (event->attr.type != event->pmu->type) - return -ENOENT; - - if (event->cpu < 0) - return -EINVAL; - pmu = event_to_amd_uncore_pmu(event); ctx = *per_cpu_ptr(pmu->ctx, event->cpu); if (!ctx) @@ -700,7 +694,7 @@ int amd_uncore_df_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; @@ -833,7 +827,7 @@ int amd_uncore_l3_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; @@ -958,7 +952,7 @@ int amd_uncore_umc_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_umc_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c index 3e4ab89d440c..58d6e5b483c5 100644 --- a/arch/x86/events/intel/cstate.c +++ b/arch/x86/events/intel/cstate.c @@ -319,16 +319,6 @@ static int cstate_pmu_event_init(struct perf_event *event) u64 cfg = event->attr.config; int cpu; - if (event->attr.type != event->pmu->type) - return -ENOENT; - - /* unsupported modes and filters */ - if (event->attr.sample_period) /* no sampling */ - return -EINVAL; - - if (event->cpu < 0) - return -EINVAL; - if (event->pmu == &cstate_core_pmu) { if (cfg >= PERF_CSTATE_CORE_EVENT_MAX) return -EINVAL; @@ -530,7 +520,7 @@ static struct pmu cstate_core_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; @@ -545,7 +535,7 @@ static struct pmu cstate_pkg_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; @@ -560,7 +550,7 @@ static struct pmu cstate_module_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, }; diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 7927c0b832fa..031d5aff297a 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -736,24 +736,15 @@ static int uncore_pmu_event_init(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; int ret; - if (event->attr.type != event->pmu->type) - return -ENOENT; - pmu = uncore_event_to_pmu(event); /* no device found for this pmu */ if (pmu->func_id < 0) return -ENOENT; - /* Sampling not supported yet */ - if (hwc->sample_period) - return -EINVAL; - /* * Place all uncore events for a particular physical package * onto a single cpu */ - if (event->cpu < 0) - return -EINVAL; box = uncore_pmu_to_box(pmu, event->cpu); if (!box || box->cpu < 0) return -EINVAL; @@ -919,7 +910,7 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu) .stop = uncore_pmu_event_stop, .read = uncore_pmu_event_read, .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .attr_update = pmu->type->attr_update, }; } else { diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c index 7fd4334e12a1..2af53e3f16c1 100644 --- a/arch/x86/events/intel/uncore_snb.c +++ b/arch/x86/events/intel/uncore_snb.c @@ -876,33 +876,19 @@ static int snb_uncore_imc_event_init(struct perf_event *event) u64 cfg = event->attr.config & SNB_UNCORE_PCI_IMC_EVENT_MASK; int idx, base; - if (event->attr.type != event->pmu->type) - return -ENOENT; - pmu = uncore_event_to_pmu(event); /* no device found for this pmu */ if (pmu->func_id < 0) return -ENOENT; - /* Sampling not supported yet */ - if (hwc->sample_period) - return -EINVAL; - - /* unsupported modes and filters */ - if (event->attr.sample_period) /* no sampling */ + /* check only supported bits are set */ + if (event->attr.config & ~SNB_UNCORE_PCI_IMC_EVENT_MASK) return -EINVAL; /* * Place all uncore events for a particular physical package * onto a single cpu */ - if (event->cpu < 0) - return -EINVAL; - - /* check only supported bits are set */ - if (event->attr.config & ~SNB_UNCORE_PCI_IMC_EVENT_MASK) - return -EINVAL; - box = uncore_pmu_to_box(pmu, event->cpu); if (!box || box->cpu < 0) return -EINVAL; @@ -1013,7 +999,7 @@ static struct pmu snb_uncore_imc_pmu = { .start = uncore_pmu_event_start, .stop = uncore_pmu_event_stop, .read = uncore_pmu_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, }; static struct intel_uncore_ops snb_uncore_imc_ops = { diff --git a/arch/x86/events/msr.c b/arch/x86/events/msr.c index b33c0931d61d..af8dd83aca48 100644 --- a/arch/x86/events/msr.c +++ b/arch/x86/events/msr.c @@ -204,13 +204,6 @@ static int msr_event_init(struct perf_event *event) { u64 cfg = event->attr.config; - if (event->attr.type != event->pmu->type) - return -ENOENT; - - /* unsupported modes and filters */ - if (event->attr.sample_period) /* no sampling */ - return -EINVAL; - if (cfg >= PERF_MSR_EVENT_MAX) return -EINVAL; @@ -296,7 +289,7 @@ static struct pmu pmu_msr = { .start = msr_event_start, .stop = msr_event_stop, .read = msr_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .attr_update = attr_update, }; diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 8d98d468b976..34b054970c3d 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -328,17 +328,10 @@ static int rapl_pmu_event_init(struct perf_event *event) int bit, ret = 0; struct rapl_pmu *pmu; - /* only look at RAPL events */ - if (event->attr.type != rapl_pmus->pmu.type) - return -ENOENT; - /* check only supported bits are set */ if (event->attr.config & ~RAPL_EVENT_MASK) return -EINVAL; - if (event->cpu < 0) - return -EINVAL; - event->event_caps |= PERF_EV_CAP_READ_ACTIVE_PKG; if (!cfg || cfg >= NR_RAPL_DOMAINS + 1) @@ -693,7 +686,7 @@ static int __init init_rapl_pmus(void) rapl_pmus->pmu.stop = rapl_pmu_event_stop; rapl_pmus->pmu.read = rapl_pmu_event_read; rapl_pmus->pmu.module = THIS_MODULE; - rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE; + rapl_pmus->pmu.capabilities = PERF_PMU_UNCORE_CAPS; return 0; } From patchwork Tue Mar 12 17:34:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13590451 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 9FE6BC54E67 for ; Tue, 12 Mar 2024 17:35:23 +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:References:In-Reply-To: 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: List-Owner; bh=53QricsHH/mbvD11o/iu8bW6MdsWpTf6oUUpUeJV8yk=; b=K9AQvfSwq7545D ddoS6B4d9WJB5aQxlaSnIJZWVQt9e803waPMCWQHBuzGjlm/qZPoJuqw/mrCS+sQlC63QcjZdz/p2 8xidLoSfdKWUYwIT0uWa8sSccGJvYU94lxIBCzYPyQvPl/Jgj+0VHdlGkRA9P3r2wfseGb9pWpwzR x/tb0MEHrjiSipD3IETpMhDCbosgZ0Uzuoi5+ZbTjrZwRskp7WnbNo4s0ZUnIQ6QBjTEx6i4wnlxb Xq14oJBFD4PowNrT19jMoh9jUbqNSvDHj2LlN8gViwJyHasXDEqOzZruRP2+6SZdxqjVme/k3jKgV XbY+11M2OTwt6Fp2EZQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61o-00000006saP-42Sg; Tue, 12 Mar 2024 17:35:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk61a-00000006sF7-01VF for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 17:34:54 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB0D615BF; Tue, 12 Mar 2024 10:35:26 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4EB4D3F762; Tue, 12 Mar 2024 10:34:47 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn, Russell King , Shawn Guo , Sascha Hauer Subject: [PATCH 10/10] ARM: Use common uncore PMU capabilities Date: Tue, 12 Mar 2024 17:34:12 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_103450_360899_0F49C08A X-CRM114-Status: GOOD ( 12.68 ) 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 Switch the ARM system PMU drivers over to the new common capabilities, allowing to remove all the checks that perf core now takes care of. CC: Russell King CC: Shawn Guo CC: Sascha Hauer Signed-off-by: Robin Murphy Acked-by: Shawn Guo --- arch/arm/mach-imx/mmdc.c | 16 +--------------- arch/arm/mm/cache-l2x0-pmu.c | 12 +----------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c index 444a7eaa320c..806ab6675b37 100644 --- a/arch/arm/mach-imx/mmdc.c +++ b/arch/arm/mach-imx/mmdc.c @@ -280,20 +280,6 @@ static int mmdc_pmu_event_init(struct perf_event *event) struct mmdc_pmu *pmu_mmdc = to_mmdc_pmu(event->pmu); int cfg = event->attr.config; - if (event->attr.type != event->pmu->type) - return -ENOENT; - - if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) - return -EOPNOTSUPP; - - if (event->cpu < 0) { - dev_warn(pmu_mmdc->dev, "Can't provide per-task data!\n"); - return -EOPNOTSUPP; - } - - if (event->attr.sample_period) - return -EINVAL; - if (cfg < 0 || cfg >= MMDC_NUM_COUNTERS) return -EINVAL; @@ -445,7 +431,7 @@ static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc, .start = mmdc_pmu_event_start, .stop = mmdc_pmu_event_stop, .read = mmdc_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, }, .mmdc_base = mmdc_base, .dev = dev, diff --git a/arch/arm/mm/cache-l2x0-pmu.c b/arch/arm/mm/cache-l2x0-pmu.c index 993fefdc167a..a2567d953fdb 100644 --- a/arch/arm/mm/cache-l2x0-pmu.c +++ b/arch/arm/mm/cache-l2x0-pmu.c @@ -295,16 +295,6 @@ static int l2x0_pmu_event_init(struct perf_event *event) { struct hw_perf_event *hw = &event->hw; - if (event->attr.type != l2x0_pmu->type) - return -ENOENT; - - if (is_sampling_event(event) || - event->attach_state & PERF_ATTACH_TASK) - return -EINVAL; - - if (event->cpu < 0) - return -EINVAL; - if (event->attr.config & ~L2X0_EVENT_CNT_CFG_SRC_MASK) return -EINVAL; @@ -524,7 +514,7 @@ static __init int l2x0_pmu_init(void) .del = l2x0_pmu_event_del, .event_init = l2x0_pmu_event_init, .attr_groups = l2x0_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, }; l2x0_pmu_reset();