diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:05:03 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 18:01:49 -0400 |
commit | 2044fdb03eb4e511d5028be0917899931f17461f (patch) | |
tree | 69e1a9a8f27e1242f83c5a4569af39794f040e54 | |
parent | 61edec81d260bc96a73c878bbdb4c614460346da (diff) |
hangcheck-timer: Use ktime_get_ns()
There is no point in having a S390 private implementation and there is
no point in using the raw monotonic time. The NTP freqeuency
adjustment of CLOCK_MONOTONIC is really not doing any harm for the
hang check timer.
Use ktime_get_ns() for everything and get rid of the timespec
conversions.
V2: Drop the raw monotonic and the S390 special case
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | drivers/char/hangcheck-timer.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index f953c96efc86..ebc4c73d8ca4 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
50 | #include <linux/sysrq.h> | 50 | #include <linux/sysrq.h> |
51 | #include <linux/timer.h> | 51 | #include <linux/timer.h> |
52 | #include <linux/time.h> | 52 | #include <linux/hrtimer.h> |
53 | 53 | ||
54 | #define VERSION_STR "0.9.1" | 54 | #define VERSION_STR "0.9.1" |
55 | 55 | ||
@@ -117,24 +117,7 @@ __setup("hcheck_reboot", hangcheck_parse_reboot); | |||
117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); | 117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); |
118 | #endif /* not MODULE */ | 118 | #endif /* not MODULE */ |
119 | 119 | ||
120 | #if defined(CONFIG_S390) | 120 | #define TIMER_FREQ 1000000000ULL |
121 | # define HAVE_MONOTONIC | ||
122 | # define TIMER_FREQ 1000000000ULL | ||
123 | #else | ||
124 | # define TIMER_FREQ 1000000000ULL | ||
125 | #endif | ||
126 | |||
127 | #ifdef HAVE_MONOTONIC | ||
128 | extern unsigned long long monotonic_clock(void); | ||
129 | #else | ||
130 | static inline unsigned long long monotonic_clock(void) | ||
131 | { | ||
132 | struct timespec ts; | ||
133 | getrawmonotonic(&ts); | ||
134 | return timespec_to_ns(&ts); | ||
135 | } | ||
136 | #endif /* HAVE_MONOTONIC */ | ||
137 | |||
138 | 121 | ||
139 | /* Last time scheduled */ | 122 | /* Last time scheduled */ |
140 | static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; | 123 | static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; |
@@ -143,12 +126,11 @@ static void hangcheck_fire(unsigned long); | |||
143 | 126 | ||
144 | static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); | 127 | static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); |
145 | 128 | ||
146 | |||
147 | static void hangcheck_fire(unsigned long data) | 129 | static void hangcheck_fire(unsigned long data) |
148 | { | 130 | { |
149 | unsigned long long cur_tsc, tsc_diff; | 131 | unsigned long long cur_tsc, tsc_diff; |
150 | 132 | ||
151 | cur_tsc = monotonic_clock(); | 133 | cur_tsc = ktime_get_ns(); |
152 | 134 | ||
153 | if (cur_tsc > hangcheck_tsc) | 135 | if (cur_tsc > hangcheck_tsc) |
154 | tsc_diff = cur_tsc - hangcheck_tsc; | 136 | tsc_diff = cur_tsc - hangcheck_tsc; |
@@ -177,7 +159,7 @@ static void hangcheck_fire(unsigned long data) | |||
177 | tsc_diff, tsc_diff - hangcheck_tick*TIMER_FREQ); | 159 | tsc_diff, tsc_diff - hangcheck_tick*TIMER_FREQ); |
178 | #endif | 160 | #endif |
179 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); | 161 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); |
180 | hangcheck_tsc = monotonic_clock(); | 162 | hangcheck_tsc = ktime_get_ns(); |
181 | } | 163 | } |
182 | 164 | ||
183 | 165 | ||
@@ -185,16 +167,11 @@ static int __init hangcheck_init(void) | |||
185 | { | 167 | { |
186 | printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", | 168 | printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", |
187 | VERSION_STR, hangcheck_tick, hangcheck_margin); | 169 | VERSION_STR, hangcheck_tick, hangcheck_margin); |
188 | #if defined (HAVE_MONOTONIC) | ||
189 | printk("Hangcheck: Using monotonic_clock().\n"); | ||
190 | #else | ||
191 | printk("Hangcheck: Using getrawmonotonic().\n"); | ||
192 | #endif /* HAVE_MONOTONIC */ | ||
193 | hangcheck_tsc_margin = | 170 | hangcheck_tsc_margin = |
194 | (unsigned long long)(hangcheck_margin + hangcheck_tick); | 171 | (unsigned long long)(hangcheck_margin + hangcheck_tick); |
195 | hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ; | 172 | hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ; |
196 | 173 | ||
197 | hangcheck_tsc = monotonic_clock(); | 174 | hangcheck_tsc = ktime_get_ns(); |
198 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); | 175 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); |
199 | 176 | ||
200 | return 0; | 177 | return 0; |