From acfce18a2af057f945e45381ea2bc73622629c39 Mon Sep 17 00:00:00 2001 From: ups Date: Mon, 23 May 2005 23:01:53 +0000 Subject: Use low level constructs borrowed from interrupt threads to wait for work in proc0. Remove the TDP_WAKEPROC0 workaround. --- sys/vm/vm_glue.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'sys/vm/vm_glue.c') diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 6122ea2..9deb363 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -113,6 +113,10 @@ SYSINIT(scheduler, SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY, scheduler, NULL) static void swapout(struct proc *); #endif + +static volatile int proc0_rescan; + + /* * MPSAFE * @@ -596,6 +600,9 @@ scheduler(dummy) loop: if (vm_page_count_min()) { VM_WAIT; + mtx_lock_spin(&sched_lock); + proc0_rescan = 0; + mtx_unlock_spin(&sched_lock); goto loop; } @@ -641,7 +648,13 @@ loop: * Nothing to do, back to sleep. */ if ((p = pp) == NULL) { - tsleep(&proc0, PVM, "sched", maxslp * hz / 2); + mtx_lock_spin(&sched_lock); + if (!proc0_rescan) { + TD_SET_IWAIT(&thread0); + mi_switch(SW_VOL, NULL); + } + proc0_rescan = 0; + mtx_unlock_spin(&sched_lock); goto loop; } PROC_LOCK(p); @@ -653,6 +666,9 @@ loop: */ if (p->p_sflag & (PS_INMEM | PS_SWAPPINGOUT | PS_SWAPPINGIN)) { PROC_UNLOCK(p); + mtx_lock_spin(&sched_lock); + proc0_rescan = 0; + mtx_unlock_spin(&sched_lock); goto loop; } @@ -668,10 +684,29 @@ loop: PROC_UNLOCK(p); mtx_lock_spin(&sched_lock); p->p_swtime = 0; + proc0_rescan = 0; mtx_unlock_spin(&sched_lock); goto loop; } +void kick_proc0(void) +{ + struct thread *td = &thread0; + + + if (TD_AWAITING_INTR(td)) { + CTR2(KTR_INTR, "%s: setrunqueue %d", __func__, 0); + TD_CLR_IWAIT(td); + setrunqueue(td, SRQ_INTR); + } else { + proc0_rescan = 1; + CTR2(KTR_INTR, "%s: state %d", + __func__, td->td_state); + } + +} + + #ifndef NO_SWAPPING /* -- cgit v1.1