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:
Eric van Gyzen 2015-03-28 21:21:40 +00:00
parent b7ece01c7e
commit e858b027db
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=280792

View File

@ -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)
return (ret);
umtxq_lock(&key);
ret = umtxq_signal(&key, n_wake);
umtxq_signal(&key, n_wake);
umtxq_unlock(&key);
umtx_key_release(&key);
return (0);
@ -1440,7 +1440,7 @@ umtx_pi_setowner(struct umtx_pi *pi, struct thread *owner)
uq_owner = owner->td_umtxq;
mtx_assert(&umtx_lock, MA_OWNED);
if (pi->pi_owner != NULL)
panic("pi_ower != NULL");
panic("pi_owner != NULL");
pi->pi_owner = owner;
TAILQ_INSERT_TAIL(&uq_owner->uq_pi_contested, pi, pi_link);
}
@ -1464,9 +1464,8 @@ umtx_pi_disown(struct umtx_pi *pi)
static int
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);
if (pi->pi_owner == owner) {
mtx_unlock(&umtx_lock);
@ -1612,11 +1611,8 @@ umtx_pi_unref(struct umtx_pi *pi)
KASSERT(pi->pi_refcount > 0, ("invalid reference count"));
if (--pi->pi_refcount == 0) {
mtx_lock(&umtx_lock);
if (pi->pi_owner != NULL) {
TAILQ_REMOVE(&pi->pi_owner->td_umtxq->uq_pi_contested,
pi, pi_link);
pi->pi_owner = NULL;
}
if (pi->pi_owner != NULL)
umtx_pi_disown(pi);
KASSERT(TAILQ_EMPTY(&pi->pi_blocked),
("blocked queue not empty"));
mtx_unlock(&umtx_lock);
@ -1876,7 +1872,7 @@ do_unlock_pi(struct thread *td, struct umutex *m, uint32_t flags)
mtx_lock(&umtx_lock);
pi = uq_first->uq_pi_blocked;
KASSERT(pi != NULL, ("pi == NULL?"));
if (pi->pi_owner != curthread) {
if (pi->pi_owner != td) {
mtx_unlock(&umtx_lock);
umtxq_unbusy(&key);
umtxq_unlock(&key);
@ -1884,7 +1880,7 @@ do_unlock_pi(struct thread *td, struct umutex *m, uint32_t flags)
/* userland messed the mutex */
return (EPERM);
}
uq_me = curthread->td_umtxq;
uq_me = td->td_umtxq;
umtx_pi_disown(pi);
/* get highest priority thread which is still sleeping. */
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);
}
}
thread_lock(curthread);
sched_lend_user_prio(curthread, pri);
thread_unlock(curthread);
thread_lock(td);
sched_lend_user_prio(td, pri);
thread_unlock(td);
mtx_unlock(&umtx_lock);
if (uq_first)
umtxq_signal_thread(uq_first);