[ofa-general] Re: wait_for_completion_timeout() spurious failure under heavy load?

Jiri Slaby jirislaby at gmail.com
Thu Jun 19 23:40:49 PDT 2008


Roland Dreier napsal(a):
> It seems that the current implementaton of wait_for_completion_timeout()
> has a small problem under very high load for the common pattern:
> 
> 	if (!wait_for_completion_timeout(&done, timeout))
> 		/* handle failure */
> 
> because the implementation very roughly does (lots of code deleted to
> show the basic flow):
> 
> 	static inline long __sched
> 	do_wait_for_common(struct completion *x, long timeout, int state)
> 	{
> 		if (x->done)
> 			return timeout;
> 
> 		do {
> 			timeout = schedule_timeout(timeout);
> 	
> 			if (!timeout)
> 				return timeout;
> 	
> 		} while (!x->done);
> 	
> 		return timeout;
> 	}
> 
> so if the system is very busy and x->done is not set when
> do_wait_for_common() is entered, it is possible that the first call to
> schedule_timeout() returns 0 because the task doing wait_for_completion

Sorry, but how can schedule_timeout return 0 before the timeout expiration?



More information about the general mailing list