Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6845406rdb; Fri, 15 Dec 2023 09:43:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSY1LHHO91lyKcXOuxeC0QTNUzPiVGSAWauIqfcMRnIAPfkMgqSXfrmaMnRucaKolTu3pC X-Received: by 2002:a17:907:c007:b0:a1f:7069:fc02 with SMTP id ss7-20020a170907c00700b00a1f7069fc02mr7364791ejc.87.1702662185296; Fri, 15 Dec 2023 09:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702662185; cv=none; d=google.com; s=arc-20160816; b=wOXRmJT0o8tz+rr/v7lWGLGTz3zWrUhNpJuyO2TWXdvX9grpL09U5+hiHk8+3yTemf xORX0rups0f9kInFpqdqhI5033WpmnbbM1FMRMgx4Ye4MSq0gmdRr0CQG/PAEXD5T+NA UHx/sU8goDlyavZ5lF8NfKhqziplGUNuS6SHMGArGtWqX7qC4BQeewUpr3CF/c+hXGeu /3HLiT8kY+NTrhkMbbjCDuiHR2baydj2R68eb2kwFcRSHQK0sTtoE67REISm93q6Owbw oShSGM0ZADaxr9IiLVNe6rCdW710jx9/I/A0jv5YrWA7Co8ydB0h1Fh2/G4u7EVD9XQo ANAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ncpzawXwbmZpY7M0y8Z8hu4gwCKnzj5mv5oFX70mQn8=; fh=TrGXTVbgtS8xrqvC+dP2mj4BRf0tt3eEEH/D95VFRTI=; b=vDnph39D/V0OCbt9yR5hqbfLzfB6G8xEdQfw5zrRKEk8LkADCUa6RcKAySTzzYYXks F5609dMn7CbGEjgRzOfVhCwrVh8fwPJRzYvSmnpCizt6Lyns1cHWG8x0iHWGobT6Z4fY FBGWvlWhz0NRV+KLRM1SBYC5izPXnm2dfWX6eutO1QsLsc4CMcdSnjBVt4axcimPGvdi cZ/zeuDkACFTqH0yNRqC3ivEw9G2ZRpFmya4CPAFshF9Cn+OGh9JnK4AsUSDTMwMQkiB cxg0Z27Uo/uQDvsW3xuu4JlCwut+3NMYmX6EpqP5q91XPJxEylp99Dc8ACdzf9ipKBIA kxyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n6-20020a170906378600b00a1d4bba57f7si7575054ejc.956.2023.12.15.09.43.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:43:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 109881F24714 for ; Fri, 15 Dec 2023 17:43:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 931EA1DDC1; Fri, 15 Dec 2023 17:42:56 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5114282ED4; Fri, 15 Dec 2023 17:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 0E005C15; Fri, 15 Dec 2023 09:43:38 -0800 (PST) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3404A3F5A1; Fri, 15 Dec 2023 09:42:51 -0800 (PST) Message-ID: Date: Fri, 15 Dec 2023 17:42:50 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 1/2] arm: perf: Fix ARCH=arm build with GCC in armv8pmu_write_evtype() Content-Language: en-US To: Mark Rutland Cc: 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, Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Anshuman Khandual , Suzuki K Poulose , linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20231215150040.3342183-1-james.clark@arm.com> <20231215150040.3342183-2-james.clark@arm.com> From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 15/12/2023 16:21, Mark Rutland wrote: > On Fri, Dec 15, 2023 at 03:00:38PM +0000, James Clark wrote: >> 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. > > I reckon it'd be cleaner to use GENMASK_ULL for the TH and TC fields, in > include/linux/perf/arm_pmu.h have: > > | /* > | * PMXEVTYPER: Event selection reg > | */ > | #define ARMV8_PMU_EVTYPE_EVENT GENMASK(15, 0) /* Mask for EVENT bits */ > | #define ARMV8_PMU_EVTYPE_TH GENMASK_ULL(43, 32) /* arm64 only */ > | #define ARMV8_PMU_EVTYPE_TC GENMASK_ULL(63, 61) /* arm64 only */ > > IIUC that should silence this warning, and it'd remove the need for the > ifdeffery and other changes in patch 2. > > Does that work, or am I missing something? > > Thanks, > Mark. > You're right that does work. For some reason I thought there was some component of writing it to the mask that was the issue as well. I'll send another version with that fix instead. Thanks James >> >> Fixes: 3115ee021bfb ("arm64: perf: Include threshold control fields in PMEVTYPER mask") >> Reported-by: Uwe Kleine-K"onig >> 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); >> -- >> 2.34.1 >>