On Tue, 15 Jan 2013, Liu, Chuansheng wrote: > > Indeed, this patch introduces a race. If runtime_status changes from > > RPM_SUSPENDING and power.wait_queue is signalled in between the test at > > the end of the loop and the prepare_to_wait() call, the loop will never > > end. > Checking the race case, it should not happen? > Updating runtime_status and wake_up wait_queue are protected by power.lock. > spin_lock(&power.lock) > ... > __update_runtime_status() > ... > wake_up_all(&dev->power.wait_queue) > ... > spin_unlock(&power.lock)
You're right, the lock prevents this race from happening. On the other hand, with your change we would end up calling finish_wait() without calling prepare_to_wait() first. And as Rafael mentioned, the current code fits the pattern that people expect to see. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/