aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-02-26 15:21:59 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-26 15:21:59 -0500
commit5d0859cef29167d45dc6cf89d19712145e6005d6 (patch)
tree1fe3be14cc773f4df5606a9993930cc43889a169 /kernel
parent14131f2f98ac350ee9e73faed916d2238a8b6a0d (diff)
parent83ce400928680a6c8123d492684b27857f5a2d95 (diff)
Merge branch 'sched/clock' into tracing/ftrace
Conflicts: kernel/sched_clock.c
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched_clock.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index db69174b1178..f7602da84c40 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -24,12 +24,12 @@
24 * The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat 24 * The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat
25 * consistent between cpus (never more than 2 jiffies difference). 25 * consistent between cpus (never more than 2 jiffies difference).
26 */ 26 */
27#include <linux/sched.h>
28#include <linux/percpu.h>
29#include <linux/spinlock.h> 27#include <linux/spinlock.h>
30#include <linux/ktime.h>
31#include <linux/module.h>
32#include <linux/hardirq.h> 28#include <linux/hardirq.h>
29#include <linux/module.h>
30#include <linux/percpu.h>
31#include <linux/ktime.h>
32#include <linux/sched.h>
33 33
34/* 34/*
35 * Scheduler clock - returns current time in nanosec units. 35 * Scheduler clock - returns current time in nanosec units.
@@ -44,6 +44,10 @@ unsigned long long __attribute__((weak)) sched_clock(void)
44static __read_mostly int sched_clock_running; 44static __read_mostly int sched_clock_running;
45 45
46#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK 46#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
47__read_mostly int sched_clock_stable;
48#else
49static const int sched_clock_stable = 1;
50#endif
47 51
48struct sched_clock_data { 52struct sched_clock_data {
49 /* 53 /*
@@ -88,7 +92,7 @@ void sched_clock_init(void)
88} 92}
89 93
90/* 94/*
91 * min,max except they take wrapping into account 95 * min, max except they take wrapping into account
92 */ 96 */
93 97
94static inline u64 wrap_min(u64 x, u64 y) 98static inline u64 wrap_min(u64 x, u64 y)
@@ -117,10 +121,13 @@ static u64 __update_sched_clock(struct sched_clock_data *scd, u64 now)
117 if (unlikely(delta < 0)) 121 if (unlikely(delta < 0))
118 delta = 0; 122 delta = 0;
119 123
124 if (unlikely(!sched_clock_running))
125 return 0ull;
126
120 /* 127 /*
121 * scd->clock = clamp(scd->tick_gtod + delta, 128 * scd->clock = clamp(scd->tick_gtod + delta,
122 * max(scd->tick_gtod, scd->clock), 129 * max(scd->tick_gtod, scd->clock),
123 * scd->tick_gtod + TICK_NSEC); 130 * scd->tick_gtod + TICK_NSEC);
124 */ 131 */
125 132
126 clock = scd->tick_gtod + delta; 133 clock = scd->tick_gtod + delta;
@@ -149,8 +156,11 @@ static void lock_double_clock(struct sched_clock_data *data1,
149 156
150u64 sched_clock_cpu(int cpu) 157u64 sched_clock_cpu(int cpu)
151{ 158{
152 struct sched_clock_data *scd = cpu_sdc(cpu);
153 u64 now, clock, this_clock, remote_clock; 159 u64 now, clock, this_clock, remote_clock;
160 struct sched_clock_data *scd;
161
162 if (sched_clock_stable)
163 return sched_clock();
154 164
155 /* 165 /*
156 * Normally this is not called in NMI context - but if it is, 166 * Normally this is not called in NMI context - but if it is,
@@ -162,6 +172,7 @@ u64 sched_clock_cpu(int cpu)
162 if (unlikely(!sched_clock_running)) 172 if (unlikely(!sched_clock_running))
163 return 0ull; 173 return 0ull;
164 174
175 scd = cpu_sdc(cpu);
165 WARN_ON_ONCE(!irqs_disabled()); 176 WARN_ON_ONCE(!irqs_disabled());
166 now = sched_clock(); 177 now = sched_clock();
167 178
@@ -201,6 +212,8 @@ u64 sched_clock_cpu(int cpu)
201 return clock; 212 return clock;
202} 213}
203 214
215#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
216
204void sched_clock_tick(void) 217void sched_clock_tick(void)
205{ 218{
206 struct sched_clock_data *scd = this_scd(); 219 struct sched_clock_data *scd = this_scd();
@@ -243,22 +256,7 @@ void sched_clock_idle_wakeup_event(u64 delta_ns)
243} 256}
244EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); 257EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
245 258
246#else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */ 259#endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
247
248void sched_clock_init(void)
249{
250 sched_clock_running = 1;
251}
252
253u64 sched_clock_cpu(int cpu)
254{
255 if (unlikely(!sched_clock_running))
256 return 0;
257
258 return sched_clock();
259}
260
261#endif
262 260
263unsigned long long cpu_clock(int cpu) 261unsigned long long cpu_clock(int cpu)
264{ 262{