Page MenuHomeFreeBSD

D49031.id151141.diff
No OneTemporary

D49031.id151141.diff

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -2542,6 +2542,7 @@
old_inherited_pri = uq->uq_inherited_pri;
umtxq_lock(&uq->uq_key);
umtxq_busy(&uq->uq_key);
+ umtxq_insert(uq);
umtxq_unlock(&uq->uq_key);
rv = fueword32(&m->m_ceilings[0], &ceiling);
@@ -2609,18 +2610,17 @@
if (error == 0) {
error = thread_check_susp(td, false);
if (error == 0 && try == 0) {
- umtxq_unbusy_unlocked(&uq->uq_key);
+ umtxq_lock(&uq->uq_key);
+ umtxq_remove(uq);
+ umtxq_unbusy(&uq->uq_key);
+ umtxq_unlock(&uq->uq_key);
continue;
}
- error = 0;
}
} else if (owner == UMUTEX_RB_NOTRECOV) {
error = ENOTRECOVERABLE;
}
- if (try != 0)
- error = EBUSY;
-
/*
* If we caught a signal, we have retried and now
* exit immediately.
@@ -2628,8 +2628,23 @@
if (error != 0)
break;
+ /*
+ * We may have gotten a spurious failure.
+ */
+ if (owner == UMUTEX_CONTESTED) {
+ umtxq_lock(&uq->uq_key);
+ umtxq_remove(uq);
+ umtxq_unbusy(&uq->uq_key);
+ umtxq_unlock(&uq->uq_key);
+ continue;
+ }
+
+ if (try != 0) {
+ error = EBUSY;
+ break;
+ }
+
umtxq_lock(&uq->uq_key);
- umtxq_insert(uq);
umtxq_unbusy(&uq->uq_key);
error = umtxq_sleep(uq, "umtxpp", timeout == NULL ?
NULL : &timo);
@@ -2674,7 +2689,10 @@
}
out:
- umtxq_unbusy_unlocked(&uq->uq_key);
+ umtxq_lock(&uq->uq_key);
+ umtxq_unbusy(&uq->uq_key);
+ umtxq_remove(uq);
+ umtxq_unlock(&uq->uq_key);
umtx_key_release(&uq->uq_key);
return (error);
}
@@ -2790,6 +2808,7 @@
for (;;) {
umtxq_lock(&uq->uq_key);
umtxq_busy(&uq->uq_key);
+ umtxq_insert(uq);
umtxq_unlock(&uq->uq_key);
rv = fueword32(&m->m_ceilings[0], &save_ceiling);
@@ -2834,13 +2853,23 @@
if (error != 0)
break;
+ /*
+ * We may have gotten a spurious failure.
+ */
+ if (owner == UMUTEX_CONTESTED) {
+ umtxq_lock(&uq->uq_key);
+ umtxq_remove(uq);
+ umtxq_unbusy(&uq->uq_key);
+ umtxq_unlock(&uq->uq_key);
+ continue;
+ }
+
/*
* We set the contested bit, sleep. Otherwise the lock changed
* and we need to retry or we lost a race to the thread
* unlocking the umtx.
*/
umtxq_lock(&uq->uq_key);
- umtxq_insert(uq);
umtxq_unbusy(&uq->uq_key);
error = umtxq_sleep(uq, "umtxpp", NULL);
umtxq_remove(uq);
@@ -2849,6 +2878,7 @@
umtxq_lock(&uq->uq_key);
if (error == 0)
umtxq_signal(&uq->uq_key, INT_MAX);
+ umtxq_remove(uq);
umtxq_unbusy(&uq->uq_key);
umtxq_unlock(&uq->uq_key);
umtx_key_release(&uq->uq_key);

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 8, 10:34 PM (10 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28505972
Default Alt Text
D49031.id151141.diff (2 KB)

Event Timeline