Linus Torvalds writes: (Summary) The default "autoremove_wake_function()" does the
wait list removal, so if you just use the normal wait/wakeup, you're
all done an don't need to do anythig more.
all done an don't need to do anythig more.
That's very much by design.
That's very much by design.
In fact, it's why "finish_wait()" uses that "list_empty_careful()" thing on the entry - exactly so that it only needs to take the wait queue lock if it is still on the wait list (ie it was woken up by something else).
something else).
Now, it *is* racy, in the sense that the autoremove_wake_function() will remove the entry *after* having successfully woken up the process, so with bad luck and a quick wakeup, the woken process may not see the good list_empty_careful() case.
not see the good list_empty_careful() case.
So we really *should* do the remove earlier inside the pi_lock region in ttwu().
all done an don't need to do anythig more.
That's very much by design.
That's very much by design.
In fact, it's why "finish_wait()" uses that "list_empty_careful()" thing on the entry - exactly so that it only needs to take the wait queue lock if it is still on the wait list (ie it was woken up by something else).
something else).
Now, it *is* racy, in the sense that the autoremove_wake_function() will remove the entry *after* having successfully woken up the process, so with bad luck and a quick wakeup, the woken process may not see the good list_empty_careful() case.
not see the good list_empty_careful() case.
So we really *should* do the remove earlier inside the pi_lock region in ttwu().