diff options
author | Adrian Chadd <adrian@FreeBSD.org> | 2015-09-10 04:05:58 +0000 |
---|---|---|
committer | Adrian Chadd <adrian@FreeBSD.org> | 2015-09-10 04:05:58 +0000 |
commit | 32766cd281b1f7930790ce4840b8e08964ab737f (patch) | |
tree | 359124d34cb5d29cdd600d5a11936b0f4e772b27 /sys/kern/subr_param.c | |
parent | b98cb919dec2697af74f4e7bbea8a14f1c1a3d6e (diff) | |
download | src-32766cd281b1f7930790ce4840b8e08964ab737f.tar.gz src-32766cd281b1f7930790ce4840b8e08964ab737f.zip |
Also make kern.maxfilesperproc a boot time tunable.
Auto-tuning threshold discussions aside, it turns out that if you want
to lower this on say, rather memory-packed machines, you either set maxusers
or kern.maxfiles, or you set it in sysctl. The former is a non-exact
way to tune this; the latter doesn't actually affect anything in the
startup scripts.
This first occured because I wondered why the hell screen would take upwards
of 10 seconds to spawn a new screen. I then found python doing the same
thing during fork/exec of child processes - it calls close() on each FD
up to the current openfiles limit. On a 1TB machine this is like, 26 million
FDs per process. Ugh.
So:
* This allows it to be set early in /boot/loader.conf;
* It can be used to work around the ridiculous situation of
screen, python, etc doing a close() on potentially millions of FDs
even though you only have four open.
Tested:
* 4GB, 32GB, 64GB, 128GB, 384GB, 1TB systems with autotune, ensuring
screen and python forking doesn't result in some pretty hilariously
bad behaviour.
TODO:
* Note that the default login.conf sets openfiles-cur to unlimited,
effectively obeying kern.maxfilesperproc. Perhaps we should fix
this.
* .. and even if we do, we need to also ensure that daemons get
a soft limit of something reasonable and capped - they can request
more FDs themselves.
MFC after: 1 week
Sponsored by: Norse Corp, Inc.
Notes
Notes:
svn path=/head/; revision=287606
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r-- | sys/kern/subr_param.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 36608d1f52b8..52c6f167f753 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -265,7 +265,8 @@ init_param2(long physpages) if (maxfiles > (physpages / 4)) maxfiles = physpages / 4; maxfilesperproc = (maxfiles / 10) * 9; - + TUNABLE_INT_FETCH("kern.maxfilesperproc", &maxfilesperproc); + /* * Cannot be changed after boot. */ |