diff options
author | jake <jake@FreeBSD.org> | 2000-11-17 18:09:18 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2000-11-17 18:09:18 +0000 |
commit | 3a97b3e213f232a4b939a68fed0d93230f4b2ddb (patch) | |
tree | cac806cc5bcd1867db8a01f555cc5cd41f13cfba /sys | |
parent | 4392ed2ce56049571282c170b18fa4632409955e (diff) | |
download | FreeBSD-src-3a97b3e213f232a4b939a68fed0d93230f4b2ddb.zip FreeBSD-src-3a97b3e213f232a4b939a68fed0d93230f4b2ddb.tar.gz |
- Split the run queue and sleep queue linkage, so that a process
may block on a mutex while on the sleep queue without corrupting
it.
- Move dropping of Giant to after the acquire of sched_lock.
Tested by: John Hay <jhay@icomtek.csir.co.za>
jhb
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/alpha/trap.c | 2 | ||||
-rw-r--r-- | sys/amd64/amd64/trap.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 2 | ||||
-rw-r--r-- | sys/ia64/ia64/trap.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_mutex.c | 1 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_subr.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 18 | ||||
-rw-r--r-- | sys/kern/subr_trap.c | 2 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 1 | ||||
-rw-r--r-- | sys/kern/subr_witness.c | 1 | ||||
-rw-r--r-- | sys/sys/proc.h | 3 |
12 files changed, 22 insertions, 18 deletions
diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index a387910..50a386d 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -120,8 +120,8 @@ userret(p, pc, oticks, have_giant) * indicated by our priority. */ s = splstatclock(); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 21e5e12..fa768ec 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -192,8 +192,8 @@ userret(p, frame, oticks, have_giant) * our priority. */ s = splhigh(); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 21e5e12..fa768ec 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -192,8 +192,8 @@ userret(p, frame, oticks, have_giant) * our priority. */ s = splhigh(); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index f519543..64f7752 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -102,8 +102,8 @@ userret(register struct proc *p, u_int64_t pc, u_quad_t oticks, int have_giant) * indicated by our priority. */ s = splstatclock(); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 354ff91..58a98d1 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -718,6 +718,7 @@ static char *dup_list[] = { }; static char *sleep_list[] = { + "Giant", NULL }; diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index dcc0ed3..a49964e 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1283,8 +1283,8 @@ issignal(p) psignal(p->p_pptr, SIGCHLD); do { stop(p); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); mi_switch(); mtx_exit(&sched_lock, MTX_SPIN); PICKUP_GIANT(); @@ -1356,8 +1356,8 @@ issignal(p) stop(p); if ((p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) == 0) psignal(p->p_pptr, SIGCHLD); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); mi_switch(); mtx_exit(&sched_lock, MTX_SPIN); PICKUP_GIANT(); diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 429f34b..c379f79 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -377,8 +377,8 @@ uio_yield() p = curproc; s = splhigh(); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); p->p_priority = p->p_usrpri; setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 13b5707..972b682 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -420,9 +420,9 @@ msleep(ident, mtx, priority, wmesg, timo) if (p && KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 1, 0); #endif - DROP_GIANT_NOSWITCH(); WITNESS_SLEEP(0, mtx); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); if (mtx != NULL) { mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); @@ -461,7 +461,7 @@ msleep(ident, mtx, priority, wmesg, timo) p->p_nativepri = p->p_priority; CTR4(KTR_PROC, "msleep: proc %p (pid %d, %s), schedlock %p", p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); - TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_procq); + TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq); if (timo) thandle = timeout(endtsleep, (void *)p, timo); /* @@ -583,7 +583,7 @@ asleep(void *ident, int priority, const char *wmesg, int timo) p->p_slptime = 0; p->p_asleep.as_priority = priority; p->p_asleep.as_timo = timo; - TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_procq); + TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq); } mtx_exit(&sched_lock, MTX_SPIN); @@ -612,9 +612,9 @@ mawait(struct mtx *mtx, int priority, int timo) int s; WITNESS_SAVE_DECL(mtx); - DROP_GIANT_NOSWITCH(); WITNESS_SLEEP(0, mtx); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); if (mtx != NULL) { mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); WITNESS_SAVE(mtx, mtx); @@ -778,7 +778,7 @@ unsleep(p) s = splhigh(); mtx_enter(&sched_lock, MTX_SPIN); if (p->p_wchan) { - TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_procq); + TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_slpq); p->p_wchan = 0; } mtx_exit(&sched_lock, MTX_SPIN); @@ -800,9 +800,9 @@ wakeup(ident) mtx_enter(&sched_lock, MTX_SPIN); qp = &slpque[LOOKUP(ident)]; restart: - TAILQ_FOREACH(p, qp, p_procq) { + TAILQ_FOREACH(p, qp, p_slpq) { if (p->p_wchan == ident) { - TAILQ_REMOVE(qp, p, p_procq); + TAILQ_REMOVE(qp, p, p_slpq); p->p_wchan = 0; if (p->p_stat == SSLEEP) { /* OPTIMIZED EXPANSION OF setrunnable(p); */ @@ -846,9 +846,9 @@ wakeup_one(ident) mtx_enter(&sched_lock, MTX_SPIN); qp = &slpque[LOOKUP(ident)]; - TAILQ_FOREACH(p, qp, p_procq) { + TAILQ_FOREACH(p, qp, p_slpq) { if (p->p_wchan == ident) { - TAILQ_REMOVE(qp, p, p_procq); + TAILQ_REMOVE(qp, p, p_slpq); p->p_wchan = 0; if (p->p_stat == SSLEEP) { /* OPTIMIZED EXPANSION OF setrunnable(p); */ diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 21e5e12..fa768ec 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -192,8 +192,8 @@ userret(p, frame, oticks, have_giant) * our priority. */ s = splhigh(); - DROP_GIANT_NOSWITCH(); mtx_enter(&sched_lock, MTX_SPIN); + DROP_GIANT_NOSWITCH(); setrunqueue(p); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 354ff91..58a98d1 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -718,6 +718,7 @@ static char *dup_list[] = { }; static char *sleep_list[] = { + "Giant", NULL }; diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 354ff91..58a98d1 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -718,6 +718,7 @@ static char *dup_list[] = { }; static char *sleep_list[] = { + "Giant", NULL }; diff --git a/sys/sys/proc.h b/sys/sys/proc.h index af24b30..6534f90 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -127,7 +127,8 @@ struct mtx; struct ithd; struct proc { - TAILQ_ENTRY(proc) p_procq; /* run/sleep queue. */ + TAILQ_ENTRY(proc) p_procq; /* run/mutex queue. */ + TAILQ_ENTRY(proc) p_slpq; /* sleep queue. */ LIST_ENTRY(proc) p_list; /* List of all processes. */ /* substructures: */ |