diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-07-30 06:54:05 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-07-30 06:54:05 +0000 |
commit | 8eb7238cade123cbd553b5d57bbb5117f538adbb (patch) | |
tree | 0c83be03d1e2e71dfad7f8b959ebd86dd9b9546f /sys/kern | |
parent | 18acb2ea275ccf40f6db01964cd3438104000486 (diff) | |
download | FreeBSD-src-8eb7238cade123cbd553b5d57bbb5117f538adbb.zip FreeBSD-src-8eb7238cade123cbd553b5d57bbb5117f538adbb.tar.gz |
- Optimize wakeup() and its friends; if a thread waken up is being
swapped in, we do not have to ask for the scheduler thread to do
that.
- Assert that a process is not swapped out in runq functions and
swapout().
- Introduce thread_safetoswapout() for readability.
- In swapout_procs(), perform a test that may block (check of a
thread working on its vm map) first. This lets us call swapout()
with the sched_lock held, providing a better atomicity.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_condvar.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_switch.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 18 |
3 files changed, 22 insertions, 8 deletions
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index 822a4c9..55fba60 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -534,8 +534,10 @@ cv_wakeup(struct cv *cvp) maybe_resched(td); } else { td->td_state = TDS_SWAPPED; - td->td_proc->p_sflag |= PS_SWAPINREQ; - wakeup(&proc0); /* XXXKSE */ + if ((td->td_proc->p_sflag & PS_SWAPPINGIN) == 0) { + td->td_proc->p_sflag |= PS_SWAPINREQ; + wakeup(&proc0); + } } /* END INLINE EXPANSION */ } diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index 9629ac2..97dd771 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -525,6 +525,8 @@ runq_add(struct runq *rq, struct kse *ke) KASSERT(ke->ke_state != KES_ONRUNQ, ("runq_add: kse %p (%s) already in run queue", ke, ke->ke_proc->p_comm)); + KASSERT(ke->ke_proc->p_sflag & PS_INMEM, + ("runq_add: process swapped out")); pri = ke->ke_thread->td_priority / RQ_PPQ; ke->ke_rqindex = pri; runq_setbit(rq, pri); @@ -590,6 +592,8 @@ runq_choose(struct runq *rq) ("runq_choose: No thread on KSE")); KASSERT((ke->ke_thread->td_kse != NULL), ("runq_choose: No KSE on thread")); + KASSERT(ke->ke_proc->p_sflag & PS_INMEM, + ("runq_choose: process swapped out")); return (ke); } CTR1(KTR_RUNQ, "runq_choose: idleproc pri=%d", pri); @@ -610,6 +614,8 @@ runq_remove(struct runq *rq, struct kse *ke) KASSERT((ke->ke_state == KES_ONRUNQ), ("KSE not on run queue")); mtx_assert(&sched_lock, MA_OWNED); + KASSERT(ke->ke_proc->p_sflag & PS_INMEM, + ("runq_remove: process swapped out")); pri = ke->ke_rqindex; rqh = &rq->rq_queues[pri]; CTR4(KTR_RUNQ, "runq_remove: p=%p pri=%d %d rqh=%p", diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index e4bef85..9e60459 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -719,8 +719,10 @@ restart: maybe_resched(td); } else { td->td_state = TDS_SWAPPED; - p->p_sflag |= PS_SWAPINREQ; - wakeup(&proc0); + if ((p->p_sflag & PS_SWAPPINGIN) == 0) { + p->p_sflag |= PS_SWAPINREQ; + wakeup(&proc0); + } } /* END INLINE EXPANSION */ } @@ -766,8 +768,10 @@ restart: break; } else { td->td_state = TDS_SWAPPED; - p->p_sflag |= PS_SWAPINREQ; - wakeup(&proc0); + if ((p->p_sflag & PS_SWAPPINGIN) == 0) { + p->p_sflag |= PS_SWAPINREQ; + wakeup(&proc0); + } } /* END INLINE EXPANSION */ goto restart; @@ -941,8 +945,10 @@ setrunnable(struct thread *td) td->td_ksegrp->kg_slptime = 0; if ((p->p_sflag & PS_INMEM) == 0) { td->td_state = TDS_SWAPPED; - p->p_sflag |= PS_SWAPINREQ; - wakeup(&proc0); + if ((p->p_sflag & PS_SWAPPINGIN) == 0) { + p->p_sflag |= PS_SWAPINREQ; + wakeup(&proc0); + } } else { if (td->td_state != TDS_RUNQ) setrunqueue(td); /* XXXKSE */ |