diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -319,13 +319,19 @@ maxprocperuid = (maxproc * 9) / 10; /* - * 'maxfiles' by default is set to 32 files per MB (overridable by - * a tunable), and is then clamped at 64 files per MB (which thus never - * happens by default). (The default MAXFILES is for all practical - * purposes not used, as it gives a lower value than 32 files per MB as - * soon as there is more than ~2.5MB of memory.) + * 'maxfiles' by default is set to 16 files per MB (with a value of 40 + * at origin; the final value is overridable by a tunable), and is then + * clamped at 64 files per MB (which thus never happens by default). 16 + * files per MB was chosen so that 'maxfiles' always stays below the + * default value automatically chosen by the system for 'maxvnodes', in + * order to mitigate a deadlock situation where some processes can + * deplete all available vnodes, from which we currently cannot recover. + * Mechanisms allowing to create more in-kernel vnodes without file + * descriptors, such as nullfs mount, can nonetheless defeat this + * counter-measure. Deeper fixes are needed to completely avoid this + * deadlock. */ - maxfiles = imax(MAXFILES, pgtok(physpages) / (1024 / 32)); + maxfiles = imax(MAXFILES, pgtok(physpages) / (1024 / 16)); TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles); { const long maxfiles_clamp = pgtok(physpages) / (1024 / 64);