On Thursday, December 22, 2016 05:51:44 PM Mark Johnston wrote: > Author: markj > Date: Thu Dec 22 17:51:44 2016 > New Revision: 310423 > URL: https://svnweb.freebsd.org/changeset/base/310423 > > Log: > Revert part of r300109. > > The removal of TAILQ_FOREACH_SAFE introduced a small race: when the last > thread on a sleepqueue is awoken, it reclaims the sleepqueue and may begin > executing on a different CPU before sleepq_resume_thread() returns. This > leaves a window during which it may go back to sleep and incorrectly be > awoken again by the caller of sleepq_broadcast().
This is very subtle. The issue is that the last sleepq_resume_thread transfers ownership of 'sq' from the wait channel that the sleepq_broadcast has locked, to the thread being resumed. I thought about using a local TAILQ_HEAD and using TAILQ_CONCAT to move the list of threads out of the sleep queue and then walking that list. However, a comment explaining this transfer of ownership (and that we can't safely access 'sq' after the last thread is resumed) is probably sufficient (but necessary I think). Do you feel like adding one? -- John Baldwin _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"