Commit c9db4fa11526affde83603fe52595bd1260c1354
1 parent
e2787630c1
Exists in
master
and in
4 other branches
[hrtimer] Enforce resolution as lower limit of intervals
Roman Zippel pointed out that the missing lower limit of intervals leads to an accounting error in the overrun count. Enforce the lower limit of intervals to resolution in the timer forwarding code. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Showing 2 changed files with 5 additions and 3 deletions Side-by-side Diff
include/linux/hrtimer.h
... | ... | @@ -122,8 +122,7 @@ |
122 | 122 | } |
123 | 123 | |
124 | 124 | /* Forward a hrtimer so it expires after now: */ |
125 | -extern unsigned long hrtimer_forward(struct hrtimer *timer, | |
126 | - const ktime_t interval); | |
125 | +extern unsigned long hrtimer_forward(struct hrtimer *timer, ktime_t interval); | |
127 | 126 | |
128 | 127 | /* Precise sleep: */ |
129 | 128 | extern long hrtimer_nanosleep(struct timespec *rqtp, |
kernel/hrtimer.c
... | ... | @@ -275,7 +275,7 @@ |
275 | 275 | * The number of overruns is added to the overrun field. |
276 | 276 | */ |
277 | 277 | unsigned long |
278 | -hrtimer_forward(struct hrtimer *timer, const ktime_t interval) | |
278 | +hrtimer_forward(struct hrtimer *timer, ktime_t interval) | |
279 | 279 | { |
280 | 280 | unsigned long orun = 1; |
281 | 281 | ktime_t delta, now; |
... | ... | @@ -286,6 +286,9 @@ |
286 | 286 | |
287 | 287 | if (delta.tv64 < 0) |
288 | 288 | return 0; |
289 | + | |
290 | + if (interval.tv64 < timer->base->resolution.tv64) | |
291 | + interval.tv64 = timer->base->resolution.tv64; | |
289 | 292 | |
290 | 293 | if (unlikely(delta.tv64 >= interval.tv64)) { |
291 | 294 | nsec_t incr = ktime_to_ns(interval); |