Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 May 2001 23:27:04 +0100
From:      David Malone <dwmalone@maths.tcd.ie>
To:        Matt Dillon <dillon@earth.backplane.com>
Cc:        John Baldwin <jhb@FreeBSD.org>, hackers@FreeBSD.org, "Brian F. Feldman" <green@FreeBSD.org>
Subject:   Re: RE: vmspace leak (+ tentative fix)
Message-ID:  <20010521232704.A64450@walton.maths.tcd.ie>
In-Reply-To: <200105211935.f4LJZHx05386@earth.backplane.com>; from dillon@earth.backplane.com on Mon, May 21, 2001 at 12:35:17PM -0700
References:  <XFMail.010521122251.jhb@FreeBSD.org> <200105211935.f4LJZHx05386@earth.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 21, 2001 at 12:35:17PM -0700, Matt Dillon wrote:

>     It's important to release resources as early as possible, so zombied
>     processes don't run the machine out of memory if a parent forgets to
>     reap its children.

I've found one other reason for releasing resources early. For
example the vrele of a zombie process' text vnode is done by the
process which reaps that zombie. If you can make the vrele block
then the parent will block.

I've seen this happen with NFS bugs, where init has got stuck in
a "vmopar" and ended up blocking forever. The machine runs out of
processes relatively quickly once init can't clear up zombies. 

I've been using the following patch at home, which moves the
vrele from wait in the parent to exit in the child. I wonder
if it is worth committing? (The clearing of p_textvp is to
stop ps and friends tripping up over a half free vnode - I'm
not sure if it is necessary).

	David.


Index: kern_exit.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/kern/kern_exit.c,v
retrieving revision 1.127
diff -u -r1.127 kern_exit.c
--- kern_exit.c	2001/05/19 01:28:02	1.127
+++ kern_exit.c	2001/05/20 11:03:55
@@ -279,6 +279,15 @@
 		vrele(p->p_tracep);
 #endif
 	/*
+	 * Release reference to text vnode
+	 */
+	if (p->p_textvp) {
+		struct  vnode *vp = p->p_textvp;
+		p->p_textvp = NULL;
+		vrele(vp);
+	}
+
+	/*
 	 * Remove proc from allproc queue and pidhash chain.
 	 * Place onto zombproc.  Unlink from parent's child list.
 	 */
@@ -517,12 +526,6 @@
 			 * Decrement the count of procs running with this uid.
 			 */
 			(void)chgproccnt(p->p_cred->p_uidinfo, -1, 0);
-
-			/*
-			 * Release reference to text vnode
-			 */
-			if (p->p_textvp)
-				vrele(p->p_textvp);
 
 			/*
 			 * Finally finished with old proc entry.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010521232704.A64450>