Skip to content

Commit

Permalink
hrtimer, softirq: Fix hrtimer->softirq trampoline
Browse files Browse the repository at this point in the history
hrtimers callbacks are always done from hardirq context, either the
jiffy tick interrupt or the hrtimer device interrupt.

[ there is currently one exception that can still call a hrtimer
  callback from softirq, but even in that case this will still
  work correctly. ]

Reported-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Yury Polyanskiy <ypolyans@princeton.edu>
Tested-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Acked-by: David S. Miller <davem@davemloft.net>
LKML-Reference: <1265120401.24455.306.camel@laptop>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Peter Zijlstra authored and Thomas Gleixner committed Feb 3, 2010
1 parent c80d292 commit b9c3032
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions kernel/softirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,22 +500,17 @@ EXPORT_SYMBOL(tasklet_kill);
*/

/*
* The trampoline is called when the hrtimer expires. If this is
* called from the hrtimer interrupt then we schedule the tasklet as
* the timer callback function expects to run in softirq context. If
* it's called in softirq context anyway (i.e. high resolution timers
* disabled) then the hrtimer callback is called right away.
* The trampoline is called when the hrtimer expires. It schedules a tasklet
* to run __tasklet_hrtimer_trampoline() which in turn will call the intended
* hrtimer callback, but from softirq context.
*/
static enum hrtimer_restart __hrtimer_tasklet_trampoline(struct hrtimer *timer)
{
struct tasklet_hrtimer *ttimer =
container_of(timer, struct tasklet_hrtimer, timer);

if (hrtimer_is_hres_active(timer)) {
tasklet_hi_schedule(&ttimer->tasklet);
return HRTIMER_NORESTART;
}
return ttimer->function(timer);
tasklet_hi_schedule(&ttimer->tasklet);
return HRTIMER_NORESTART;
}

/*
Expand Down

0 comments on commit b9c3032

Please sign in to comment.