diff options
| -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; |
