Skip to content

Commit 2044fdb

Browse files
KAGA-KOKOjohnstultz-work
authored andcommitted
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>
1 parent 61edec8 commit 2044fdb

1 file changed

Lines changed: 5 additions & 28 deletions

File tree

‎drivers/char/hangcheck-timer.c‎

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include <asm/uaccess.h>
5050
#include <linux/sysrq.h>
5151
#include <linux/timer.h>
52-
#include <linux/time.h>
52+
#include <linux/hrtimer.h>
5353

5454
#define VERSION_STR "0.9.1"
5555

@@ -117,24 +117,7 @@ __setup("hcheck_reboot", hangcheck_parse_reboot);
117117
__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118118
#endif /* not MODULE */
119119

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
138121

139122
/* Last time scheduled */
140123
static unsigned long long hangcheck_tsc, hangcheck_tsc_margin;
@@ -143,12 +126,11 @@ static void hangcheck_fire(unsigned long);
143126

144127
static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0);
145128

146-
147129
static void hangcheck_fire(unsigned long data)
148130
{
149131
unsigned long long cur_tsc, tsc_diff;
150132

151-
cur_tsc = monotonic_clock();
133+
cur_tsc = ktime_get_ns();
152134

153135
if (cur_tsc > hangcheck_tsc)
154136
tsc_diff = cur_tsc - hangcheck_tsc;
@@ -177,24 +159,19 @@ static void hangcheck_fire(unsigned long data)
177159
tsc_diff, tsc_diff - hangcheck_tick*TIMER_FREQ);
178160
#endif
179161
mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ));
180-
hangcheck_tsc = monotonic_clock();
162+
hangcheck_tsc = ktime_get_ns();
181163
}
182164

183165

184166
static int __init hangcheck_init(void)
185167
{
186168
printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n",
187169
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 */
193170
hangcheck_tsc_margin =
194171
(unsigned long long)(hangcheck_margin + hangcheck_tick);
195172
hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ;
196173

197-
hangcheck_tsc = monotonic_clock();
174+
hangcheck_tsc = ktime_get_ns();
198175
mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ));
199176

200177
return 0;

0 commit comments

Comments
 (0)