When failing to claim ownership of a umtx_pi, restore the umutex owner

to its previous, unowned state.  This avoids compounding an existing
problem of inconsistent ownership.

Submitted by:	Eric van Gyzen <eric_van_gyzen@dell.com>
Obtained from:	Dell Inc.
PR:	198914
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2015-02-25 16:17:16 +00:00
parent cc876d2c5c
commit 84b736b268
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=279283

View File

@ -1741,6 +1741,17 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32_t flags,
error = umtx_pi_claim(pi, td);
umtxq_unbusy(&uq->uq_key);
umtxq_unlock(&uq->uq_key);
if (error != 0) {
/*
* Since we're going to return an
* error, restore the m_owner to its
* previous, unowned state to avoid
* compounding the problem.
*/
(void)casuword32(&m->m_owner,
id | UMUTEX_CONTESTED,
UMUTEX_CONTESTED);
}
break;
}