epoch(9): fix potential deadlock

Don't acquire a waiting thread's lock while holding our own

Approved by:	sbruno
This commit is contained in:
Matt Macy 2018-05-17 19:41:58 +00:00
parent 80767b1c65
commit d1bcb409f6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333758

View File

@ -407,9 +407,13 @@ epoch_block_handler(struct ck_epoch *global __unused, ck_epoch_record_t *cr,
* restore on exit from epoch_wait().
*/
if (!TD_IS_INHIBITED(tdwait) && tdwait->td_priority > td->td_priority) {
critical_enter();
thread_unlock(td);
thread_lock(tdwait);
sched_prio(tdwait, td->td_priority);
thread_unlock(tdwait);
thread_lock(td);
critical_exit();
}
if (TD_IS_INHIBITED(tdwait) && TD_ON_LOCK(tdwait) &&
((ts = tdwait->td_blocked) != NULL)) {