From patchwork Fri Dec 15 15:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13494561 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 08AFAC35274 for ; Fri, 15 Dec 2023 15:01:36 +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=xOJB3DD38B9JomE5v7r55xHz7WhRd2vqAeVEqHfV3J0=; b=NksjicF7T46qkC jDRxlzWcuK1kvkTU7qIWHKk106xWD8tTOUPHDwqbfqzakswHWqqkOxgZJD798usaYbJNU1/RmeqBE Tn6qHNFcMDNmg/O6PbtGwQVmx5U7szp4sgDYB3dZiTQ+MizsII4TeUTIyWv4wSa4Ks9I+nsbHp+BM Q3NXkLPJy0/ipoAB0HUdeCRg/YIRY7SWl/10cuzYAwyVC4Y7UalcElDr25RnJeD0j2eLE9N1wXKHG AYJIt2KmD0mDn8ulugMaAQVtLp8x3/Vuz4xGEnwKPgJcRWmMXe4DID6g0LyFEBkge1CvJe81GA3lF UAWCbXR3agMGm3cSDSoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9ga-003e0e-0J; Fri, 15 Dec 2023 15:01:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9gW-003dzQ-1g for linux-arm-kernel@lists.infradead.org; Fri, 15 Dec 2023 15:01:06 +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 0D1BB1063; Fri, 15 Dec 2023 07:01:49 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3393F3F5A1; Fri, 15 Dec 2023 07:01:00 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-next@vger.kernel.org, will@kernel.org, u.kleine-koenig@pengutronix.de Cc: James Clark , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Anshuman Khandual , Suzuki K Poulose , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 1/2] arm: perf: Fix ARCH=arm build with GCC in armv8pmu_write_evtype() Date: Fri, 15 Dec 2023 15:00:38 +0000 Message-Id: <20231215150040.3342183-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215150040.3342183-1-james.clark@arm.com> References: <20231215150040.3342183-1-james.clark@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_070105_454526_4410AD75 X-CRM114-Status: GOOD ( 10.58 ) 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 LLVM ignores everything inside the if statement and doesn't generate errors, but GCC doesn't ignore it, resulting in the following error: drivers/perf/arm_pmuv3.c: In function ‘armv8pmu_write_evtype’: include/linux/bits.h:34:29: error: left shift count >= width of type [-Werror=shift-count-overflow] 34 | (((~UL(0)) - (UL(1) << (l)) + 1) & \ Fix it by changing the if to #if. Fixes: 3115ee021bfb ("arm64: perf: Include threshold control fields in PMEVTYPER mask") Reported-by: Uwe Kleine-König Closes: https://lore.kernel.org/linux-arm-kernel/20231215120817.h2f3akgv72zhrtqo@pengutronix.de/ Signed-off-by: James Clark --- drivers/perf/arm_pmuv3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 23fa6c5da82c..3ed2086cefc3 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -631,8 +631,9 @@ static void armv8pmu_write_evtype(int idx, unsigned long val) ARMV8_PMU_EXCLUDE_EL0 | ARMV8_PMU_EXCLUDE_EL1; - if (IS_ENABLED(CONFIG_ARM64)) - mask |= ARMV8_PMU_EVTYPE_TC | ARMV8_PMU_EVTYPE_TH; +#if IS_ENABLED(CONFIG_ARM64) + mask |= ARMV8_PMU_EVTYPE_TC | ARMV8_PMU_EVTYPE_TH; +#endif val &= mask; write_pmevtypern(counter, val); From patchwork Fri Dec 15 15:00:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13494563 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 8CDE6C35274 for ; Fri, 15 Dec 2023 15:01:45 +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=Er8Sclt2xR02R4hr5by7bblxjGbBQm+eMPfyInjaBWA=; b=lpRC6AJuO5/zBw iVFb9x4AVluV/AGLGuGlTPgLRQ61m2NFjLJ20GnSA7pEw1Nt99Rc/jqV/cgdjr7cjURFkVPIJQB2Q j5UYNxIhPC5AThb8o6lCqMh5ffjlwQStOR/1iR76EVkqXWsbAMnZ+OxNgVi4NqQR7hmv7EspNJAmU jnb5zOIaAyuG8wwBRGST6veRbLoPE9mjvLRneFlznn14Cm8YRB3BB9OOLpD1FklgSEIWy6T3DWfLf nyNCvOBKNA4q9fM+qouG9oRrqxVt+q/N/yIi2dPvdV1KflIVSTI6GggU0YirF2sN5m/h7x7DuUHLq E0953MmJXEGiDodKtn0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9gj-003e47-39; Fri, 15 Dec 2023 15:01:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9ga-003e0v-1Y for linux-arm-kernel@lists.infradead.org; Fri, 15 Dec 2023 15:01:09 +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 CA28CC15; Fri, 15 Dec 2023 07:01:52 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BB2853F5A1; Fri, 15 Dec 2023 07:01:04 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-next@vger.kernel.org, will@kernel.org, u.kleine-koenig@pengutronix.de Cc: James Clark , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Anshuman Khandual , Suzuki K Poulose , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 2/2] arm: perf: Fix ARCH=arm build with GCC in armv8pmu_set_event_filter() Date: Fri, 15 Dec 2023 15:00:39 +0000 Message-Id: <20231215150040.3342183-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215150040.3342183-1-james.clark@arm.com> References: <20231215150040.3342183-1-james.clark@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_070108_567687_67754DD0 X-CRM114-Status: GOOD ( 11.72 ) 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 LLVM ignores everything inside the if statement and doesn't generate errors, but GCC does, resulting in the following: drivers/perf/arm_pmuv3.c: In function armv8pmu_set_event_filter: include/linux/bits.h:34:29: error: left shift count >= width of type [-Werror=shift-count-overflow] 34 | (((~UL(0)) - (UL(1) << (l)) + 1) & \ Fix it by changing the if to #if. This results in an unused function warning for armv8pmu_event_threshold_control(), so suppress that too. Fixes: 816c26754447 ("arm64: perf: Add support for event counting threshold") Signed-off-by: James Clark --- drivers/perf/arm_pmuv3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 3ed2086cefc3..8aa23878019a 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -338,7 +338,7 @@ static bool armv8pmu_event_want_user_access(struct perf_event *event) return ATTR_CFG_GET_FLD(&event->attr, rdpmc); } -static u8 armv8pmu_event_threshold_control(struct perf_event_attr *attr) +static __maybe_unused u8 armv8pmu_event_threshold_control(struct perf_event_attr *attr) { u8 th_compare = ATTR_CFG_GET_FLD(attr, threshold_compare); u8 th_count = ATTR_CFG_GET_FLD(attr, threshold_count); @@ -1040,11 +1040,13 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event, return -EINVAL; } - if (IS_ENABLED(CONFIG_ARM64) && th) { +#if IS_ENABLED(CONFIG_ARM64) + if (th) { config_base |= FIELD_PREP(ARMV8_PMU_EVTYPE_TH, th); config_base |= FIELD_PREP(ARMV8_PMU_EVTYPE_TC, armv8pmu_event_threshold_control(attr)); } +#endif /* * Install the filter into config_base as this is used to