|
@@ -53,6 +53,7 @@
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
#include "sched.h"
|
|
#include "sched.h"
|
|
|
|
+#include <linux/sched_clock.h>
|
|
|
|
|
|
/*
|
|
/*
|
|
* Scheduler clock - returns current time in nanosec units.
|
|
* Scheduler clock - returns current time in nanosec units.
|
|
@@ -68,11 +69,6 @@ EXPORT_SYMBOL_GPL(sched_clock);
|
|
|
|
|
|
__read_mostly int sched_clock_running;
|
|
__read_mostly int sched_clock_running;
|
|
|
|
|
|
-void sched_clock_init(void)
|
|
|
|
-{
|
|
|
|
- sched_clock_running = 1;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
|
|
#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
|
|
/*
|
|
/*
|
|
* We must start with !__sched_clock_stable because the unstable -> stable
|
|
* We must start with !__sched_clock_stable because the unstable -> stable
|
|
@@ -199,6 +195,15 @@ void clear_sched_clock_stable(void)
|
|
__clear_sched_clock_stable();
|
|
__clear_sched_clock_stable();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void __sched_clock_gtod_offset(void)
|
|
|
|
+{
|
|
|
|
+ __gtod_offset = (sched_clock() + __sched_clock_offset) - ktime_get_ns();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void __init sched_clock_init(void)
|
|
|
|
+{
|
|
|
|
+ sched_clock_running = 1;
|
|
|
|
+}
|
|
/*
|
|
/*
|
|
* We run this as late_initcall() such that it runs after all built-in drivers,
|
|
* We run this as late_initcall() such that it runs after all built-in drivers,
|
|
* notably: acpi_processor and intel_idle, which can mark the TSC as unstable.
|
|
* notably: acpi_processor and intel_idle, which can mark the TSC as unstable.
|
|
@@ -385,8 +390,6 @@ void sched_clock_tick(void)
|
|
|
|
|
|
void sched_clock_tick_stable(void)
|
|
void sched_clock_tick_stable(void)
|
|
{
|
|
{
|
|
- u64 gtod, clock;
|
|
|
|
-
|
|
|
|
if (!sched_clock_stable())
|
|
if (!sched_clock_stable())
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -398,9 +401,7 @@ void sched_clock_tick_stable(void)
|
|
* TSC to be unstable, any computation will be computing crap.
|
|
* TSC to be unstable, any computation will be computing crap.
|
|
*/
|
|
*/
|
|
local_irq_disable();
|
|
local_irq_disable();
|
|
- gtod = ktime_get_ns();
|
|
|
|
- clock = sched_clock();
|
|
|
|
- __gtod_offset = (clock + __sched_clock_offset) - gtod;
|
|
|
|
|
|
+ __sched_clock_gtod_offset();
|
|
local_irq_enable();
|
|
local_irq_enable();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -434,6 +435,12 @@ EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
|
|
|
|
|
|
#else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
|
|
#else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
|
|
|
|
|
|
|
|
+void __init sched_clock_init(void)
|
|
|
|
+{
|
|
|
|
+ sched_clock_running = 1;
|
|
|
|
+ generic_sched_clock_init();
|
|
|
|
+}
|
|
|
|
+
|
|
u64 sched_clock_cpu(int cpu)
|
|
u64 sched_clock_cpu(int cpu)
|
|
{
|
|
{
|
|
if (unlikely(!sched_clock_running))
|
|
if (unlikely(!sched_clock_running))
|