Date: Sat, 28 Mar 2015 21:21:40 +0000 (UTC) From: Eric van Gyzen <vangyzen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280792 - head/sys/kern Message-ID: <201503282121.t2SLLeW8067873@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: vangyzen Date: Sat Mar 28 21:21:40 2015 New Revision: 280792 URL: https://svnweb.freebsd.org/changeset/base/280792 Log: 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 Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Sat Mar 28 19:59:33 2015 (r280791) +++ head/sys/kern/kern_umtx.c Sat Mar 28 21:21:40 2015 (r280792) @@ -912,7 +912,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); @@ -1440,7 +1440,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); } @@ -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 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); @@ -1884,7 +1880,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); @@ -1900,9 +1896,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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503282121.t2SLLeW8067873>