Module Name: src
Committed By: rmind
Date: Sat Mar 28 21:38:56 UTC 2009
Modified Files:
src/sys/kern: kern_exit.c
Log Message:
- proc_free(): no need assign 'p->p_pptr' to 'parent' many times,
re-use it where appropriate (proc_lock is held across usages).
- Undefine DEBUG_EXIT.
To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/sys/kern/kern_exit.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_exit.c
diff -u src/sys/kern/kern_exit.c:1.218 src/sys/kern/kern_exit.c:1.219
--- src/sys/kern/kern_exit.c:1.218 Thu Jan 22 14:38:35 2009
+++ src/sys/kern/kern_exit.c Sat Mar 28 21:38:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exit.c,v 1.218 2009/01/22 14:38:35 yamt Exp $ */
+/* $NetBSD: kern_exit.c,v 1.219 2009/03/28 21:38:55 rmind Exp $ */
/*-
* Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.218 2009/01/22 14:38:35 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.219 2009/03/28 21:38:55 rmind Exp $");
#include "opt_ktrace.h"
#include "opt_perfctrs.h"
@@ -112,8 +112,6 @@
#include <uvm/uvm_extern.h>
-#define DEBUG_EXIT
-
#ifdef DEBUG_EXIT
int debug_exit = 0;
#define DPRINTF(x) if (debug_exit) printf x
@@ -856,7 +854,7 @@
static void
proc_free(struct proc *p, struct rusage *ru)
{
- struct proc *parent;
+ struct proc *parent = p->p_pptr;
struct lwp *l;
ksiginfo_t ksi;
kauth_cred_t cred1, cred2;
@@ -876,25 +874,20 @@
* parent the exit signal. The rest of the cleanup
* will be done when the old parent waits on the child.
*/
- if ((p->p_slflag & PSL_TRACED) != 0) {
- parent = p->p_pptr;
- if (p->p_opptr != parent){
- mutex_enter(p->p_lock);
- p->p_slflag &= ~(PSL_TRACED|PSL_FSTRACE|PSL_SYSCALL);
- mutex_exit(p->p_lock);
- parent = p->p_opptr;
- if (parent == NULL)
- parent = initproc;
- proc_reparent(p, parent);
- p->p_opptr = NULL;
- if (p->p_exitsig != 0) {
- exit_psignal(p, parent, &ksi);
- kpsignal(parent, &ksi, NULL);
- }
- cv_broadcast(&parent->p_waitcv);
- mutex_exit(proc_lock);
- return;
+ if ((p->p_slflag & PSL_TRACED) != 0 && p->p_opptr != parent) {
+ mutex_enter(p->p_lock);
+ p->p_slflag &= ~(PSL_TRACED|PSL_FSTRACE|PSL_SYSCALL);
+ mutex_exit(p->p_lock);
+ parent = (p->p_opptr == NULL) ? initproc : p->p_opptr;
+ proc_reparent(p, parent);
+ p->p_opptr = NULL;
+ if (p->p_exitsig != 0) {
+ exit_psignal(p, parent, &ksi);
+ kpsignal(parent, &ksi, NULL);
}
+ cv_broadcast(&parent->p_waitcv);
+ mutex_exit(proc_lock);
+ return;
}
/*
@@ -903,7 +896,6 @@
*/
leavepgrp(p);
- parent = p->p_pptr;
sched_proc_exit(parent, p);
/*
@@ -934,8 +926,7 @@
*/
p->p_stat = SIDL; /* not even a zombie any more */
LIST_REMOVE(p, p_list); /* off zombproc */
- parent = p->p_pptr;
- p->p_pptr->p_nstopchild--;
+ parent->p_nstopchild--;
LIST_REMOVE(p, p_sibling);
/*