From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] ARM64: Accessing perf counters from userspace
Date: Mon, 3 Nov 2014 15:40:06 +0000 [thread overview]
Message-ID: <20141103154006.GJ29621@leverpostej> (raw)
In-Reply-To: <1415027045-6573-1-git-send-email-yogesh.tillu@linaro.org>
Hi,
On Mon, Nov 03, 2014 at 03:04:00PM +0000, Yogesh Tillu wrote:
> We have tried to implement some changes to allow perf counters to be accessed
> from user space. Benchmarking so far has show that these are 100s of times
> faster than using syscall(perf_event_open). This would be useful for many use
> cases like networking(critical to fast path code), benchmark executionpath with
> low budget of cpu cycles etc.
>
> Benchmark figures on ArmV8, "reading perf cycle counter" with below approaches
> 1) Reading perf cycle counter through perf_event_open syscall
> Result[cpu cycles]: 2000 (For Armv7[Arndale] 5407)
> 2) Direct access of perf counters from userspace through asm
> Result[cpu cycles]: 2 (For Armv7[Arndale] 16)
> 3) Reading perf cycle counter through vDSO path
> Result[cpu cycles]: ~20
>
>
> Could you please let me know your comments/review. Below are the details about
> setup and patchset.
For there to be any meaningful review of this, it needs to be based on a
kernel tree, and implemented within the existing perf framework; it
cannot be a module on the side. This is impossible to review, because it
looks nothing like what a real solution will have to.
Please base this on a kernel tree, and integrate with the existing
frameworks.
It would also be helpful if you could describe a use case for which the
current mechanisms are too expensive. It will certainly be cheaper to
read the registers directly, but there is additional work userspace will
need to do in addition to simply reading the registers. That can impact
the use-case.
It's unclear to me why you cannot amortize the cost of the reads over a
number of iterations. A specific (non-trivial) example would help.
Thanks,
Mark.
>
> ** Setup details **
> Architecture: ArmV8
> Board : Juno Board
> Linux kernel: 3.16.0+
> Kernel Repo : git://git.linaro.org/kernel/linux-linaro-tracking.git
> (Branch:linux-linaro)
> Rootfs : Linaro Ubuntu rootfs
> Toolchain : gcc version 4.9.1 20140529 (prerelease)
> (crosstool-NG linaro-1.13.1-4.9-2014.06-02 - Linaro GCC 4.9-2014.06)
>
> 1) Reading perf cycle counter through perf_event_open syscall
> *Application to read counter using perf_event_open syscall.
> [PATCH] Application reads perf cycle counter using perf_event_open
> syscall, and prints Benchmark results.
>
> Signed-off-by: Yogesh Tillu <yogesh.tillu@linaro.org>
> ---
> app_readcounter.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 83 insertions(+)
> create mode 100644 app_readcounter.c
>
>
> 2) Direct access of perf counters from userspace using asm
> This setup contains kernel module + header file with implemented asm to access
> perf counters + Application uses api provided in header file to access counter.
>
> * Kernel Module: To enable access of counters from userspace
> Yogesh Tillu (1):
> Kernel module to Enable userspace access to PMU counters for
> ArmV8
>
> ARMv8_Module/Makefile | 8 ++++
> ARMv8_Module/README | 1 +
> ARMv8_Module/enable_arm_pmu.c | 96 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 105 insertions(+)
> create mode 100644 ARMv8_Module/Makefile
> create mode 100644 ARMv8_Module/README
> create mode 100644 ARMv8_Module/enable_arm_pmu.c
>
> * Application:
> [PATCH] Added test for Direct access of perf counter from userspace
> using asm.
>
> Signed-off-by: Yogesh Tillu <yogesh.tillu@linaro.org>
> ---
> README.directaccess | 8 ++++
> direct_access.c | 65 ++++++++++++++++++++++++++++
> direct_access.h | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 190 insertions(+)
> create mode 100644 README.directaccess
> create mode 100644 direct_access.c
> create mode 100644 direct_access.h
>
> 3) Reading perf cycle counter through vDSO path
> * Kernel Module: To enable access of counters from userspace ( Same as setup (2) )
> * Kernel vDSO implementation: vDSO implementation for reading of perf cycle counter
> [PATCH] provide open/read function through vDSO for PMU counters
> Yogesh Tillu (1):
> To read PMU cycle counter through vDSO Path
>
> arch/arm64/kernel/vdso/Makefile | 6 +++---
> arch/arm64/kernel/vdso/vdso.lds.S | 5 +++++
> arch/arm64/kernel/vdso/vdso_perfc.c | 20 ++++++++++++++++++++
> 3 files changed, 28 insertions(+), 3 deletions(-)
> create mode 100644 arch/arm64/kernel/vdso/vdso_perfc.c
>
> * application : To read perf counter through api(implemented through vDSO)
> [PATCH] Test Application: access PMU counter through vDSO
> Yogesh Tillu (1):
> Test application to read PMU counter through vdso
>
> vdso_userspace_perf.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
> create mode 100644 vdso_userspace_perf.c
>
> NOTE: This codebase mainly for POC of "Access perf counters from userspace",
> not much concentration towards api standard forms.
>
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
next prev parent reply other threads:[~2014-11-03 15:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-03 15:04 [RFC] ARM64: Accessing perf counters from userspace Yogesh Tillu
2014-11-03 15:04 ` [RFC PATCH 1/5] Application: reads perf cycle counter using perf_event_open syscall Yogesh Tillu
2014-11-03 15:04 ` [RFC PATCH 2/5] Kernel module: to Enable userspace access to PMU counters for ArmV8 Yogesh Tillu
2014-11-03 15:22 ` Måns Rullgård
2014-11-03 16:16 ` Mark Rutland
2014-11-03 15:04 ` [RFC PATCH 3/5] Application: Added test for Direct access of perf counter from userspace using asm Yogesh Tillu
2014-11-03 15:04 ` [RFC PATCH 4/5]ARM64: Kernel: To read PMU cycle counter through vDSO Path Yogesh Tillu
2014-11-03 16:13 ` Mark Rutland
2014-11-03 15:04 ` [RFC PATCH 5/5] Application: to read PMU counter through vdso Yogesh Tillu
2014-11-03 15:40 ` Mark Rutland [this message]
2014-11-04 18:32 ` [RFC] ARM64: Accessing perf counters from userspace Yogesh Tillu
[not found] ` <CAPiYAf4ZbEP20AEaEyaDJ9ov-w-F-UNDu9OmurL_3YQx+9p5bA@mail.gmail.com>
2014-11-05 17:39 ` Mark Rutland
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=20141103154006.GJ29621@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.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