lkml.org 
[lkml]   [2010]   [Dec]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH] fix unsafe operation in high resolution timer
From
After calling the callback function of hrtimer, the timer could become
unreliable in corner cases where the timer will no longer be queued
and the mm segment, in which the timer is embedded, could be reclaimed
in the callback.

The unreliability is fixed by checking the result of callback before
operating the timer again.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/kernel/hrtimer.c 2010-11-01 19:54:12.000000000 +0800
+++ b/kernel/hrtimer.c 2010-12-23 21:17:02.000000000 +0800
@@ -1225,6 +1225,7 @@ static void __run_hrtimer(struct hrtimer
raw_spin_unlock(&cpu_base->lock);
trace_hrtimer_expire_entry(timer, now);
restart = fn(timer);
+ if (restart != HRTIMER_NORESTART)
trace_hrtimer_expire_exit(timer);
raw_spin_lock(&cpu_base->lock);

@@ -1236,11 +1237,8 @@ static void __run_hrtimer(struct hrtimer
if (restart != HRTIMER_NORESTART) {
BUG_ON(timer->state != HRTIMER_STATE_CALLBACK);
enqueue_hrtimer(timer, base);
+ timer->state &= ~HRTIMER_STATE_CALLBACK;
}
-
- WARN_ON_ONCE(!(timer->state & HRTIMER_STATE_CALLBACK));
-
- timer->state &= ~HRTIMER_STATE_CALLBACK;
}

#ifdef CONFIG_HIGH_RES_TIMERS

\
 
 \ /
  Last update: 2010-12-23 14:33    [W:0.059 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site