svn commit: r288494 - stable/10/sys/kern
Eric van Gyzen
vangyzen at FreeBSD.org
Fri Oct 2 13:48:33 UTC 2015
Author: vangyzen
Date: Fri Oct 2 13:48:32 2015
New Revision: 288494
URL: https://svnweb.freebsd.org/changeset/base/288494
Log:
MFC r280792
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 until recently)
Sponsored by: Dell Inc.
Modified:
stable/10/sys/kern/kern_umtx.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/kern/kern_umtx.c
==============================================================================
--- stable/10/sys/kern/kern_umtx.c Fri Oct 2 13:30:56 2015 (r288493)
+++ stable/10/sys/kern/kern_umtx.c Fri Oct 2 13:48:32 2015 (r288494)
@@ -1273,7 +1273,7 @@ kern_umtx_wake(struct thread *td, void *
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);
@@ -1805,7 +1805,7 @@ umtx_pi_setowner(struct umtx_pi *pi, str
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);
}
@@ -1829,9 +1829,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);
@@ -1977,11 +1976,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);
@@ -2241,7 +2237,7 @@ do_unlock_pi(struct thread *td, struct u
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);
@@ -2249,7 +2245,7 @@ do_unlock_pi(struct thread *td, struct u
/* 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);
@@ -2265,9 +2261,9 @@ do_unlock_pi(struct thread *td, struct u
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);
More information about the svn-src-stable-10
mailing list