Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jul 2009 16:41:18 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 165707 for review
Message-ID:  <200907061641.n66GfIaC077945@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165707

Change 165707 by trasz@trasz_victim on 2009/07/06 16:40:29

	Clean up maxprocesses accounting.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#7 edit

Differences ...

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#7 (text+ko) ====

@@ -224,6 +224,10 @@
 
 	p1 = td->td_proc;
 
+	error = hrl_alloc_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1);
+	if (error)
+		return (error);
+
 	/*
 	 * Here we don't create a new process, but we divorce
 	 * certain parts of a process from itself.
@@ -234,6 +238,7 @@
 			PROC_LOCK(p1);
 			if (thread_single(SINGLE_BOUNDARY)) {
 				PROC_UNLOCK(p1);
+				hrl_free_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1);
 				return (ERESTART);
 			}
 			PROC_UNLOCK(p1);
@@ -267,6 +272,8 @@
 			PROC_UNLOCK(p1);
 		}
 		*procp = NULL;
+		if (error)
+			hrl_free_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1);
 		return (error);
 	}
 
@@ -346,18 +353,14 @@
 	 * XXXRW: Can we avoid privilege here if it's not needed?
 	 */
 	error = priv_check_cred(td->td_ucred, PRIV_PROC_LIMIT, 0);
-	if (error == 0) {
+	if (error == 0)
 		ok = chgproccnt(td->td_ucred->cr_ruidinfo, 1, 0);
-		error = hrl_alloc_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1);
-	} else {
+	else {
 		PROC_LOCK(p1);
 		ok = chgproccnt(td->td_ucred->cr_ruidinfo, 1,
 		    lim_cur(p1, RLIMIT_NPROC));
-		error = hrl_alloc_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1);
 		PROC_UNLOCK(p1);
 	}
-	if (ok != !error)
-		printf("fork1: ok = %d, error = %d\n", ok, error);
 	if (!ok) {
 		error = EAGAIN;
 		goto fail;
@@ -584,12 +587,6 @@
 	PROC_UNLOCK(p1);
 	PROC_UNLOCK(p2);
 
-	/*
-	 * Initialize HRL accounting information.
-	 * XXX: Handle failure?
-	 */
-	hrl_proc_fork(p1, p2);
-
 	/* Bump references to the text vnode (for procfs) */
 	if (p2->p_textvp)
 		vref(p2->p_textvp);
@@ -808,6 +805,7 @@
 		vmspace_free(vm2);
 	uma_zfree(proc_zone, newproc);
 	pause("fork", hz / 2);
+	hrl_free_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1);
 	return (error);
 }
 



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