Commit c9db4fa1 authored by Thomas Gleixner's avatar Thomas Gleixner

[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: default avatarThomas Gleixner <tglx@linutronix.de>
parent e2787630
...@@ -122,8 +122,7 @@ static inline int hrtimer_active(const struct hrtimer *timer) ...@@ -122,8 +122,7 @@ static inline int hrtimer_active(const struct hrtimer *timer)
} }
/* Forward a hrtimer so it expires after now: */ /* Forward a hrtimer so it expires after now: */
extern unsigned long hrtimer_forward(struct hrtimer *timer, extern unsigned long hrtimer_forward(struct hrtimer *timer, ktime_t interval);
const ktime_t interval);
/* Precise sleep: */ /* Precise sleep: */
extern long hrtimer_nanosleep(struct timespec *rqtp, extern long hrtimer_nanosleep(struct timespec *rqtp,
......
...@@ -275,7 +275,7 @@ void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) ...@@ -275,7 +275,7 @@ void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
* The number of overruns is added to the overrun field. * The number of overruns is added to the overrun field.
*/ */
unsigned long unsigned long
hrtimer_forward(struct hrtimer *timer, const ktime_t interval) hrtimer_forward(struct hrtimer *timer, ktime_t interval)
{ {
unsigned long orun = 1; unsigned long orun = 1;
ktime_t delta, now; ktime_t delta, now;
...@@ -287,6 +287,9 @@ hrtimer_forward(struct hrtimer *timer, const ktime_t interval) ...@@ -287,6 +287,9 @@ hrtimer_forward(struct hrtimer *timer, const ktime_t interval)
if (delta.tv64 < 0) if (delta.tv64 < 0)
return 0; return 0;
if (interval.tv64 < timer->base->resolution.tv64)
interval.tv64 = timer->base->resolution.tv64;
if (unlikely(delta.tv64 >= interval.tv64)) { if (unlikely(delta.tv64 >= interval.tv64)) {
nsec_t incr = ktime_to_ns(interval); nsec_t incr = ktime_to_ns(interval);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment