summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorniklas <niklas@openbsd.org>2005-05-25 23:17:47 +0000
committerniklas <niklas@openbsd.org>2005-05-25 23:17:47 +0000
commit51e884f5097bd82bb2785d036ae66e1531f468d2 (patch)
tree5ca09db806340d65527cf9a3f83000f9d4656ec2 /sys/kern/kern_fork.c
parentMention isearch wrap (diff)
downloadwireguard-openbsd-51e884f5097bd82bb2785d036ae66e1531f468d2.tar.xz
wireguard-openbsd-51e884f5097bd82bb2785d036ae66e1531f468d2.zip
This patch is mortly art's work and was done *a year* ago. Art wants to thank
everyone for the prompt review and ok of this work ;-) Yeah, that includes me too, or maybe especially me. I am sorry. Change the sched_lock to a mutex. This fixes, among other things, the infamous "telnet localhost &" problem. The real bug in that case was that the sched_lock which is by design a non-recursive lock, was recursively acquired, and not enough releases made us hold the lock in the idle loop, blocking scheduling on the other processors. Some of the other processors would hold the biglock though, which made it impossible for cpu 0 to enter the kernel... A nice deadlock. Let me just say debugging this for days just to realize that it was all fixed in an old diff noone ever ok'd was somewhat of an anti-climax. This diff also changes splsched to be correct for all our architectures.
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index ed404db4a0c..05ba79f3399 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.74 2005/02/24 04:44:25 tedu Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.75 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -341,9 +341,9 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize,
/*
* Make child runnable, set start time, and add to run queue.
*/
- SCHED_LOCK(s);
getmicrotime(&p2->p_stats->p_start);
p2->p_acflag = AFORK;
+ SCHED_LOCK(s);
p2->p_stat = SRUN;
setrunqueue(p2);
SCHED_UNLOCK(s);