PERFORCE change 119631 for review
John Baldwin
jhb at FreeBSD.org
Thu May 10 15:28:24 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=119631
Change 119631 by jhb at jhb_mutex on 2007/05/10 15:28:19
Move cpu_exit() sooner. There's no need to make this happen
this late (most of them are nops, the others all deal with
stuff that only affects userland). Moving it allows us to avoid
dropping the proc lock and parent proc lock after notifying other
processes of our exit via kevent(2) or SIGCHLD but before setting
PRS_ZOMBIE. As a result, if the other process tried to do a
waitpid(W_NOHANG) during that window, it wouldn't see the process
as a zombie yet and would fail.
Affected files ...
.. //depot/projects/smpng/sys/kern/kern_exit.c#122 edit
Differences ...
==== //depot/projects/smpng/sys/kern/kern_exit.c#122 (text+ko) ====
@@ -406,6 +406,16 @@
sx_xunlock(&allproc_lock);
/*
+ * Call machine-dependent code to release any
+ * machine-dependent resources other than the address space.
+ * The address space is released by "vmspace_exitfree(p)" in
+ * vm_waitproc().
+ */
+ cpu_exit(td);
+
+ WITNESS_WARN(WARN_PANIC, NULL, "process (pid %d) exiting", p->p_pid);
+
+ /*
* Reparent all of our children to init.
*/
sx_xlock(&proctree_lock);
@@ -484,22 +494,6 @@
else /* LINUX thread */
psignal(p->p_pptr, p->p_sigparent);
}
- PROC_UNLOCK(p->p_pptr);
- PROC_UNLOCK(p);
-
- /*
- * Finally, call machine-dependent code to release the remaining
- * resources including address space.
- * The address space is released by "vmspace_exitfree(p)" in
- * vm_waitproc().
- */
- cpu_exit(td);
-
- WITNESS_WARN(WARN_PANIC, &proctree_lock.lock_object,
- "process (pid %d) exiting", p->p_pid);
-
- PROC_LOCK(p);
- PROC_LOCK(p->p_pptr);
sx_xunlock(&proctree_lock);
/*
More information about the p4-projects
mailing list