summaryrefslogtreecommitdiffstats
path: root/sys/miscfs
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/miscfs
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/miscfs')
-rw-r--r--sys/miscfs/procfs/procfs_ctl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/miscfs/procfs/procfs_ctl.c b/sys/miscfs/procfs/procfs_ctl.c
index c38270f3c33..7a1c92b0bb3 100644
--- a/sys/miscfs/procfs/procfs_ctl.c
+++ b/sys/miscfs/procfs/procfs_ctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_ctl.c,v 1.13 2004/05/20 18:32:38 tedu Exp $ */
+/* $OpenBSD: procfs_ctl.c,v 1.14 2005/05/25 23:17:47 niklas Exp $ */
/* $NetBSD: procfs_ctl.c,v 1.14 1996/02/09 22:40:48 christos Exp $ */
/*
@@ -48,6 +48,7 @@
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/ptrace.h>
+#include <sys/sched.h>
#include <miscfs/procfs/procfs.h>
/*
@@ -110,6 +111,7 @@ procfs_control(curp, p, op)
int op;
{
int error;
+ int s;
/*
* Attach - attaches the target process for debugging
@@ -248,8 +250,10 @@ procfs_control(curp, p, op)
#endif
}
+ SCHED_LOCK(s);
if (p->p_stat == SSTOP)
setrunnable(p);
+ SCHED_UNLOCK(s);
return (0);
}
#endif
@@ -265,6 +269,7 @@ procfs_doctl(curp, p, pfs, uio)
int error;
char msg[PROCFS_CTLLEN+1];
const vfs_namemap_t *nm;
+ int s;
if (uio->uio_rw != UIO_WRITE)
return (EOPNOTSUPP);
@@ -297,7 +302,9 @@ procfs_doctl(curp, p, pfs, uio)
if (TRACE_WAIT_P(curp, p)) {
p->p_xstat = nm->nm_val;
FIX_SSTEP(p);
+ SCHED_LOCK(s);
setrunnable(p);
+ SCHED_UNLOCK(s);
} else {
psignal(p, nm->nm_val);
}