]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
hrtimer: prevent migration for raising softirq
authorSteven Rostedt <rostedt@goodmis.org>
Thu, 3 Jul 2008 18:31:26 +0000 (14:31 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 24 Jul 2008 16:14:12 +0000 (09:14 -0700)
commit ee3ece830f6db9837f7ac67008f532a8c1e755f4 upstream.

Due to a possible deadlock, the waking of the softirq was pushed outside
of the hrtimer base locks. See commit 0c96c5979a522c3323c30a078a70120e29b5bdbc

Unfortunately this allows the task to migrate after setting up the softirq
and raising it. Since softirqs run a queue that is per-cpu we may raise the
softirq on the wrong CPU and this will keep the queued softirq task from
running.

To solve this issue, this patch disables preemption around the releasing
of the hrtimer lock and raising of the softirq.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/hrtimer.c

index c15a359ea611fe7f22fe2fb7a599ceacc2dad8b8..3d31d65299337a7991e1bedc6b75b6e6772ffd8a 100644 (file)
@@ -896,10 +896,18 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
         */
        raise = timer->state == HRTIMER_STATE_PENDING;
 
+       /*
+        * We use preempt_disable to prevent this task from migrating after
+        * setting up the softirq and raising it. Otherwise, if me migrate
+        * we will raise the softirq on the wrong CPU.
+        */
+       preempt_disable();
+
        unlock_hrtimer_base(timer, &flags);
 
        if (raise)
                hrtimer_raise_softirq();
+       preempt_enable();
 
        return ret;
 }