Fix LOR of thread lock and umtx's priority propagation mutex due

to the reworking of scheduler lock.

MFC: after 3 days
This commit is contained in:
David Xu 2007-12-11 08:25:36 +00:00
parent 6a663207e7
commit 435806d31b
3 changed files with 17 additions and 17 deletions

View File

@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/time.h>
#include <sys/umtx.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@ -482,6 +483,7 @@ int
rtp_to_pri(struct rtprio *rtp, struct thread *td)
{
u_char newpri;
u_char oldpri;
if (rtp->prio > RTP_PRIO_MAX)
return (EINVAL);
@ -501,10 +503,15 @@ rtp_to_pri(struct rtprio *rtp, struct thread *td)
return (EINVAL);
}
sched_class(td, rtp->type); /* XXX fix */
oldpri = td->td_user_pri;
sched_user_prio(td, newpri);
if (curthread == td)
sched_prio(curthread, td->td_user_pri); /* XXX dubious */
thread_unlock(td);
if (TD_ON_UPILOCK(td) && oldpri != newpri) {
thread_unlock(td);
umtx_pi_adjust(td, oldpri);
} else
thread_unlock(td);
return (0);
}

View File

@ -762,14 +762,12 @@ sched_user_prio(struct thread *td, u_char prio)
{
u_char oldprio;
THREAD_LOCK_ASSERT(td, MA_OWNED);
td->td_base_user_pri = prio;
if (td->td_flags & TDF_UBORROWING && td->td_user_pri <= prio)
return;
oldprio = td->td_user_pri;
td->td_user_pri = prio;
if (TD_ON_UPILOCK(td) && oldprio != prio)
umtx_pi_adjust(td, oldprio);
}
void
@ -777,13 +775,10 @@ sched_lend_user_prio(struct thread *td, u_char prio)
{
u_char oldprio;
THREAD_LOCK_ASSERT(td, MA_OWNED);
td->td_flags |= TDF_UBORROWING;
oldprio = td->td_user_pri;
td->td_user_pri = prio;
if (TD_ON_UPILOCK(td) && oldprio != prio)
umtx_pi_adjust(td, oldprio);
}
void
@ -791,12 +786,14 @@ sched_unlend_user_prio(struct thread *td, u_char prio)
{
u_char base_pri;
THREAD_LOCK_ASSERT(td, MA_OWNED);
base_pri = td->td_base_user_pri;
if (prio >= base_pri) {
td->td_flags &= ~TDF_UBORROWING;
sched_user_prio(td, base_pri);
} else
} else {
sched_lend_user_prio(td, prio);
}
}
void

View File

@ -1709,9 +1709,6 @@ sched_user_prio(struct thread *td, u_char prio)
return;
oldprio = td->td_user_pri;
td->td_user_pri = prio;
if (TD_ON_UPILOCK(td) && oldprio != prio)
umtx_pi_adjust(td, oldprio);
}
void
@ -1719,13 +1716,10 @@ sched_lend_user_prio(struct thread *td, u_char prio)
{
u_char oldprio;
THREAD_LOCK_ASSERT(td, MA_OWNED);
td->td_flags |= TDF_UBORROWING;
oldprio = td->td_user_pri;
td->td_user_pri = prio;
if (TD_ON_UPILOCK(td) && oldprio != prio)
umtx_pi_adjust(td, oldprio);
}
void
@ -1733,12 +1727,14 @@ sched_unlend_user_prio(struct thread *td, u_char prio)
{
u_char base_pri;
THREAD_LOCK_ASSERT(td, MA_OWNED);
base_pri = td->td_base_user_pri;
if (prio >= base_pri) {
td->td_flags &= ~TDF_UBORROWING;
sched_user_prio(td, base_pri);
} else
} else {
sched_lend_user_prio(td, prio);
}
}
/*