Skip to content

Commit

Permalink
hrtimer: prevent migration for raising softirq
Browse files Browse the repository at this point in the history
Due to a possible deadlock, the waking of the softirq was pushed outside
of the hrtimer base locks. See commit 0c96c59

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>
  • Loading branch information
Steven Rostedt authored and Linus Torvalds committed Jul 3, 2008
1 parent 6beef7e commit ee3ece8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,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;
}
Expand Down

0 comments on commit ee3ece8

Please sign in to comment.