Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea71a546 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar
Browse files

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: default avatarIngo Molnar <mingo@elte.hu>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
parent bb10ed09
Loading
Loading
Loading
Loading
+6 −18
Original line number Original line Diff line number Diff line
@@ -4398,32 +4398,20 @@ do_wait_for_common(struct completion *x, long timeout, int state)
			     signal_pending(current)) ||
			     signal_pending(current)) ||
			    (state == TASK_KILLABLE &&
			    (state == TASK_KILLABLE &&
			     fatal_signal_pending(current))) {
			     fatal_signal_pending(current))) {
				__remove_wait_queue(&x->wait, &wait);
				timeout = -ERESTARTSYS;
				return -ERESTARTSYS;
				break;
			}
			}
			__set_current_state(state);
			__set_current_state(state);
			spin_unlock_irq(&x->wait.lock);
			spin_unlock_irq(&x->wait.lock);
			timeout = schedule_timeout(timeout);
			timeout = schedule_timeout(timeout);
			spin_lock_irq(&x->wait.lock);
			spin_lock_irq(&x->wait.lock);

		} while (!x->done && timeout);
			/*
			 * If the completion has arrived meanwhile
			 * then return 1 jiffy time left:
			 */
			if (x->done && !timeout) {
				timeout = 1;
				break;
			}

			if (!timeout) {
		__remove_wait_queue(&x->wait, &wait);
		__remove_wait_queue(&x->wait, &wait);
		if (!x->done)
			return timeout;
			return timeout;
	}
	}
		} while (!x->done);
		__remove_wait_queue(&x->wait, &wait);
	}
	x->done--;
	x->done--;
	return timeout;
	return timeout ?: 1;
}
}


static long __sched
static long __sched