Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf/x86: Add a native_perf_sched_clock_from_tsc()

PEBSv3 has a raw TSC time stamp in its memory buffer that
later needs to to be converted to perf_clock.

Add a native_sched_clock_from_tsc() that works the same
as native_sched_clock(), but starts with an already given
TSC value.

Paravirt is ignored, it will just get the native clock.
But there isn't a para virtualized PEBS anyway.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: eranian@google.com
Link: http://lkml.kernel.org/r/1431285767-27027-2-git-send-email-andi@firstfloor.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andi Kleen and committed by
Ingo Molnar
a94cab23 b1bf72d6

+9
+1
arch/x86/include/asm/tsc.h
··· 51 51 extern int check_tsc_unstable(void); 52 52 extern int check_tsc_disabled(void); 53 53 extern unsigned long native_calibrate_tsc(void); 54 + extern unsigned long long native_sched_clock_from_tsc(u64 tsc); 54 55 55 56 extern int tsc_clocksource_reliable; 56 57
+8
arch/x86/kernel/tsc.c
··· 296 296 return cycles_2_ns(tsc_now); 297 297 } 298 298 299 + /* 300 + * Generate a sched_clock if you already have a TSC value. 301 + */ 302 + u64 native_sched_clock_from_tsc(u64 tsc) 303 + { 304 + return cycles_2_ns(tsc); 305 + } 306 + 299 307 /* We need to define a real function for sched_clock, to override the 300 308 weak default version */ 301 309 #ifdef CONFIG_PARAVIRT