From 05f836c1c3fdb085eb93908c94736251d6a86f6d Mon Sep 17 00:00:00 2001 From: pjd Date: Wed, 12 May 2010 16:42:28 +0000 Subject: When there is no memory or KVA, try to help by reclaiming some vnodes. This helps with 'kmem_map too small' panics. No objections from: kib Tested by: Alexander V. Ribchansky MFC after: 1 week --- sys/kern/vfs_subr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index d93d2d8..1fb131a 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -821,6 +821,19 @@ static struct kproc_desc vnlru_kp = { }; SYSINIT(vnlru, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &vnlru_kp); + +static void +vfs_lowmem(void *arg __unused) +{ + + /* + * On low memory condition free 1/8th of the free vnodes. + */ + mtx_lock(&vnode_free_list_mtx); + vnlru_free(freevnodes / 8); + mtx_unlock(&vnode_free_list_mtx); +} +EVENTHANDLER_DEFINE(vm_lowmem, vfs_lowmem, NULL, 0); /* * Routines having to do with the management of the vnode table. -- cgit v1.1