diff options
author | davidxu <davidxu@FreeBSD.org> | 2007-12-17 05:55:07 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2007-12-17 05:55:07 +0000 |
commit | 747bbe486b9f221347134dcf2ed813f745239d4f (patch) | |
tree | 70cf5743d46bb4c967a89c952579b1257640a8c9 /sys/kern/kern_umtx.c | |
parent | f3f1d0b3a58a334b944a9ca62dac1948a4392ce3 (diff) | |
download | FreeBSD-src-747bbe486b9f221347134dcf2ed813f745239d4f.zip FreeBSD-src-747bbe486b9f221347134dcf2ed813f745239d4f.tar.gz |
Add missing changes for fixing LOR of umtx lock and thread lock, follow
the committing of files:
kern_resource.c revision 1.181
sched_4bsd.c revision 1.111
sched_ule.c revision 1.218
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r-- | sys/kern/kern_umtx.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 5f572be..0857366d 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -212,6 +212,7 @@ static int umtx_key_get(void *addr, int type, int share, static void umtx_key_release(struct umtx_key *key); static struct umtx_pi *umtx_pi_alloc(int); static void umtx_pi_free(struct umtx_pi *pi); +static void umtx_pi_adjust_locked(struct thread *td, u_char oldpri); static int do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags); static void umtx_thread_cleanup(struct thread *td); static void umtx_exec_hook(void *arg __unused, struct proc *p __unused, @@ -1294,7 +1295,7 @@ umtx_unpropagate_priority(struct umtx_pi *pi) { struct umtx_q *uq, *uq_owner; struct umtx_pi *pi2; - int pri; + int pri, oldpri; mtx_assert(&umtx_lock, MA_OWNED); @@ -1313,8 +1314,10 @@ umtx_unpropagate_priority(struct umtx_pi *pi) if (pri > uq_owner->uq_inherited_pri) pri = uq_owner->uq_inherited_pri; thread_lock(pi->pi_owner); + oldpri = pi->pi_owner->td_user_pri; sched_unlend_user_prio(pi->pi_owner, pri); thread_unlock(pi->pi_owner); + umtx_pi_adjust_locked(pi->pi_owner, oldpri); pi = uq_owner->uq_pi_blocked; } } @@ -1372,21 +1375,13 @@ umtx_pi_claim(struct umtx_pi *pi, struct thread *owner) return (0); } -/* - * Adjust a thread's order position in its blocked PI mutex, - * this may result new priority propagating process. - */ -void -umtx_pi_adjust(struct thread *td, u_char oldpri) +static void +umtx_pi_adjust_locked(struct thread *td, u_char oldpri) { struct umtx_q *uq; struct umtx_pi *pi; uq = td->td_umtxq; - - mtx_assert(&umtx_lock, MA_OWNED); - MPASS(TD_ON_UPILOCK(td)); - /* * Pick up the lock that td is blocked on. */ @@ -1406,6 +1401,18 @@ umtx_pi_adjust(struct thread *td, u_char oldpri) } /* + * Adjust a thread's order position in its blocked PI mutex, + * this may result new priority propagating process. + */ +void +umtx_pi_adjust(struct thread *td, u_char oldpri) +{ + mtx_lock_spin(&umtx_lock); + umtx_pi_adjust_locked(td, oldpri); + mtx_unlock_spin(&umtx_lock); +} + +/* * Sleep on a PI mutex. */ static int @@ -1457,7 +1464,9 @@ umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, TAILQ_INSERT_TAIL(&pi->pi_blocked, uq, uq_lockq); uq->uq_pi_blocked = pi; + thread_lock(td); td->td_flags |= TDF_UPIBLOCKED; + thread_unlock(td); mtx_unlock_spin(&umtx_lock); umtxq_unlock(&uq->uq_key); @@ -1480,7 +1489,9 @@ umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, mtx_lock_spin(&umtx_lock); uq->uq_pi_blocked = NULL; + thread_lock(td); td->td_flags &= ~TDF_UPIBLOCKED; + thread_unlock(td); TAILQ_REMOVE(&pi->pi_blocked, uq, uq_lockq); umtx_unpropagate_priority(pi); mtx_unlock_spin(&umtx_lock); @@ -2728,6 +2739,8 @@ umtx_thread_cleanup(struct thread *td) pi->pi_owner = NULL; TAILQ_REMOVE(&uq->uq_pi_contested, pi, pi_link); } + thread_lock(td); td->td_flags &= ~TDF_UBORROWING; + thread_unlock(td); mtx_unlock_spin(&umtx_lock); } |