arm64: Enable access to pmu registers by user-space
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest7 patches 3 repliesIn review
- v35 patches 7 repliesSuperseded
- v2 posting 2/25 patches 3 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 RFC posting 1/2 | 7 patches | 9 replies | Superseded | |
| v1 RFC | 6 patches | 6 replies | Superseded |
Changes in v4 from the cover letter
* Rebased on will/for-next/perf in order to include this patch [1]
* Re-introduce mrs hook used in previous versions
* Invert cpu feature to track homogeneity instead of heterogeneity
* Introduce accessor for boot_cpu_data (see second commit for more info)
* Apply Mark Rutland's comments
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | perf: arm64: Add test to check userspace access to hardware counters.tools/ tools/ tools/ +1 more | +266 | 2 replies | |
| 2/7 | arm64: cpu: Add accessor for boot_cpu_dataarch/ arch/ | +7 | 0 replies | |
| 3/7 | arm64: cpufeature: Add feature to detect homogeneous systemsarch/ arch/ arch/ | +40 | 0 replies | |
| 4/7 | arm64: pmu: Add hook to handle pmu-related undefined instructionsarch/ arch/ | +57 | 0 replies | |
| 5/7 | arm64: pmu: Add function implementation to update event index in userpage.arch/ include/ | +23 | 0 replies | |
| 6/7 | arm64: perf: Enable pmu counter direct access for perf event on armv8arch/ arch/ arch/ +2 more | +77 | 1 reply | |
| 7/7 | Documentation: arm64: Document PMU counters access from userspaceDocumentation/ | +42 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/7] arm64: Enable access to pmu registers by user-space
Hi,
Changes since v3:
* Rebased on will/for-next/perf in order to include this patch [1]
* Re-introduce mrs hook used in previous versions
* Invert cpu feature to track homogeneity instead of heterogeneity
* Introduce accessor for boot_cpu_data (see second commit for more info)
* Apply Mark Rutland's comments
The perf user-space tool relies on the PMU to monitor events. It offers an abstraction layer over the hardware counters since the underlying implementation is cpu-dependent. We want to allow userspace tools to have access to the registers storing the hardware counters' values directly. This targets specifically self-monitoring tasks in order to reduce the overhead by directly accessing the registers without having to go through the kernel.
In order to do this we need to setup the pmu so that it exposes its registers to userspace access.
The first patch add a test to the perf tool so that we can test that the access to the registers works correctly from userspace.
The second patch introduces an accessor for boot_cpu_data which is static. Including cpu.h turned out to cause a chain of dependencies so I opted for the accessor since it is not much used.
The third patch add a capability in the arm64 cpufeatures framework in order to detect when we are running on a homogeneous system.
The fourth patch re introduces the hooks to handling undefined instruction for mrs instructions on pmu-related registers.
The fifth patch focuses on the armv8 pmuv3 PMU support and makes sure that the access to the pmu registers is enable and that the userspace have access to the relevent information in order to use them.
The sixth patch put in place callbacks to enable access to the hardware counters from userspace when a compatible event is opened using the perf API.
The seventh patch adds a short documentation about PMU counters direct access from userspace.
[1]: https://lkml.org/lkml/2019/8/20/875
Raphael Gault (7):
perf: arm64: Add test to check userspace access to hardware counters.
arm64: cpu: Add accessor for boot_cpu_data
arm64: cpufeature: Add feature to detect homogeneous systems
arm64: pmu: Add hook to handle pmu-related undefined instructions
arm64: pmu: Add function implementation to update event index in
userpage.
arm64: perf: Enable pmu counter direct access for perf event on armv8
Documentation: arm64: Document PMU counters access from userspace
.../arm64/pmu_counter_user_access.txt | 42 +++ arch/arm64/include/asm/cpu.h | 2 +- arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/cpufeature.h | 10 + arch/arm64/include/asm/mmu.h | 6 + arch/arm64/include/asm/mmu_context.h | 2 + arch/arm64/include/asm/perf_event.h | 14 + arch/arm64/kernel/cpufeature.c | 32 ++- arch/arm64/kernel/cpuinfo.c | 7 +- arch/arm64/kernel/perf_event.c | 77 ++++++ drivers/perf/arm_pmu.c | 54 ++++ include/linux/perf/arm_pmu.h | 2 + tools/perf/arch/arm64/include/arch-tests.h | 7 + tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 + tools/perf/arch/arm64/tests/user-events.c | 254 ++++++++++++++++++ 16 files changed, 512 insertions(+), 5 deletions(-) create mode 100644 Documentation/arm64/pmu_counter_user_access.txt create mode 100644 tools/perf/arch/arm64/tests/user-events.c
Signature · 1 line
2.17.1