aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched_clock.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-07-07 14:16:52 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-11 09:53:26 -0400
commitaf52a90a14cdaa54ecbfb6e6982abb13466a4b56 (patch)
tree2488d6d7943b167987c33f984f7109c3dc4ae783 /kernel/sched_clock.c
parentf7cce27f5605b9e137b829a47949cb2d3c7e1cab (diff)
sched_clock: stop maximum check on NO HZ
Working with ftrace I would get large jumps of 11 millisecs or more with the clock tracer. This killed the latencing timings of ftrace and also caused the irqoff self tests to fail. What was happening is with NO_HZ the idle would stop the jiffy counter and before the jiffy counter was updated the sched_clock would have a bad delta jiffies to compare with the gtod with the maximum. The jiffies would stop and the last sched_tick would record the last gtod. On wakeup, the sched clock update would compare the gtod + delta jiffies (which would be zero) and compare it to the TSC. The TSC would have correctly (with a stable TSC) moved forward several jiffies. But because the jiffies has not been updated yet the clock would be prevented from moving forward because it would appear that the TSC jumped too far ahead. The clock would then virtually stop, until the jiffies are updated. Then the next sched clock update would see that the clock was very much behind since the delta jiffies is now correct. This would then jump the clock forward by several jiffies. This caused ftrace to report several milliseconds of interrupts off latency at every resume from NO_HZ idle. This patch adds hooks into the nohz code to disable the checking of the maximum clock update when nohz is in effect. It resumes the max check when nohz has updated the jiffies again. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Cc: Steven Rostedt <srostedt@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched_clock.c')
-rw-r--r--kernel/sched_clock.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index 42b81fa38cbd..97159e225a77 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -45,6 +45,9 @@ struct sched_clock_data {
45 u64 tick_raw; 45 u64 tick_raw;
46 u64 tick_gtod; 46 u64 tick_gtod;
47 u64 clock; 47 u64 clock;
48#ifdef CONFIG_NO_HZ
49 int check_max;
50#endif
48}; 51};
49 52
50static DEFINE_PER_CPU_SHARED_ALIGNED(struct sched_clock_data, sched_clock_data); 53static DEFINE_PER_CPU_SHARED_ALIGNED(struct sched_clock_data, sched_clock_data);
@@ -76,11 +79,45 @@ void sched_clock_init(void)
76 scd->tick_raw = 0; 79 scd->tick_raw = 0;
77 scd->tick_gtod = ktime_now; 80 scd->tick_gtod = ktime_now;
78 scd->clock = ktime_now; 81 scd->clock = ktime_now;
82#ifdef CONFIG_NO_HZ
83 scd->check_max = 1;
84#endif
79 } 85 }
80 86
81 sched_clock_running = 1; 87 sched_clock_running = 1;
82} 88}
83 89
90#ifdef CONFIG_NO_HZ
91/*
92 * The dynamic ticks makes the delta jiffies inaccurate. This
93 * prevents us from checking the maximum time update.
94 * Disable the maximum check during stopped ticks.
95 */
96void sched_clock_tick_stop(int cpu)
97{
98 struct sched_clock_data *scd = cpu_sdc(cpu);
99
100 scd->check_max = 0;
101}
102
103void sched_clock_tick_start(int cpu)
104{
105 struct sched_clock_data *scd = cpu_sdc(cpu);
106
107 scd->check_max = 1;
108}
109
110static int check_max(struct sched_clock_data *scd)
111{
112 return scd->check_max;
113}
114#else
115static int check_max(struct sched_clock_data *scd)
116{
117 return 1;
118}
119#endif /* CONFIG_NO_HZ */
120
84/* 121/*
85 * update the percpu scd from the raw @now value 122 * update the percpu scd from the raw @now value
86 * 123 *
@@ -112,7 +149,7 @@ static void __update_sched_clock(struct sched_clock_data *scd, u64 now)
112 */ 149 */
113 max_clock = scd->tick_gtod + (2 + delta_jiffies) * TICK_NSEC; 150 max_clock = scd->tick_gtod + (2 + delta_jiffies) * TICK_NSEC;
114 151
115 if (unlikely(clock + delta > max_clock)) { 152 if (unlikely(clock + delta > max_clock) && check_max(scd)) {
116 if (clock < max_clock) 153 if (clock < max_clock)
117 clock = max_clock; 154 clock = max_clock;
118 else 155 else