Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp942053rdf; Wed, 22 Nov 2023 00:45:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IERZClrkAUCDX7tshxLxnbbm1h3QYYVK2Lsb9fBM6K2orXLv1Mts69kIVCMQtT5Sm5aiOVd X-Received: by 2002:a05:6a20:3956:b0:187:4329:f06d with SMTP id r22-20020a056a20395600b001874329f06dmr7072545pzg.31.1700642751357; Wed, 22 Nov 2023 00:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700642751; cv=none; d=google.com; s=arc-20160816; b=jEKJAYYt7DbVzWPBpP+4nGyYtR3MN8ynEf7WAVr4ZoXOe34EA3rFuMeB09UMDnrYLN ypEcoEG36hmdHryMQR3uahtusMrSiWw2AdcgHAQtFwy0ty445/GSmRVKNtIapCVivYS0 zDyMsBF5n3Psxy0e8OzCkSCcx+gAUU/0FKtHOFpLCZvWO1PfojotCgCZCjoTXVqjTsrP 5YA/hJiOwVNuINNOOiLArETyjd1zplMncowSJNyu1yN9P1uFdfIzx3MToStdy1AjY19I BVJiFlHx3Y8YJtoRlM+bQYWBn6QlTQKJDFC2VmEwmGRtRbmIHGLdjEoqIwCRL9eLyPwJ EiDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=cqzOG0p5dDELSIvxxuEiUor+RdHwl/6hP/ayT+MzNlo=; fh=nOqhHfnJd6kSgHfO8J5Q8P/GaGiVNrZWuBtWbv+aPnM=; b=zZL/eNKEUOsh4579uSxqNsforM6Xh6BVK+LVp+sI0TmqvqjwjBRUNpqjeK0QQRqNIn S8ULsWilG/BUeaUXszG4KOyEiSdfMr8L+XoBpdaurxy9cq24HwFkECsi9AXLRiTo39B7 e7XTkhk5kUvjAjN+MO1qUa5u5HGYOAACThnT/lvofOwNO+FlnUUo8H5leIeTtnmkHcqI 7tIds8+LVie9z47Y4I3bI/sYJJpGJOVMpMPpZM+uW3CSo9mmvQ9vv1UHRFhXdheGAP/i loV8gZardB1mPYwugxgQ8OqEGFcCRRpiRx1C+0C7tf3gM6bNCNyKEkSFDIxYBjl+/kaJ a9Fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w64-20020a636243000000b005bdfb77e552si11789816pgb.439.2023.11.22.00.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 00:45:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 71C358087259; Wed, 22 Nov 2023 00:45:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbjKVIpD (ORCPT + 99 others); Wed, 22 Nov 2023 03:45:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjKVIpC (ORCPT ); Wed, 22 Nov 2023 03:45:02 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B922A1; Wed, 22 Nov 2023 00:44:58 -0800 (PST) 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 F0DDC1595; Wed, 22 Nov 2023 00:45:44 -0800 (PST) Received: from [10.162.41.8] (a077893.blr.arm.com [10.162.41.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 12E723F73F; Wed, 22 Nov 2023 00:44:54 -0800 (PST) Message-ID: <347fc210-8c31-47be-a87a-656fa30a72ef@arm.com> Date: Wed, 22 Nov 2023 14:14:52 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/3] arm64: perf: Include threshold control fields in PMEVTYPER mask Content-Language: en-US To: James Clark , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, suzuki.poulose@arm.com, will@kernel.org, mark.rutland@arm.com Cc: Catalin Marinas , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231113112507.917107-1-james.clark@arm.com> <20231113112507.917107-2-james.clark@arm.com> From: Anshuman Khandual In-Reply-To: <20231113112507.917107-2-james.clark@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 00:45:20 -0800 (PST) On 11/13/23 16:55, James Clark wrote: > FEAT_PMUv3_TH (Armv8.8) adds two new fields to PMEVTYPER, so include > them in the mask. These aren't writable on 32 bit kernels as they are in > the high part of the register, so only include them for arm64. > > It would be difficult to do this statically in the asm header files for > each platform without resulting in circular includes or #ifdefs inline > in the code. For that reason the ARMV8_PMU_EVTYPE_MASK definition has > been removed and the mask is constructed programmatically. Agreed, and this also makes sense because there is just a single instance for ARMV8_PMU_EVTYPE_MASK in armv8pmu_write_evtype(). > > Signed-off-by: James Clark > --- > drivers/perf/arm_pmuv3.c | 9 ++++++++- > include/linux/perf/arm_pmuv3.h | 3 ++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c > index 6ca7be05229c..1d40d794f5e4 100644 > --- a/drivers/perf/arm_pmuv3.c > +++ b/drivers/perf/arm_pmuv3.c > @@ -555,8 +555,15 @@ static void armv8pmu_write_counter(struct perf_event *event, u64 value) > static inline void armv8pmu_write_evtype(int idx, u32 val) > { > u32 counter = ARMV8_IDX_TO_COUNTER(idx); > + unsigned long mask = ARMV8_PMU_EVTYPE_EVENT | > + ARMV8_PMU_INCLUDE_EL2 | > + ARMV8_PMU_EXCLUDE_EL0 | > + ARMV8_PMU_EXCLUDE_EL1; At first this looks bit odd sequence - EL2, EL0, EL1 but such as these bit positions. #define ARMV8_PMU_EXCLUDE_EL1 (1U << 31) #define ARMV8_PMU_EXCLUDE_EL0 (1U << 30) #define ARMV8_PMU_INCLUDE_EL2 (1U << 27) > > - val &= ARMV8_PMU_EVTYPE_MASK; > + if (IS_ENABLED(CONFIG_ARM64)) > + mask |= ARMV8_PMU_EVTYPE_TC | ARMV8_PMU_EVTYPE_TH; This makes sense. > + > + val &= mask; > write_pmevtypern(counter, val); > } > > diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h > index 9c226adf938a..ddd1fec86739 100644 > --- a/include/linux/perf/arm_pmuv3.h > +++ b/include/linux/perf/arm_pmuv3.h > @@ -228,7 +228,8 @@ > /* > * PMXEVTYPER: Event selection reg > */ > -#define ARMV8_PMU_EVTYPE_MASK 0xc800ffff /* Mask for writable bits */ > +#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32) > +#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61) Looks correct. > #define ARMV8_PMU_EVTYPE_EVENT 0xffff /* Mask for EVENT bits */ > > /* Reviewed-by: Anshuman Khandual