svn commit: r347227 - head/sys/kern
Mark Johnston
markj at FreeBSD.org
Tue May 7 15:03:27 UTC 2019
Author: markj
Date: Tue May 7 15:03:26 2019
New Revision: 347227
URL: https://svnweb.freebsd.org/changeset/base/347227
Log:
Simplify the test against maxproc in fork1().
Previously nprocs_new would be tested against maxprocs twice when
nprocs_new < maxprocs - 10. Eliminate the unnecessary comparison.
Submitted by: Wuyang Chung <wuyang.chung1 at gmail.com>
GitHub PR: https://github.com/freebsd/freebsd/pull/397
MFC after: 1 week
Modified:
head/sys/kern/kern_fork.c
Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c Tue May 7 14:32:17 2019 (r347226)
+++ head/sys/kern/kern_fork.c Tue May 7 15:03:26 2019 (r347227)
@@ -883,18 +883,20 @@ fork1(struct thread *td, struct fork_req *fr)
* processes; don't let root exceed the limit.
*/
nprocs_new = atomic_fetchadd_int(&nprocs, 1) + 1;
- if ((nprocs_new >= maxproc - 10 &&
- priv_check_cred(td->td_ucred, PRIV_MAXPROC) != 0) ||
- nprocs_new >= maxproc) {
- error = EAGAIN;
- sx_xlock(&allproc_lock);
- if (ppsratecheck(&lastfail, &curfail, 1)) {
- printf("maxproc limit exceeded by uid %u (pid %d); "
- "see tuning(7) and login.conf(5)\n",
- td->td_ucred->cr_ruid, p1->p_pid);
+ if (nprocs_new >= maxproc - 10) {
+ if (priv_check_cred(td->td_ucred, PRIV_MAXPROC) != 0 ||
+ nprocs_new >= maxproc) {
+ error = EAGAIN;
+ sx_xlock(&allproc_lock);
+ if (ppsratecheck(&lastfail, &curfail, 1)) {
+ printf("maxproc limit exceeded by uid %u "
+ "(pid %d); see tuning(7) and "
+ "login.conf(5)\n",
+ td->td_ucred->cr_ruid, p1->p_pid);
+ }
+ sx_xunlock(&allproc_lock);
+ goto fail2;
}
- sx_xunlock(&allproc_lock);
- goto fail2;
}
/*
More information about the svn-src-head
mailing list