summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2011-07-06 20:06:44 +0000
committertrasz <trasz@FreeBSD.org>2011-07-06 20:06:44 +0000
commit4a17b24427e55ec7e1862b08a0a9247f0717d010 (patch)
tree443d8da9aef22fdf042ab6f2cf16f5e2d4f04bd3 /sys/kern/kern_fork.c
parent1adac93bc0e2f40ac5d98734f9451cb1a0f42124 (diff)
downloadFreeBSD-src-4a17b24427e55ec7e1862b08a0a9247f0717d010.zip
FreeBSD-src-4a17b24427e55ec7e1862b08a0a9247f0717d010.tar.gz
All the racct_*() calls need to happen with the proc locked. Fixing this
won't happen before 9.0. This commit adds "#ifdef RACCT" around all the "PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p)" instances, in order to avoid useless locking/unlocking in kernels built without "options RACCT".
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 04e635a..a8abd8e 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -734,11 +734,13 @@ fork1(struct thread *td, int flags, int pages, struct proc **procp)
return (fork_norfproc(td, flags));
}
+#ifdef RACCT
PROC_LOCK(p1);
error = racct_add(p1, RACCT_NPROC, 1);
PROC_UNLOCK(p1);
if (error != 0)
return (EAGAIN);
+#endif
mem_charged = 0;
vm2 = NULL;
@@ -822,6 +824,7 @@ fork1(struct thread *td, int flags, int pages, struct proc **procp)
goto fail;
}
+#ifdef RACCT
/*
* After fork, there is exactly one thread running.
*/
@@ -832,6 +835,7 @@ fork1(struct thread *td, int flags, int pages, struct proc **procp)
error = EAGAIN;
goto fail;
}
+#endif
/*
* Increment the count of procs running with this uid. Don't allow
@@ -874,9 +878,11 @@ fail1:
vmspace_free(vm2);
uma_zfree(proc_zone, newproc);
pause("fork", hz / 2);
+#ifdef RACCT
PROC_LOCK(p1);
racct_sub(p1, RACCT_NPROC, 1);
PROC_UNLOCK(p1);
+#endif
return (error);
}
OpenPOWER on IntegriCloud