diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-07-03 13:44:44 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-05-14 18:38:11 (GMT) |
commit | 62630bcefd277c0647f4b47bac54e0c0ef077c93 (patch) | |
tree | caf2bdd88e982b6aef2588a35cadaa5c78d6f8f2 /kernel/posix-cpu-timers.c | |
parent | 28a746a14daedf8bc3f1f1c060b4dd147eb122fc (diff) | |
download | linux-fsl-qoriq-62630bcefd277c0647f4b47bac54e0c0ef077c93.tar.xz |
posix-timers: Avoid wakeups when no timers are active
Waking the thread even when no timers are scheduled is useless.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r-- | kernel/posix-cpu-timers.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 2d1963c..4bf82f8 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c @@ -1331,6 +1331,21 @@ wait_to_die: return 0; } +static inline int __fastpath_timer_check(struct task_struct *tsk) +{ + /* tsk == current, ensure it is safe to use ->signal/sighand */ + if (unlikely(tsk->exit_state)) + return 0; + + if (!task_cputime_zero(&tsk->cputime_expires)) + return 1; + + if (!task_cputime_zero(&tsk->signal->cputime_expires)) + return 1; + + return 0; +} + void run_posix_cpu_timers(struct task_struct *tsk) { unsigned long cpu = smp_processor_id(); @@ -1343,7 +1358,7 @@ void run_posix_cpu_timers(struct task_struct *tsk) tasklist = per_cpu(posix_timer_tasklist, cpu); /* check to see if we're already queued */ - if (!tsk->posix_timer_list) { + if (!tsk->posix_timer_list && __fastpath_timer_check(tsk)) { get_task_struct(tsk); if (tasklist) { tsk->posix_timer_list = tasklist; @@ -1355,9 +1370,9 @@ void run_posix_cpu_timers(struct task_struct *tsk) tsk->posix_timer_list = tsk; } per_cpu(posix_timer_tasklist, cpu) = tsk; + + wake_up_process(per_cpu(posix_timer_task, cpu)); } - /* XXX signal the thread somehow */ - wake_up_process(per_cpu(posix_timer_task, cpu)); } /* |