mirror of
https://github.com/opnsense/src.git
synced 2026-06-13 18:50:31 -04:00
vfs: vntblinit(): Raise default 'kern.maxvnodes' higher than 'kern.maxfiles'
Having 'kern.maxvnodes' higher than 'kern.maxfiles' mitigates a scenario
where some processes can eat up all vnodes in the system, causing
a deadlock, as long as the kernel itself does not create too many vnodes
without creating some file descriptor in some process' FD table. A very
small percentage (~0.6%) of excess vnodes at infinity, coupled with
a large difference near the origin, should cover basic cases more than
enough. Note however that this measure can be defeated, e.g., by using
nullfs mounts with non-trivial file hierarchies.
MFC after: 5 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50314
(cherry picked from commit e9baf472a6)
(cherry picked from commit a6b05a35ce3c516cadfca49c310dffaabbe40440)
Approved by: re (cperciva)
This commit is contained in:
parent
0b4d5c560a
commit
6b6d6448fe
1 changed files with 4 additions and 5 deletions
|
|
@ -727,13 +727,12 @@ vntblinit(void *dummy __unused)
|
|||
* KVA).
|
||||
*
|
||||
* Currently, on 64-bit platforms, 'desiredvnodes' is set to
|
||||
* 'virtvnodes' up to a physical memory cutoff of ~1674MB, after which
|
||||
* 'virtvnodes' up to a physical memory cutoff of ~1722MB, after which
|
||||
* 'physvnodes' applies instead. With the current automatic tuning for
|
||||
* 'maxfiles' (32 files/MB), 'desiredvnodes' becomes smaller than it at
|
||||
* ~5136MB.
|
||||
* 'maxfiles' (32 files/MB), 'desiredvnodes' is always greater than it.
|
||||
*/
|
||||
physvnodes = maxproc + pgtok(vm_cnt.v_page_count) / 64 +
|
||||
3 * min(98304 * 16, pgtok(vm_cnt.v_page_count)) / 64;
|
||||
physvnodes = maxproc + pgtok(vm_cnt.v_page_count) / 32 +
|
||||
min(98304 * 16, pgtok(vm_cnt.v_page_count)) / 32;
|
||||
virtvnodes = vm_kmem_size / (10 * (sizeof(struct vm_object) +
|
||||
sizeof(struct vnode) + NC_SZ * ncsizefactor + NFS_NCLNODE_SZ));
|
||||
desiredvnodes = min(physvnodes, virtvnodes);
|
||||
|
|
|
|||
Loading…
Reference in a new issue