git: a6b05a35ce3c - stable/14 - vfs: vntblinit(): Raise default 'kern.maxvnodes' higher than 'kern.maxfiles'
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 20 May 2025 09:08:40 UTC
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=a6b05a35ce3c516cadfca49c310dffaabbe40440 commit a6b05a35ce3c516cadfca49c310dffaabbe40440 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2025-05-12 12:19:56 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-05-20 09:05:33 +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 (cherry picked from commit e9baf472a6d228a16be19a11150d41cff29affe8) --- 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 62ae987a3084..7ff6ac5f5b44 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -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);