Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jul 2010 09:35:52 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-arch@freebsd.org, alc@freebsd.org
Cc:        Matthew Fleming <mdf356@gmail.com>, Andriy Gapon <avg@freebsd.org>
Subject:   Re: amd64: change VM_KMEM_SIZE_SCALE to 1?
Message-ID:  <201007270935.52082.jhb@freebsd.org>
In-Reply-To: <AANLkTimWcXHAz=K1UM6ECa=6xR5KuS-sf_nDhbFEgehq@mail.gmail.com>
References:  <4C4DB2B8.9080404@freebsd.org> <4C4DD1AA.3050906@freebsd.org> <AANLkTimWcXHAz=K1UM6ECa=6xR5KuS-sf_nDhbFEgehq@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007270935.52082.jhb>