diff options
author | 2019-11-02 05:31:20 +0000 | |
---|---|---|
committer | 2019-11-02 05:31:20 +0000 | |
commit | dfa1de3e618fc84112edc97684a632dc38416c64 (patch) | |
tree | 6adbc7d6d7e6b3ff2876fc3e63b6f09aac9440f2 /sys/kern/kern_sched.c | |
parent | switch ASN1_STRING_data() with constified ASN1_STRING_get0_data() (diff) | |
download | wireguard-openbsd-dfa1de3e618fc84112edc97684a632dc38416c64.tar.xz wireguard-openbsd-dfa1de3e618fc84112edc97684a632dc38416c64.zip |
Move dead procs to the reaper queue immediately after context switch.
This eliminates a forced context switch to the idle proc. In addition,
sched_exit() no longer needs to sum proc runtime because mi_switch()
will do it.
OK mpi@ a while ago
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r-- | sys/kern/kern_sched.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index a32dbba110d..94ebd833ab1 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.60 2019/11/01 20:58:01 mpi Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.61 2019/11/02 05:31:20 visa Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org> * @@ -159,17 +159,10 @@ sched_idle(void *v) while (1) { while (!cpu_is_idle(curcpu())) { - struct proc *dead; - SCHED_LOCK(s); p->p_stat = SSLEEP; mi_switch(); SCHED_UNLOCK(s); - - while ((dead = LIST_FIRST(&spc->spc_deadproc))) { - LIST_REMOVE(dead, p_hash); - exit2(dead); - } } splassert(IPL_NONE); @@ -204,7 +197,7 @@ sched_idle(void *v) * and waking up the reaper without risking having our address space and * stack torn from under us before we manage to switch to another proc. * Therefore we have a per-cpu list of dead processes where we put this - * proc and have idle clean up that list and move it to the reaper list. + * proc. We move the list to the reaper list after context switch. * All this will be unnecessary once we can bind the reaper this cpu * and not risk having it switch to another in case it sleeps. */ @@ -212,14 +205,8 @@ void sched_exit(struct proc *p) { struct schedstate_percpu *spc = &curcpu()->ci_schedstate; - struct timespec ts; - struct proc *idle; int s; - nanouptime(&ts); - timespecsub(&ts, &spc->spc_runtime, &ts); - timespecadd(&p->p_rtime, &ts, &p->p_rtime); - LIST_INSERT_HEAD(&spc->spc_deadproc, p, p_hash); #ifdef MULTIPROCESSOR @@ -229,10 +216,8 @@ sched_exit(struct proc *p) #endif SCHED_LOCK(s); - idle = spc->spc_idleproc; - idle->p_stat = SRUN; - cpu_switchto(NULL, idle); - panic("cpu_switchto returned"); + mi_switch(); + panic("mi_switch returned"); } /* |