Clean up some cosmetic nits in kern_umtx.c, found during recent work
in this area and by the Clang static analyzer. Remove some dead assignments. Fix a typo in a panic string. Use umtx_pi_disown() instead of duplicate code. Use an existing variable instead of curthread. Approved by: kib (mentor) MFC after: 3 days Sponsored by: Dell Inc
This commit is contained in:
parent
b7ece01c7e
commit
e858b027db
@ -912,7 +912,7 @@ kern_umtx_wake(struct thread *td, void *uaddr, int n_wake, int is_private)
|
|||||||
is_private ? THREAD_SHARE : AUTO_SHARE, &key)) != 0)
|
is_private ? THREAD_SHARE : AUTO_SHARE, &key)) != 0)
|
||||||
return (ret);
|
return (ret);
|
||||||
umtxq_lock(&key);
|
umtxq_lock(&key);
|
||||||
ret = umtxq_signal(&key, n_wake);
|
umtxq_signal(&key, n_wake);
|
||||||
umtxq_unlock(&key);
|
umtxq_unlock(&key);
|
||||||
umtx_key_release(&key);
|
umtx_key_release(&key);
|
||||||
return (0);
|
return (0);
|
||||||
@ -1440,7 +1440,7 @@ umtx_pi_setowner(struct umtx_pi *pi, struct thread *owner)
|
|||||||
uq_owner = owner->td_umtxq;
|
uq_owner = owner->td_umtxq;
|
||||||
mtx_assert(&umtx_lock, MA_OWNED);
|
mtx_assert(&umtx_lock, MA_OWNED);
|
||||||
if (pi->pi_owner != NULL)
|
if (pi->pi_owner != NULL)
|
||||||
panic("pi_ower != NULL");
|
panic("pi_owner != NULL");
|
||||||
pi->pi_owner = owner;
|
pi->pi_owner = owner;
|
||||||
TAILQ_INSERT_TAIL(&uq_owner->uq_pi_contested, pi, pi_link);
|
TAILQ_INSERT_TAIL(&uq_owner->uq_pi_contested, pi, pi_link);
|
||||||
}
|
}
|
||||||
@ -1464,9 +1464,8 @@ umtx_pi_disown(struct umtx_pi *pi)
|
|||||||
static int
|
static int
|
||||||
umtx_pi_claim(struct umtx_pi *pi, struct thread *owner)
|
umtx_pi_claim(struct umtx_pi *pi, struct thread *owner)
|
||||||
{
|
{
|
||||||
struct umtx_q *uq, *uq_owner;
|
struct umtx_q *uq;
|
||||||
|
|
||||||
uq_owner = owner->td_umtxq;
|
|
||||||
mtx_lock(&umtx_lock);
|
mtx_lock(&umtx_lock);
|
||||||
if (pi->pi_owner == owner) {
|
if (pi->pi_owner == owner) {
|
||||||
mtx_unlock(&umtx_lock);
|
mtx_unlock(&umtx_lock);
|
||||||
@ -1612,11 +1611,8 @@ umtx_pi_unref(struct umtx_pi *pi)
|
|||||||
KASSERT(pi->pi_refcount > 0, ("invalid reference count"));
|
KASSERT(pi->pi_refcount > 0, ("invalid reference count"));
|
||||||
if (--pi->pi_refcount == 0) {
|
if (--pi->pi_refcount == 0) {
|
||||||
mtx_lock(&umtx_lock);
|
mtx_lock(&umtx_lock);
|
||||||
if (pi->pi_owner != NULL) {
|
if (pi->pi_owner != NULL)
|
||||||
TAILQ_REMOVE(&pi->pi_owner->td_umtxq->uq_pi_contested,
|
umtx_pi_disown(pi);
|
||||||
pi, pi_link);
|
|
||||||
pi->pi_owner = NULL;
|
|
||||||
}
|
|
||||||
KASSERT(TAILQ_EMPTY(&pi->pi_blocked),
|
KASSERT(TAILQ_EMPTY(&pi->pi_blocked),
|
||||||
("blocked queue not empty"));
|
("blocked queue not empty"));
|
||||||
mtx_unlock(&umtx_lock);
|
mtx_unlock(&umtx_lock);
|
||||||
@ -1876,7 +1872,7 @@ do_unlock_pi(struct thread *td, struct umutex *m, uint32_t flags)
|
|||||||
mtx_lock(&umtx_lock);
|
mtx_lock(&umtx_lock);
|
||||||
pi = uq_first->uq_pi_blocked;
|
pi = uq_first->uq_pi_blocked;
|
||||||
KASSERT(pi != NULL, ("pi == NULL?"));
|
KASSERT(pi != NULL, ("pi == NULL?"));
|
||||||
if (pi->pi_owner != curthread) {
|
if (pi->pi_owner != td) {
|
||||||
mtx_unlock(&umtx_lock);
|
mtx_unlock(&umtx_lock);
|
||||||
umtxq_unbusy(&key);
|
umtxq_unbusy(&key);
|
||||||
umtxq_unlock(&key);
|
umtxq_unlock(&key);
|
||||||
@ -1884,7 +1880,7 @@ do_unlock_pi(struct thread *td, struct umutex *m, uint32_t flags)
|
|||||||
/* userland messed the mutex */
|
/* userland messed the mutex */
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
}
|
}
|
||||||
uq_me = curthread->td_umtxq;
|
uq_me = td->td_umtxq;
|
||||||
umtx_pi_disown(pi);
|
umtx_pi_disown(pi);
|
||||||
/* get highest priority thread which is still sleeping. */
|
/* get highest priority thread which is still sleeping. */
|
||||||
uq_first = TAILQ_FIRST(&pi->pi_blocked);
|
uq_first = TAILQ_FIRST(&pi->pi_blocked);
|
||||||
@ -1900,9 +1896,9 @@ do_unlock_pi(struct thread *td, struct umutex *m, uint32_t flags)
|
|||||||
pri = UPRI(uq_first2->uq_thread);
|
pri = UPRI(uq_first2->uq_thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thread_lock(curthread);
|
thread_lock(td);
|
||||||
sched_lend_user_prio(curthread, pri);
|
sched_lend_user_prio(td, pri);
|
||||||
thread_unlock(curthread);
|
thread_unlock(td);
|
||||||
mtx_unlock(&umtx_lock);
|
mtx_unlock(&umtx_lock);
|
||||||
if (uq_first)
|
if (uq_first)
|
||||||
umtxq_signal_thread(uq_first);
|
umtxq_signal_thread(uq_first);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user