Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Sep 2011 08:08:24 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r225364 - head/sys/kern
Message-ID:  <201109030808.p8388O67036227@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sat Sep  3 08:08:24 2011
New Revision: 225364
URL: http://svn.freebsd.org/changeset/base/225364

Log:
  Fix panic that happens when fork(2) fails due to a limit other than
  the rctl one - for example, it happens when someone reaches maximum
  number of processes in the system.
  
  Approved by:	re (kib)

Modified:
  head/sys/kern/kern_racct.c

Modified: head/sys/kern/kern_racct.c
==============================================================================
--- head/sys/kern/kern_racct.c	Sat Sep  3 08:03:25 2011	(r225363)
+++ head/sys/kern/kern_racct.c	Sat Sep  3 08:08:24 2011	(r225364)
@@ -605,6 +605,7 @@ out:
 void
 racct_proc_exit(struct proc *p)
 {
+	int i;
 	uint64_t runtime;
 
 	PROC_LOCK(p);
@@ -618,14 +619,18 @@ racct_proc_exit(struct proc *p)
 	if (runtime < p->p_prev_runtime)
 		runtime = p->p_prev_runtime;
 #endif
-	racct_set(p, RACCT_CPU, runtime);
+	mtx_lock(&racct_lock);
+	racct_set_locked(p, RACCT_CPU, runtime);
 
-	/*
-	 * XXX: Free this some other way.
-	 */
-	racct_set(p, RACCT_NPTS, 0);
-	racct_set(p, RACCT_NTHR, 0);
-	racct_set(p, RACCT_RSS, 0);
+	for (i = 0; i <= RACCT_MAX; i++) {
+		if (p->p_racct->r_resources[i] == 0)
+			continue;
+	    	if (!RACCT_IS_RECLAIMABLE(i))
+			continue;
+		racct_set_locked(p, i, 0);
+	}
+
+	mtx_unlock(&racct_lock);
 	PROC_UNLOCK(p);
 
 #ifdef RCTL



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