From: Will Deacon <will@kernel.org>
To: James Clark <james.clark@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org, peterz@infradead.org,
Al Grant <al.grant@arm.com>, Mark Rutland <mark.rutland@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2] drivers/perf: arm_spe: Use perf_allow_kernel() for permissions
Date: Fri, 16 Aug 2024 13:45:00 +0100 [thread overview]
Message-ID: <20240816124459.GA24323@willie-the-truck> (raw)
In-Reply-To: <20240807155153.2714025-1-james.clark@linaro.org>
On Wed, Aug 07, 2024 at 04:51:53PM +0100, James Clark wrote:
> For other PMUs, PERF_SAMPLE_PHYS_ADDR requires perf_allow_kernel()
> rather than just perfmon_capable(). Because PMSCR_EL1_PA is another form
> of physical address, make it consistent and use perf_allow_kernel() for
> SPE as well. PMSCR_EL1_PCT and PMSCR_EL1_CX also get the same change.
>
> This improves consistency and indirectly fixes the following error
> message which is misleading because perf_event_paranoid is not taken
> into account by perfmon_capable():
>
> $ perf record -e arm_spe/pa_enable/
>
> Error:
> Access to performance monitoring and observability operations is
> limited. Consider adjusting /proc/sys/kernel/perf_event_paranoid
> setting ...
>
> Suggested-by: Al Grant <al.grant@arm.com>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
> Changes since v1:
>
> * Export perf_allow_kernel() instead of sysctl_perf_event_paranoid
>
> drivers/perf/arm_spe_pmu.c | 9 ++++-----
> include/linux/perf_event.h | 8 +-------
> kernel/events/core.c | 9 +++++++++
> 3 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
> index 9100d82bfabc..3569050f9cf3 100644
> --- a/drivers/perf/arm_spe_pmu.c
> +++ b/drivers/perf/arm_spe_pmu.c
> @@ -41,7 +41,7 @@
>
> /*
> * Cache if the event is allowed to trace Context information.
> - * This allows us to perform the check, i.e, perfmon_capable(),
> + * This allows us to perform the check, i.e, perf_allow_kernel(),
> * in the context of the event owner, once, during the event_init().
> */
> #define SPE_PMU_HW_FLAGS_CX 0x00001
> @@ -50,7 +50,7 @@ static_assert((PERF_EVENT_FLAG_ARCH & SPE_PMU_HW_FLAGS_CX) == SPE_PMU_HW_FLAGS_C
>
> static void set_spe_event_has_cx(struct perf_event *event)
> {
> - if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && perfmon_capable())
> + if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && !perf_allow_kernel(&event->attr))
> event->hw.flags |= SPE_PMU_HW_FLAGS_CX;
The rationale for this change in the commit message is because other
drivers gate PERF_SAMPLE_PHYS_ADDR on perf_allow_kernel(). However,
putting the PID in contextidr doesn't seem to have anything to do with
that...
> }
>
> @@ -745,9 +745,8 @@ static int arm_spe_pmu_event_init(struct perf_event *event)
>
> set_spe_event_has_cx(event);
> reg = arm_spe_event_to_pmscr(event);
> - if (!perfmon_capable() &&
> - (reg & (PMSCR_EL1_PA | PMSCR_EL1_PCT)))
> - return -EACCES;
> + if (reg & (PMSCR_EL1_PA | PMSCR_EL1_PCT))
Similarly here. What does the physical counter have to do with physical
address sampling other than sharing the word "physical"?
Will
next prev parent reply other threads:[~2024-08-16 12:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 15:51 [PATCH v2] drivers/perf: arm_spe: Use perf_allow_kernel() for permissions James Clark
2024-08-16 12:45 ` Will Deacon [this message]
2024-08-16 13:27 ` James Clark
2024-08-23 15:02 ` Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240816124459.GA24323@willie-the-truck \
--to=will@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=al.grant@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox