svn commit: r306608 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Mon Oct 3 00:02:33 UTC 2016


Author: mjg
Date: Mon Oct  3 00:02:32 2016
New Revision: 306608
URL: https://svnweb.freebsd.org/changeset/base/306608

Log:
  cache: ignore purgevfs requests for filesystems with few vnodes
  
  purgevfs is purely optional and induces lock contention in workloads
  which frequently mount and unmount filesystems.
  
  In particular, poudriere will do this for filesystems with 4 vnodes or
  less. Full cache scan is clearly wasteful.
  
  Since there is no explicit counter for namecache entries, the number of
  vnodes used by the target fs is checked.
  
  The default limit is the number of bucket locks.
  
  Reviewed by:	kib

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Sun Oct  2 23:59:31 2016	(r306607)
+++ head/sys/kern/vfs_cache.c	Mon Oct  3 00:02:32 2016	(r306608)
@@ -207,6 +207,9 @@ SYSCTL_ULONG(_debug, OID_AUTO, numcacheh
 u_int	ncsizefactor = 2;
 SYSCTL_UINT(_vfs, OID_AUTO, ncsizefactor, CTLFLAG_RW, &ncsizefactor, 0,
     "Size factor for namecache");
+static u_int	ncpurgeminvnodes;
+SYSCTL_UINT(_vfs, OID_AUTO, ncpurgeminvnodes, CTLFLAG_RW, &ncpurgeminvnodes, 0,
+    "Number of vnodes below which purgevfs ignores the request");
 
 struct nchstats	nchstats;		/* cache effectiveness statistics */
 
@@ -1614,6 +1617,7 @@ nchinit(void *dummy __unused)
 	    M_WAITOK | M_ZERO);
 	for (i = 0; i < numvnodelocks; i++)
 		mtx_init(&vnodelocks[i], "ncvn", NULL, MTX_DUPOK | MTX_RECURSE);
+	ncpurgeminvnodes = numbucketlocks;
 
 	numcalls = counter_u64_alloc(M_WAITOK);
 	dothits = counter_u64_alloc(M_WAITOK);
@@ -1764,6 +1768,8 @@ cache_purgevfs(struct mount *mp)
 
 	/* Scan hash tables for applicable entries */
 	SDT_PROBE1(vfs, namecache, purgevfs, done, mp);
+	if (mp->mnt_nvnodelistsize <= ncpurgeminvnodes)
+		return;
 	TAILQ_INIT(&ncps);
 	n_nchash = nchash + 1;
 	vlp1 = vlp2 = NULL;


More information about the svn-src-all mailing list