amd64: change VM_KMEM_SIZE_SCALE to 1?

John Baldwin jhb at freebsd.org
Tue Jul 27 14:16:29 UTC 2010


On Monday, July 26, 2010 3:30:59 pm Alan Cox wrote:
> As far as eliminating or reducing the manual tuning that many ZFS users do,
> I would love to see someone tackle the overly conservative hard limit that
> we place on the number of vnode structures.  The current hard limit was put
> in place when we had just introduced mutexes into many structures and more a
> mutex was much larger than it is today.

I have a strawman of that (relative to 7).  It simply adjusts the hardcoded 
maximum to instead be a function of the amount of physical memory.

Index: vfs_subr.c
===================================================================
--- vfs_subr.c	(revision 210934)
+++ vfs_subr.c	(working copy)
@@ -288,6 +288,7 @@
 static void
 vntblinit(void *dummy __unused)
 {
+	int vnodes;
 
 	/*
 	 * Desiredvnodes is a function of the physical memory size and
@@ -299,10 +300,19 @@
 	desiredvnodes = min(maxproc + cnt.v_page_count / 4, 2 * vm_kmem_size /
 	    (5 * (sizeof(struct vm_object) + sizeof(struct vnode))));
 	if (desiredvnodes > MAXVNODES_MAX) {
+
+		/*
+		 * If there is a lot of physical memory, allow the cap
+		 * on vnodes to expand to using a little under 1% of
+		 * available RAM.
+		 */
+		vnodes = max(MAXVNODES_MAX, cnt.v_page_count * (PAGE_SIZE /
+		    128) / (sizeof(struct vm_object) + sizeof(struct vnode)));
+		KASSERT(vnodes < desiredvnodes, ("capped vnodes too big"));
 		if (bootverbose)
 			printf("Reducing kern.maxvnodes %d -> %d\n",
-			    desiredvnodes, MAXVNODES_MAX);
-		desiredvnodes = MAXVNODES_MAX;
+			    desiredvnodes, vnodes);
+		desiredvnodes = vnodes;
 	}
 	wantfreevnodes = desiredvnodes / 4;
 	mtx_init(&mntid_mtx, "mntid", NULL, MTX_DEF);

-- 
John Baldwin


More information about the freebsd-arch mailing list