From: Yogesh Tillu <yogesh.tillu@linaro.org>
To: linux-arm-kernel@lists.infradead.org
Cc: tillu.yogesh@gmail.com, linux-perf-users@vger.kernel.org,
linaro-networking@linaro.org, jean.pihet@linaro.org,
arnd@linaro.org, Andrew.Pinski@caviumnetworks.com,
mike.holmes@linaro.org, ola.liljedahl@linaro.org,
magnus.karlsson@avagotech.com, Prasun.Kapoor@caviumnetworks.com,
Yogesh Tillu <yogesh.tillu@linaro.org>
Subject: [RFC PATCH 4/5]ARM64: Kernel: To read PMU cycle counter through vDSO Path
Date: Mon, 3 Nov 2014 20:34:04 +0530 [thread overview]
Message-ID: <1415027045-6573-5-git-send-email-yogesh.tillu@linaro.org> (raw)
In-Reply-To: <1415027045-6573-1-git-send-email-yogesh.tillu@linaro.org>
Kernel patchset to enable vDSO path for reading PMU cycle counter.
Signed-off-by: Yogesh Tillu <yogesh.tillu@linaro.org>
---
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
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
index 6d20b7d..4fde490 100644
--- a/arch/arm64/kernel/vdso/Makefile
+++ b/arch/arm64/kernel/vdso/Makefile
@@ -5,7 +5,7 @@
# Heavily based on the vDSO Makefiles for other archs.
#
-obj-vdso := gettimeofday.o note.o sigreturn.o
+obj-vdso := gettimeofday.o note.o sigreturn.o armpmu.o
# Build rules
targets := $(obj-vdso) vdso.so vdso.so.dbg
@@ -43,8 +43,8 @@ $(obj)/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
$(call if_changed,vdsosym)
# Assembly rules for the .S files
-$(obj-vdso): %.o: %.S
- $(call if_changed_dep,vdsoas)
+#$(obj-vdso): %.o: %.S
+# $(call if_changed_dep,vdsoas)
# Actual build commands
quiet_cmd_vdsold = VDSOL $@
diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
index 8154b8d..8cb56e0 100644
--- a/arch/arm64/kernel/vdso/vdso.lds.S
+++ b/arch/arm64/kernel/vdso/vdso.lds.S
@@ -90,6 +90,11 @@ VERSION
__kernel_gettimeofday;
__kernel_clock_gettime;
__kernel_clock_getres;
+ /* ADD YOUR VDSO STUFF HERE */
+ perf_read_counter;
+ __vdso_perf_read_counter;
+ perf_open_counter;
+ __vdso_perf_open_counter;
local: *;
};
}
diff --git a/arch/arm64/kernel/vdso/vdso_perfc.c b/arch/arm64/kernel/vdso/vdso_perfc.c
new file mode 100644
index 0000000..c363d64
--- /dev/null
+++ b/arch/arm64/kernel/vdso/vdso_perfc.c
@@ -0,0 +1,20 @@
+#include <linux/compiler.h>
+
+int perf_read_counter(void)
+ __attribute__((weak, alias("__vdso__perf_read_counter")));
+int perf_open_counter(void)
+ __attribute__((weak, alias("__vdso__perf_open_counter")));
+
+#define ARMV8_PMCNTENSET_EL0_ENABLE (1<<31) /**< Enable Perf count reg */
+
+__attribute__((no_instrument_function)) int __vdso__perf_read_counter(void)
+{
+int ret = 0;
+asm volatile("mrs %0, pmccntr_el0" : "=r" (ret));
+return ret;
+}
+
+__attribute__((no_instrument_function)) void __vdso__perf_open_counter(void)
+{
+asm volatile("msr pmcntenset_el0, %0" : : "r" (ARMV8_PMCNTENSET_EL0_ENABLE));
+}
--
1.7.9.5
next prev parent reply other threads:[~2014-11-03 15:08 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 ` Yogesh Tillu [this message]
2014-11-03 16:13 ` [RFC PATCH 4/5]ARM64: Kernel: To read PMU cycle counter through vDSO Path 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 ` [RFC] ARM64: Accessing perf counters from userspace Mark Rutland
2014-11-04 18:32 ` 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=1415027045-6573-5-git-send-email-yogesh.tillu@linaro.org \
--to=yogesh.tillu@linaro.org \
--cc=Andrew.Pinski@caviumnetworks.com \
--cc=Prasun.Kapoor@caviumnetworks.com \
--cc=arnd@linaro.org \
--cc=jean.pihet@linaro.org \
--cc=linaro-networking@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=magnus.karlsson@avagotech.com \
--cc=mike.holmes@linaro.org \
--cc=ola.liljedahl@linaro.org \
--cc=tillu.yogesh@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).