Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Gleixner and committed by
John Stultz
2044fdb0 61edec81

+5 -28
+5 -28
drivers/char/hangcheck-timer.c
··· 49 49 #include <asm/uaccess.h> 50 50 #include <linux/sysrq.h> 51 51 #include <linux/timer.h> 52 - #include <linux/time.h> 52 + #include <linux/hrtimer.h> 53 53 54 54 #define VERSION_STR "0.9.1" 55 55 ··· 117 117 __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); 118 118 #endif /* not MODULE */ 119 119 120 - #if defined(CONFIG_S390) 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 - 120 + #define TIMER_FREQ 1000000000ULL 138 121 139 122 /* Last time scheduled */ 140 123 static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; ··· 126 143 127 144 static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); 128 145 129 - 130 146 static void hangcheck_fire(unsigned long data) 131 147 { 132 148 unsigned long long cur_tsc, tsc_diff; 133 149 134 - cur_tsc = monotonic_clock(); 150 + cur_tsc = ktime_get_ns(); 135 151 136 152 if (cur_tsc > hangcheck_tsc) 137 153 tsc_diff = cur_tsc - hangcheck_tsc; ··· 159 177 tsc_diff, tsc_diff - hangcheck_tick*TIMER_FREQ); 160 178 #endif 161 179 mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); 162 - hangcheck_tsc = monotonic_clock(); 180 + hangcheck_tsc = ktime_get_ns(); 163 181 } 164 182 165 183 ··· 167 185 { 168 186 printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", 169 187 VERSION_STR, hangcheck_tick, hangcheck_margin); 170 - #if defined (HAVE_MONOTONIC) 171 - printk("Hangcheck: Using monotonic_clock().\n"); 172 - #else 173 - printk("Hangcheck: Using getrawmonotonic().\n"); 174 - #endif /* HAVE_MONOTONIC */ 175 188 hangcheck_tsc_margin = 176 189 (unsigned long long)(hangcheck_margin + hangcheck_tick); 177 190 hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ; 178 191 179 - hangcheck_tsc = monotonic_clock(); 192 + hangcheck_tsc = ktime_get_ns(); 180 193 mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); 181 194 182 195 return 0;