Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1781092rdb; Mon, 9 Oct 2023 02:43:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQfT3pX9/G2B1mF/ugVmdFrZCRTBIkfXfkKlpL3zm/sWPWYsIEafZxBXY0NxKhj2X58rmS X-Received: by 2002:a17:90a:2a87:b0:274:9200:3973 with SMTP id j7-20020a17090a2a8700b0027492003973mr11482483pjd.36.1696844628331; Mon, 09 Oct 2023 02:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696844628; cv=none; d=google.com; s=arc-20160816; b=SSwIaDinpaMoHaLFiPAt5iyxvvoRPuJlu2cvBpRnphUT5j07BxbH1yHfvxxDwOto2r lCpUhMg4QZLO/uYThgOSwMqvbZk3YWLy+t6fMuD4aZNqBx2YInqWt1LOXPGK5LMXnr09 9o4CRyUw1boy3+iM+S0umFfyQdx3B/DgOh0gG4AuYM1CYkU4COzuihpgrtzYTbCKqOZP IxLAG3VjVRHxT0lpoknLmVaqGNOAd74pntUc8kp1Y1Bbyez9A1HiwKSBHx5vP8Lc92QJ pwMZMXjmeiekiyMdae8KNgw2M8V3YBXH/7G82b1OA/d6UYuvAi4F9YHkDF0+Vp3IMgGT kRNg== 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=JuFPIFQMotOryxWPoQJnGM/Fzy1kQzRBJCueeJtxVmw=; fh=ke9zMQy17pJ/cUilhTj63oZeUT2foHxD+RCmdSlpuC8=; b=Flfg8si3aCOnHqilAIM+0VaTgQ/LDG+XsdYr1Yu6cj4UOa/z8MSFPkrIfWKudEzpFf p1yrZHG7KDruNFT9WW8wVQDhtwhcPiTE5fH/maWWS0PoFo4KSfff5Ho6drxxd4xN3MIN QsM08XUqz/bWXzmbeFoW18g2ZO88e1EGuiDmaWR3FgjhZ7XpFEiAxg7447g7caZ6qQf4 wqKXN0XbIFxYugYfT9Y+enXNTQf4HCxggFu5+vAJnasLgSwjHOMwBjSKJhskeldJus8W QMqcOr54s5uCMUFXiJMnVSJKuR3XStTj987sAvdFy3NUM8PsmaE3qJITq/I0e2hyB+99 Y7Kg== 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 h6-20020a17090acf0600b00274985b2fcdsi6083591pju.138.2023.10.09.02.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 02:43:48 -0700 (PDT) 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 96434805AA37; Mon, 9 Oct 2023 02:43:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345692AbjJIJni (ORCPT + 99 others); Mon, 9 Oct 2023 05:43:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345326AbjJIJng (ORCPT ); Mon, 9 Oct 2023 05:43:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0BE048F for ; Mon, 9 Oct 2023 02:43:35 -0700 (PDT) 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 592F01FB; Mon, 9 Oct 2023 02:44:15 -0700 (PDT) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D6D583F7A6; Mon, 9 Oct 2023 02:43:33 -0700 (PDT) Message-ID: <66125bc2-ff2a-a209-a753-c2e3d8310a45@arm.com> Date: Mon, 9 Oct 2023 10:43:34 +0100 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] drivers: perf: arm_pmuv3: Update 'pmc_width' based on actual HW event width Content-Language: en-US To: Anshuman Khandual , linux-arm-kernel@lists.infradead.org, Rob Herring , raphael.gault@arm.com Cc: Will Deacon , Mark Rutland , linux-kernel@vger.kernel.org References: <20231009043724.175100-1-anshuman.khandual@arm.com> From: James Clark In-Reply-To: <20231009043724.175100-1-anshuman.khandual@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS 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]); Mon, 09 Oct 2023 02:43:45 -0700 (PDT) On 09/10/2023 05:37, Anshuman Khandual wrote: > This updates 'perf_event_mmap_page->pmc_width' based on actual HW event's > width that are currently missing i.e ARMPMU_EVT_63BIT and ARMPMU_EVT_47BIT. > Might be worth adding why this is needed or what the actual effect is. > Cc: Will Deacon > Cc: Mark Rutland > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > This applies on v6.6-rc5. > > drivers/perf/arm_pmuv3.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c > index fe4db1831662..94723d00548e 100644 > --- a/drivers/perf/arm_pmuv3.c > +++ b/drivers/perf/arm_pmuv3.c > @@ -1375,6 +1375,10 @@ void arch_perf_update_userpage(struct perf_event *event, > if (userpg->cap_user_rdpmc) { > if (event->hw.flags & ARMPMU_EVT_64BIT) > userpg->pmc_width = 64; > + else if (event->hw.flags & ARMPMU_EVT_63BIT) > + userpg->pmc_width = 63; > + else if (event->hw.flags & ARMPMU_EVT_47BIT) > + userpg->pmc_width = 47; Although it doesn't explicitly say it, the bit of the docs about pmc_width in Documentation/arch/arm64/perf.rst loosely implies that this is always either 64 or 32. Now that this isn't the case it could mislead someone in userspace that they don't have to handle the now arbitrary bit widths rather than just whole bytes/ints. I think the fix is as simple as adding something like "the width may not match the requested value or necessarily be a multiple of 8". Unless we think this is already widely known and I suppose we could leave it as is. (The existing bit in perf that uses it already handles it correctly). > else > userpg->pmc_width = 32; > }