Module Name: src
Committed By: rmind
Date: Sat May 14 18:50:08 UTC 2011
Modified Files:
src/sys/kern: kern_fork.c
Log Message:
fork1: fix stop-on-fork case, lend a correct lock to LWP for LSSTOP state.
Fixes PR/44935.
To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/kern/kern_fork.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_fork.c
diff -u src/sys/kern/kern_fork.c:1.183 src/sys/kern/kern_fork.c:1.184
--- src/sys/kern/kern_fork.c:1.183 Sun May 1 01:15:18 2011
+++ src/sys/kern/kern_fork.c Sat May 14 18:50:07 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_fork.c,v 1.183 2011/05/01 01:15:18 rmind Exp $ */
+/* $NetBSD: kern_fork.c,v 1.184 2011/05/14 18:50:07 rmind Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.183 2011/05/01 01:15:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.184 2011/05/14 18:50:07 rmind Exp $");
#include "opt_ktrace.h"
@@ -506,12 +506,14 @@
lwp_lock(l2);
KASSERT(p2->p_nrlwps == 1);
if (p2->p_sflag & PS_STOPFORK) {
+ struct schedstate_percpu *spc = &l2->l_cpu->ci_schedstate;
p2->p_nrlwps = 0;
p2->p_stat = SSTOP;
p2->p_waited = 0;
p1->p_nstopchild++;
l2->l_stat = LSSTOP;
- lwp_unlock(l2);
+ KASSERT(l2->l_wchan == NULL);
+ lwp_unlock_to(l2, spc->spc_lwplock);
} else {
p2->p_nrlwps = 1;
p2->p_stat = SACTIVE;
@@ -519,7 +521,6 @@
sched_enqueue(l2, false);
lwp_unlock(l2);
}
-
mutex_exit(p2->p_lock);
/*