Skip to content

Commit a94cab2

Browse files
Andi KleenIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent b1bf72d commit a94cab2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

arch/x86/include/asm/tsc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern int unsynchronized_tsc(void);
5151
extern int check_tsc_unstable(void);
5252
extern int check_tsc_disabled(void);
5353
extern unsigned long native_calibrate_tsc(void);
54+
extern unsigned long long native_sched_clock_from_tsc(u64 tsc);
5455

5556
extern int tsc_clocksource_reliable;
5657

arch/x86/kernel/tsc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ u64 native_sched_clock(void)
296296
return cycles_2_ns(tsc_now);
297297
}
298298

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+
299307
/* We need to define a real function for sched_clock, to override the
300308
weak default version */
301309
#ifdef CONFIG_PARAVIRT

0 commit comments

Comments
 (0)