diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2014-07-13 21:44:59 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2014-07-13 21:44:59 +0000 |
commit | 809a8365f1adffd47300b1f3762210e144f00b92 (patch) | |
tree | 80defc0f6dd4a704a53480d27bba1c1c618a95dc /sys/kern | |
parent | f2d720f47784b837b12c3073c022a9d3076bc2ff (diff) |
Fix sched_stop_secondary_cpus() to properly drain CPUs
TAILQ_FOREACH() isn't safe to use in sched_chooseproc() to iterate
over the run queues because within the loop body we remove the threads
from their run queues and reinsert them elsewhere. As a result, we
end up only draining the first thread of each run queue rather than
all of them.
ok kettenis
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_sched.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 32e8527d3d0..671772617a3 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.32 2014/05/04 05:03:26 guenther Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.33 2014/07/13 21:44:58 matthew Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org> * @@ -272,7 +272,7 @@ sched_chooseproc(void) if (spc->spc_schedflags & SPCF_SHOULDHALT) { if (spc->spc_whichqs) { for (queue = 0; queue < SCHED_NQS; queue++) { - TAILQ_FOREACH(p, &spc->spc_qs[queue], p_runq) { + while ((p = TAILQ_FIRST(&spc->spc_qs[queue]))) { remrunqueue(p); p->p_cpu = sched_choosecpu(p); setrunqueue(p); |