git: e9baf472a6d2 - main - vfs: vntblinit(): Raise default 'kern.maxvnodes' higher than 'kern.maxfiles'
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 15 May 2025 15:57:29 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=e9baf472a6d228a16be19a11150d41cff29affe8
commit e9baf472a6d228a16be19a11150d41cff29affe8
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-05-12 12:19:56 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-05-15 15:53:21 +0000
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
---
sys/kern/vfs_subr.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 769586ad0d6b..0464df2f5ad9 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -762,13 +762,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);