From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91880C433DB for ; Tue, 30 Mar 2021 11:32:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07B5261964 for ; Tue, 30 Mar 2021 11:32:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07B5261964 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ac879Yq06N+ugftfof2iJh1Rh5lgBbKMKgqaNSbd5ZQ=; b=FpVjzgC3pvom+ATgoxixvD6AL ZQEwMcvsB5aD7dM2jktzAFh0YBFEo/haXI/+S4LKwMBIpQq6IuGkFwabvhzzpTOUwiVX+YtK3YG1y mC+mq9fGtZIqB6D/H9sly10N74R0MB7bYgL4b6c7BqSuFI1+4wyF5zXEx6V4MChGM4AIQaJhUT/T/ WP0ohDXDUwbqLKB7AWF8nEJyR+SriolVpft7q1XLqzKsb/MZfXhlc/rY8D3KnahEfznRu385fZ397 BV4TXqbgUcSpmkHs413FJMiOigpoYxZPl9iYgpI9T3KS5+2xaQUyzIwCqzfs/lFCeI2GVSX9KCDBE p18X1HXlw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRCab-003Zio-7P; Tue, 30 Mar 2021 11:31:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRCaV-003Zi1-Li for linux-arm-kernel@lists.infradead.org; Tue, 30 Mar 2021 11:31:13 +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 191D11FB; Tue, 30 Mar 2021 04:31:02 -0700 (PDT) Received: from [10.57.57.107] (unknown [10.57.57.107]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D1CE93F694; Tue, 30 Mar 2021 04:30:59 -0700 (PDT) Subject: Re: [PATCH v6 02/10] arm64: perf: Enable PMU counter direct access for perf event To: Rob Herring , Will Deacon , Catalin Marinas , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Mark Rutland Cc: Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nd@arm.com References: <20210311000837.3630499-1-robh@kernel.org> <20210311000837.3630499-3-robh@kernel.org> From: Zachary Leaf Message-ID: <9e904f20-7943-ee44-9653-7aa949c3ba88@arm.com> Date: Tue, 30 Mar 2021 12:30:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210311000837.3630499-3-robh@kernel.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210330_123112_003017_E5AA01BD X-CRM114-Status: GOOD ( 16.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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/03/2021 00:08, Rob Herring wrote: > > In order to enable 64-bit counters for userspace when available, a new > config1 bit is added for userspace to indicate it wants userspace counter > access. This bit allows the kernel to decide if chaining should be > disabled and chaining and userspace access are incompatible. > The modes for config1 are as follows: > > config1 = 0 or 2 : user access enabled and always 32-bit > config1 = 1 : user access disabled and always 64-bit (using chaining if needed) > config1 = 3 : user access enabled and counter size matches underlying counter. > Thanks for this Rob. That makes it extremely easy to request 64 bit userspace counters without having to worry about the underlying bit width supported on your system. The underlying PMUv3 bit width is otherwise not accessible from userspace as far as I can tell (e.g. the relevant PMUVer bits [11:8] of ID_AA64DFR0_EL1 are masked off when reading from EL0 [1]), and the workaround of requesting 64 bit, checking cap_user_rdpmc for userspace access, and retrying with 32 bit was not that user friendly. I think it makes a lot of sense for the kernel to handle/expose it here rather than handled in the application code. I think it's worth mentioning here if anyone searches, is that the 32 bit counter behaviour when added to the perf_event_mmap_page->offset is effectively the same as a single 64 bit counter due to the offset being incremented on overflow. Using a true 64 bit counter can avoid the overhead of handling an interrupt for each overflow (and obviously has a lot more headroom before it overflows, if you require very long running perf stats). I have tested the new config1 flags on N1-SDP and the behaviour is as expected. [1] https://github.com/torvalds/linux/blob/master/Documentation/arm64/cpu-feature-registers.rst _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel