|
@@ -84,7 +84,7 @@ static inline int check_tsc_unstable(void)
|
|
|
*
|
|
|
* -johnstul@us.ibm.com "math is hard, lets go shopping!"
|
|
|
*/
|
|
|
-static unsigned long cyc2ns_scale __read_mostly;
|
|
|
+unsigned long cyc2ns_scale __read_mostly;
|
|
|
|
|
|
#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
|
|
|
|
|
@@ -93,15 +93,10 @@ static inline void set_cyc2ns_scale(unsigned long cpu_khz)
|
|
|
cyc2ns_scale = (1000000 << CYC2NS_SCALE_FACTOR)/cpu_khz;
|
|
|
}
|
|
|
|
|
|
-static inline unsigned long long cycles_2_ns(unsigned long long cyc)
|
|
|
-{
|
|
|
- return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
* Scheduler clock - returns current time in nanosec units.
|
|
|
*/
|
|
|
-unsigned long long sched_clock(void)
|
|
|
+unsigned long long native_sched_clock(void)
|
|
|
{
|
|
|
unsigned long long this_offset;
|
|
|
|
|
@@ -118,12 +113,24 @@ unsigned long long sched_clock(void)
|
|
|
return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ);
|
|
|
|
|
|
/* read the Time Stamp Counter: */
|
|
|
- get_scheduled_cycles(this_offset);
|
|
|
+ rdtscll(this_offset);
|
|
|
|
|
|
/* return the value in ns */
|
|
|
return cycles_2_ns(this_offset);
|
|
|
}
|
|
|
|
|
|
+/* We need to define a real function for sched_clock, to override the
|
|
|
+ weak default version */
|
|
|
+#ifdef CONFIG_PARAVIRT
|
|
|
+unsigned long long sched_clock(void)
|
|
|
+{
|
|
|
+ return paravirt_sched_clock();
|
|
|
+}
|
|
|
+#else
|
|
|
+unsigned long long sched_clock(void)
|
|
|
+ __attribute__((alias("native_sched_clock")));
|
|
|
+#endif
|
|
|
+
|
|
|
unsigned long native_calculate_cpu_khz(void)
|
|
|
{
|
|
|
unsigned long long start, end;
|