aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2011-11-21 05:43:53 -0500
committerIngo Molnar <mingo@elte.hu>2011-12-21 05:01:13 -0500
commite3f3541c19c89a4daae39300defba68943301949 (patch)
treef3d6fe5c39dfee8045e7955e5637ae9ff9c0d4d5 /arch/x86/kernel/cpu
parent0c9d42ed4cee2aa1dfc3a260b741baae8615744f (diff)
perf: Extend the mmap control page with time (TSC) fields
Extend the mmap control page with fields so that userspace can compute time deltas relative to the provided time fields. Currently only implemented for x86 with constant and nonstop TSC. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Cc: Arun Sharma <asharma@fb.com> Link: http://lkml.kernel.org/n/tip-3u1jucza77j3wuvs0x2bic0f@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu')
-rw-r--r--arch/x86/kernel/cpu/perf_event.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 116b040a73a8..f8bddb5b0600 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -32,6 +32,7 @@
32#include <asm/compat.h> 32#include <asm/compat.h>
33#include <asm/smp.h> 33#include <asm/smp.h>
34#include <asm/alternative.h> 34#include <asm/alternative.h>
35#include <asm/timer.h>
35 36
36#include "perf_event.h" 37#include "perf_event.h"
37 38
@@ -1627,6 +1628,19 @@ static struct pmu pmu = {
1627 .event_idx = x86_pmu_event_idx, 1628 .event_idx = x86_pmu_event_idx,
1628}; 1629};
1629 1630
1631void perf_update_user_clock(struct perf_event_mmap_page *userpg, u64 now)
1632{
1633 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
1634 return;
1635
1636 if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
1637 return;
1638
1639 userpg->time_mult = this_cpu_read(cyc2ns);
1640 userpg->time_shift = CYC2NS_SCALE_FACTOR;
1641 userpg->time_offset = this_cpu_read(cyc2ns_offset) - now;
1642}
1643
1630/* 1644/*
1631 * callchain support 1645 * callchain support
1632 */ 1646 */