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>
This commit is contained in:
parent
6af028f471
commit
e2a43807d9
|
@ -1274,6 +1274,21 @@ wait_to_die:
|
||||||
return 0;
|
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)
|
void run_posix_cpu_timers(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
unsigned long cpu = smp_processor_id();
|
unsigned long cpu = smp_processor_id();
|
||||||
|
@ -1286,7 +1301,7 @@ void run_posix_cpu_timers(struct task_struct *tsk)
|
||||||
tasklist = per_cpu(posix_timer_tasklist, cpu);
|
tasklist = per_cpu(posix_timer_tasklist, cpu);
|
||||||
|
|
||||||
/* check to see if we're already queued */
|
/* 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);
|
get_task_struct(tsk);
|
||||||
if (tasklist) {
|
if (tasklist) {
|
||||||
tsk->posix_timer_list = tasklist;
|
tsk->posix_timer_list = tasklist;
|
||||||
|
@ -1298,9 +1313,9 @@ void run_posix_cpu_timers(struct task_struct *tsk)
|
||||||
tsk->posix_timer_list = tsk;
|
tsk->posix_timer_list = tsk;
|
||||||
}
|
}
|
||||||
per_cpu(posix_timer_tasklist, cpu) = 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue