1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-13 14:40:22 +00:00

_utmx_op: don't recurse on chain busy

In handling a PP mutex, we'll busy it as soon as we enter the loop and
unbusy it either prior to sleeping or at exit time.  In this particular
case, if we fail to transition the mutex from OWNERDEAD -> owned because
of casueword(9) failure and the suspend check fails, we'll start over
and attempt to busy an already-busied chain and irrecoverably lock up
both this thread and anything else that tries to busy the chain.

Unbusy the chain prior to restarting because I couldn't decide if that
was a better or worse idea than just keeping track of whether we dirtied
it in do_lock_pp() and avoiding re-dirty.  This is marginally easier to
reason about as it returns us to expected state on entry to the loop.

While we're here, simplify the code a bit as `error` will be clobbered
right after the branch anyways.

Reviewed by:	kib, olce (both earlier version)
Differential Revision:	https://reviews.freebsd.org/D47493
This commit is contained in:
Kyle Evans 2024-11-13 16:18:40 -06:00
parent 0f30aed105
commit f660777865

View File

@ -2605,11 +2605,9 @@ do_lock_pp(struct thread *td, struct umutex *m, uint32_t flags,
*/
if (error == 0) {
error = thread_check_susp(td, false);
if (error == 0) {
if (try != 0)
error = EBUSY;
else
continue;
if (error == 0 && try == 0) {
umtxq_unbusy_unlocked(&uq->uq_key);
continue;
}
error = 0;
}