Add umtxq_lock/unlock around umtx_signal, fix debug kernel compiling,
let umtx_lock returns EINTR when it returns ERESTART, this lets userland have chance to back off mtx lock code when needed.
This commit is contained in:
parent
a08c214a72
commit
3dd213f160
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=139258
@ -178,7 +178,7 @@ umtxq_unbusy(struct umtx_key *key)
|
|||||||
int chain = umtxq_hash(key);
|
int chain = umtxq_hash(key);
|
||||||
|
|
||||||
mtx_assert(umtxq_mtx(chain), MA_OWNED);
|
mtx_assert(umtxq_mtx(chain), MA_OWNED);
|
||||||
KASSERT(umtxq_chains[chain].uc_flags & UCF_BUSY, "not busy");
|
KASSERT(umtxq_chains[chain].uc_flags & UCF_BUSY, ("not busy"));
|
||||||
umtxq_chains[chain].uc_flags &= ~UCF_BUSY;
|
umtxq_chains[chain].uc_flags &= ~UCF_BUSY;
|
||||||
if (umtxq_chains[chain].uc_flags & UCF_WANT) {
|
if (umtxq_chains[chain].uc_flags & UCF_WANT) {
|
||||||
umtxq_chains[chain].uc_flags &= ~UCF_WANT;
|
umtxq_chains[chain].uc_flags &= ~UCF_WANT;
|
||||||
@ -545,13 +545,15 @@ do_lock(struct thread *td, struct umtx *umtx, long id,
|
|||||||
}
|
}
|
||||||
timo = tvtohz(&tv);
|
timo = tvtohz(&tv);
|
||||||
error = _do_lock(td, umtx, id, timo);
|
error = _do_lock(td, umtx, id, timo);
|
||||||
if (error != EWOULDBLOCK) {
|
if (error != EWOULDBLOCK)
|
||||||
if (error == ERESTART)
|
|
||||||
error = EINTR;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* This lets userland back off critical region if needed.
|
||||||
|
*/
|
||||||
|
if (error == ERESTART)
|
||||||
|
error = EINTR;
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +706,9 @@ do_wake(struct thread *td, void *uaddr, int n_wake)
|
|||||||
|
|
||||||
if ((ret = umtx_key_get(td, uaddr, &key)) != 0)
|
if ((ret = umtx_key_get(td, uaddr, &key)) != 0)
|
||||||
return (ret);
|
return (ret);
|
||||||
|
umtxq_lock(&key);
|
||||||
ret = umtxq_signal(&key, n_wake);
|
ret = umtxq_signal(&key, n_wake);
|
||||||
|
umtxq_unlock(&key);
|
||||||
umtx_key_release(&key);
|
umtx_key_release(&key);
|
||||||
td->td_retval[0] = ret;
|
td->td_retval[0] = ret;
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user