Re: [PATCH v8 4/5] arm64: perf: Add userspace counter access disable switch
From: Will Deacon
Date: Tue Jun 01 2021 - 08:57:15 EST
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 <robh@xxxxxxxxxx>
> ---
> 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