aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-06-20 10:32:20 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-20 11:15:49 -0400
commitea71a546706dfdad72462624394e1e472c6bf34f (patch)
treeeb6f257c73510deee995f330947de4624e9b404b /kernel/sched.c
parentbb10ed0994927d433f6dbdf274fdb26cfcf516b7 (diff)
sched: refactor wait_for_completion_timeout()
Simplify the code and fix the boundary condition of wait_for_completion_timeout(,0). We can kill the first __remove_wait_queue() as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 577f160131bd..bebf9788f45e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4398,32 +4398,20 @@ do_wait_for_common(struct completion *x, long timeout, int state)
4398 signal_pending(current)) || 4398 signal_pending(current)) ||
4399 (state == TASK_KILLABLE && 4399 (state == TASK_KILLABLE &&
4400 fatal_signal_pending(current))) { 4400 fatal_signal_pending(current))) {
4401 __remove_wait_queue(&x->wait, &wait); 4401 timeout = -ERESTARTSYS;
4402 return -ERESTARTSYS; 4402 break;
4403 } 4403 }
4404 __set_current_state(state); 4404 __set_current_state(state);
4405 spin_unlock_irq(&x->wait.lock); 4405 spin_unlock_irq(&x->wait.lock);
4406 timeout = schedule_timeout(timeout); 4406 timeout = schedule_timeout(timeout);
4407 spin_lock_irq(&x->wait.lock); 4407 spin_lock_irq(&x->wait.lock);
4408 4408 } while (!x->done && timeout);
4409 /*
4410 * If the completion has arrived meanwhile
4411 * then return 1 jiffy time left:
4412 */
4413 if (x->done && !timeout) {
4414 timeout = 1;
4415 break;
4416 }
4417
4418 if (!timeout) {
4419 __remove_wait_queue(&x->wait, &wait);
4420 return timeout;
4421 }
4422 } while (!x->done);
4423 __remove_wait_queue(&x->wait, &wait); 4409 __remove_wait_queue(&x->wait, &wait);
4410 if (!x->done)
4411 return timeout;
4424 } 4412 }
4425 x->done--; 4413 x->done--;
4426 return timeout; 4414 return timeout ?: 1;
4427} 4415}
4428 4416
4429static long __sched 4417static long __sched