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=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 CC25EC47080 for ; Tue, 1 Jun 2021 12:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A769B6136E for ; Tue, 1 Jun 2021 12:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233911AbhFAM6w (ORCPT ); Tue, 1 Jun 2021 08:58:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:33684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233064AbhFAM6u (ORCPT ); Tue, 1 Jun 2021 08:58:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C02496139A; Tue, 1 Jun 2021 12:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622552229; bh=+tNYRrbJaNJpLw0qIAcircs1AmrNncomZDxq2GxZ4vQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mDJclJmxB+QtzHuW4UrMAQ/Uea/iCtbWGfJSbZzoAME42LQMRwSk88NvM8LJksv+N W1xaLgLNiMCy7yYI+ivzK3tIGOfR/ipjEtgXuvxnlm/YMdtmvzHoMPpM+f36nrL+N8 MMRI4ibGehWKZymtUWuwMdlrGXEJKfMCqyDKZyLw43YM9NAhIH8C5fCv4MKqD/qf8k nw8UVfH9A07Tb1aOV+A3VZP68PhmKAV72azIC+NcaS8537kwSlwPCd1rfJ8aya4UAJ 5P3aqjtyKWR4CV4sfN+B1+W8IdlmQykBllQUstBvPdu3cdNHW3j8Gc+vg33+0EmJ4m LdjXUDG11+Lvg== Date: Tue, 1 Jun 2021 13:57:03 +0100 From: Will Deacon To: Rob Herring Cc: Catalin Marinas , Peter Zijlstra , Ingo Molnar , Mark Rutland , Arnaldo Carvalho de Melo , Jiri Olsa , Kan Liang , Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Zachary.Leaf@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 4/5] arm64: perf: Add userspace counter access disable switch Message-ID: <20210601125703.GC28025@willie-the-truck> References: <20210517195405.3079458-1-robh@kernel.org> <20210517195405.3079458-5-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210517195405.3079458-5-robh@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rob, On Mon, May 17, 2021 at 02:54:04PM -0500, Rob Herring wrote: > Like x86, some users may want to disable userspace PMU counter > altogether. Add a sysfs 'rdpmc' file to control userspace counter > access. The default is '1' which is enabled. Writing '0' disables > access. > > In the case of multiple PMUs (i.e. big.LITTLE), the control is per PMU > and userspace must disable access on each PMU. > > Note that x86 also supports writing '2' to globally enable user access. > As there's not existing userspace support to worry about, this shouldn't > be necessary for Arm. It could be added later if the need arises. > > Signed-off-by: Rob Herring > --- > v8: > - Adjust due to patch 3 changes > v7: > - New patch > --- > arch/arm64/kernel/perf_event.c | 64 ++++++++++++++++++++++++++++++++-- > include/linux/perf/arm_pmu.h | 4 ++- > 2 files changed, 65 insertions(+), 3 deletions(-) I understand you've tried to follow the x86 behaviour here, but I think it might be better to implement this as a sysctl on arm64, with the default behaviour being that userspace access is _disabled_. Having the attribute per-PMU doesn't really make a lot of sense to me and we don't have any compatibility issues to worry about given that we've not exposed this to userspace yet. That should also be straightforward to implement (famous last words... yell if it isn't). Will 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=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 85172C4708F for ; Tue, 1 Jun 2021 12:58:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 47D7A6136E for ; Tue, 1 Jun 2021 12:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47D7A6136E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iLMPHd3fyAihcpDi0DZOBLbFjY1njFytUgKFJGITfaI=; b=Pk2A9ZekZte0Ec uhR81UJseIdtGXw+FirtYB7vDyPxeMPRAXvi5227GmIQuD3KsQ3QEqBV5soXZz6qB1hMqN1rMgDdw PKipDisl0374jfweqJ+0iZrzzvPyeGQR3MudjuPMIi4xO7DwBrIg88bHPPkE5kii+5n2kkLAL3/9o 1Txnd4C7hbPRccFSJzYuFmcX13YkrslWnpmG1oHHS6FDtCi1wVhrLOoTsSkBPv46sPfOtzqTVWYpR NwfVwOH1wYjw06+PloTDx2O6x5qgYkhd3pTXUc+UvPZHfepdOJYdg07uEwcAKrF4uocCXxOIS5ehZ MY/lvklV2gvSFCz8gN9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo3xK-00GdhJ-KM; Tue, 01 Jun 2021 12:57:14 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo3xF-00GdfR-U4 for linux-arm-kernel@lists.infradead.org; Tue, 01 Jun 2021 12:57:11 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C02496139A; Tue, 1 Jun 2021 12:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622552229; bh=+tNYRrbJaNJpLw0qIAcircs1AmrNncomZDxq2GxZ4vQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mDJclJmxB+QtzHuW4UrMAQ/Uea/iCtbWGfJSbZzoAME42LQMRwSk88NvM8LJksv+N W1xaLgLNiMCy7yYI+ivzK3tIGOfR/ipjEtgXuvxnlm/YMdtmvzHoMPpM+f36nrL+N8 MMRI4ibGehWKZymtUWuwMdlrGXEJKfMCqyDKZyLw43YM9NAhIH8C5fCv4MKqD/qf8k nw8UVfH9A07Tb1aOV+A3VZP68PhmKAV72azIC+NcaS8537kwSlwPCd1rfJ8aya4UAJ 5P3aqjtyKWR4CV4sfN+B1+W8IdlmQykBllQUstBvPdu3cdNHW3j8Gc+vg33+0EmJ4m LdjXUDG11+Lvg== Date: Tue, 1 Jun 2021 13:57:03 +0100 From: Will Deacon To: Rob Herring Cc: Catalin Marinas , Peter Zijlstra , Ingo Molnar , Mark Rutland , Arnaldo Carvalho de Melo , Jiri Olsa , Kan Liang , Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Zachary.Leaf@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 4/5] arm64: perf: Add userspace counter access disable switch Message-ID: <20210601125703.GC28025@willie-the-truck> References: <20210517195405.3079458-1-robh@kernel.org> <20210517195405.3079458-5-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210517195405.3079458-5-robh@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_055710_050366_D9C70F38 X-CRM114-Status: GOOD ( 19.38 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Rob, On Mon, May 17, 2021 at 02:54:04PM -0500, Rob Herring wrote: > Like x86, some users may want to disable userspace PMU counter > altogether. Add a sysfs 'rdpmc' file to control userspace counter > access. The default is '1' which is enabled. Writing '0' disables > access. > > In the case of multiple PMUs (i.e. big.LITTLE), the control is per PMU > and userspace must disable access on each PMU. > > Note that x86 also supports writing '2' to globally enable user access. > As there's not existing userspace support to worry about, this shouldn't > be necessary for Arm. It could be added later if the need arises. > > Signed-off-by: Rob Herring > --- > v8: > - Adjust due to patch 3 changes > v7: > - New patch > --- > arch/arm64/kernel/perf_event.c | 64 ++++++++++++++++++++++++++++++++-- > include/linux/perf/arm_pmu.h | 4 ++- > 2 files changed, 65 insertions(+), 3 deletions(-) I understand you've tried to follow the x86 behaviour here, but I think it might be better to implement this as a sysctl on arm64, with the default behaviour being that userspace access is _disabled_. Having the attribute per-PMU doesn't really make a lot of sense to me and we don't have any compatibility issues to worry about given that we've not exposed this to userspace yet. That should also be straightforward to implement (famous last words... yell if it isn't). Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel