From owner-svn-src-all@freebsd.org Sat Oct 17 13:06:30 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C2793437BDA; Sat, 17 Oct 2020 13:06:30 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CD3F23bcnz47Hn; Sat, 17 Oct 2020 13:06:30 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 600F721A5B; Sat, 17 Oct 2020 13:06:30 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09HD6UKV023966; Sat, 17 Oct 2020 13:06:30 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09HD6UxA023965; Sat, 17 Oct 2020 13:06:30 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202010171306.09HD6UxA023965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 17 Oct 2020 13:06:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366793 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 366793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 13:06:30 -0000 Author: mjg Date: Sat Oct 17 13:06:29 2020 New Revision: 366793 URL: https://svnweb.freebsd.org/changeset/base/366793 Log: cache: erwork sysctl vfs.cache tree Split everything into neg, debug, param and stat categories. The legacy nchstats sysctl (queried e.g., by systat) remains untouched. While here rename some vars to be easier on the eye. Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Sat Oct 17 13:04:46 2020 (r366792) +++ head/sys/kern/vfs_cache.c Sat Oct 17 13:06:29 2020 (r366793) @@ -79,6 +79,9 @@ __FBSDID("$FreeBSD$"); #include +static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "Name cache"); + SDT_PROVIDER_DECLARE(vfs); SDT_PROBE_DEFINE3(vfs, namecache, enter, done, "struct vnode *", "char *", "struct vnode *"); @@ -277,6 +280,21 @@ cache_ncp_canuse(struct namecache *ncp) VFS_SMR_DECLARE; +static SYSCTL_NODE(_vfs_cache, OID_AUTO, param, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "Name cache parameters"); + +static u_int __read_mostly ncsize; /* the size as computed on creation or resizing */ +SYSCTL_UINT(_vfs_cache_param, OID_AUTO, size, CTLFLAG_RW, &ncsize, 0, + "Total namecache capacity"); + +u_int ncsizefactor = 2; +SYSCTL_UINT(_vfs_cache_param, OID_AUTO, sizefactor, CTLFLAG_RW, &ncsizefactor, 0, + "Size factor for namecache"); + +static u_long __read_mostly ncnegfactor = 5; /* ratio of negative entries */ +SYSCTL_ULONG(_vfs_cache_param, OID_AUTO, negfactor, CTLFLAG_RW, &ncnegfactor, 0, + "Ratio of negative namecache entries"); + /* * Structures associated with name caching. */ @@ -286,15 +304,8 @@ static __read_mostly CK_SLIST_HEAD(nchashhead, namecac static u_long __read_mostly nchash; /* size of hash table */ SYSCTL_ULONG(_debug, OID_AUTO, nchash, CTLFLAG_RD, &nchash, 0, "Size of namecache hash table"); -static u_long __read_mostly ncnegfactor = 5; /* ratio of negative entries */ -SYSCTL_ULONG(_vfs, OID_AUTO, ncnegfactor, CTLFLAG_RW, &ncnegfactor, 0, - "Ratio of negative namecache entries"); static u_long __exclusive_cache_line numneg; /* number of negative entries allocated */ static u_long __exclusive_cache_line numcache;/* number of cache entries allocated */ -u_int ncsizefactor = 2; -SYSCTL_UINT(_vfs, OID_AUTO, ncsizefactor, CTLFLAG_RW, &ncsizefactor, 0, - "Size factor for namecache"); -static u_int __read_mostly ncsize; /* the size as computed on creation or resizing */ struct nchstats nchstats; /* cache effectiveness statistics */ @@ -433,43 +444,58 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, namecache, CTLFLAG /* * The new name cache statistics */ -static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, +static SYSCTL_NODE(_vfs_cache, OID_AUTO, stats, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Name cache statistics"); -#define STATNODE_ULONG(name, descr) \ - SYSCTL_ULONG(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, descr); -#define STATNODE_COUNTER(name, descr) \ - static COUNTER_U64_DEFINE_EARLY(name); \ - SYSCTL_COUNTER_U64(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, \ + +#define STATNODE_ULONG(name, varname, descr) \ + SYSCTL_ULONG(_vfs_cache_stats, OID_AUTO, name, CTLFLAG_RD, &varname, 0, descr); +#define STATNODE_COUNTER(name, varname, descr) \ + static COUNTER_U64_DEFINE_EARLY(varname); \ + SYSCTL_COUNTER_U64(_vfs_cache_stats, OID_AUTO, name, CTLFLAG_RD, &varname, \ descr); -STATNODE_ULONG(numneg, "Number of negative cache entries"); -STATNODE_ULONG(numcache, "Number of cache entries"); -STATNODE_COUNTER(numcachehv, "Number of namecache entries with vnodes held"); -STATNODE_COUNTER(numdrops, "Number of dropped entries due to reaching the limit"); -STATNODE_COUNTER(dothits, "Number of '.' hits"); -STATNODE_COUNTER(dotdothits, "Number of '..' hits"); -STATNODE_COUNTER(nummiss, "Number of cache misses"); -STATNODE_COUNTER(nummisszap, "Number of cache misses we do not want to cache"); -STATNODE_COUNTER(numposzaps, +STATNODE_ULONG(neg, numneg, "Number of negative cache entries"); +STATNODE_ULONG(count, numcache, "Number of cache entries"); +STATNODE_COUNTER(heldvnodes, numcachehv, "Number of namecache entries with vnodes held"); +STATNODE_COUNTER(drops, numdrops, "Number of dropped entries due to reaching the limit"); +STATNODE_COUNTER(dothits, dothits, "Number of '.' hits"); +STATNODE_COUNTER(dotdothis, dotdothits, "Number of '..' hits"); +STATNODE_COUNTER(miss, nummiss, "Number of cache misses"); +STATNODE_COUNTER(misszap, nummisszap, "Number of cache misses we do not want to cache"); +STATNODE_COUNTER(posszaps, numposzaps, "Number of cache hits (positive) we do not want to cache"); -STATNODE_COUNTER(numposhits, "Number of cache hits (positive)"); -STATNODE_COUNTER(numnegzaps, +STATNODE_COUNTER(poshits, numposhits, "Number of cache hits (positive)"); +STATNODE_COUNTER(negzaps, numnegzaps, "Number of cache hits (negative) we do not want to cache"); -STATNODE_COUNTER(numneghits, "Number of cache hits (negative)"); +STATNODE_COUNTER(neghits, numneghits, "Number of cache hits (negative)"); /* These count for vn_getcwd(), too. */ -STATNODE_COUNTER(numfullpathcalls, "Number of fullpath search calls"); -STATNODE_COUNTER(numfullpathfail1, "Number of fullpath search errors (ENOTDIR)"); -STATNODE_COUNTER(numfullpathfail2, +STATNODE_COUNTER(fullpathcalls, numfullpathcalls, "Number of fullpath search calls"); +STATNODE_COUNTER(fullpathfail1, numfullpathfail1, "Number of fullpath search errors (ENOTDIR)"); +STATNODE_COUNTER(fullpathfail2, numfullpathfail2, "Number of fullpath search errors (VOP_VPTOCNP failures)"); -STATNODE_COUNTER(numfullpathfail4, "Number of fullpath search errors (ENOMEM)"); -STATNODE_COUNTER(numfullpathfound, "Number of successful fullpath calls"); -STATNODE_COUNTER(zap_and_exit_bucket_relock_success, +STATNODE_COUNTER(fullpathfail4, numfullpathfail4, "Number of fullpath search errors (ENOMEM)"); +STATNODE_COUNTER(fullpathfound, numfullpathfound, "Number of successful fullpath calls"); + +/* + * Debug or developer statistics. + */ +static SYSCTL_NODE(_vfs_cache, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "Name cache debugging"); +#define DEBUGNODE_ULONG(name, descr) \ + SYSCTL_ULONG(_vfs_cache_debug, OID_AUTO, name, CTLFLAG_RD, &name, 0, descr); +#define DEBUGNODE_COUNTER(name, descr) \ + static COUNTER_U64_DEFINE_EARLY(name); \ + SYSCTL_COUNTER_U64(_vfs_cache_debug, OID_AUTO, name, CTLFLAG_RD, &name, \ + descr); +DEBUGNODE_COUNTER(zap_and_exit_bucket_relock_success, "Number of successful removals after relocking"); -static long zap_and_exit_bucket_fail; STATNODE_ULONG(zap_and_exit_bucket_fail, +static long zap_and_exit_bucket_fail; +DEBUGNODE_ULONG(zap_and_exit_bucket_fail, "Number of times zap_and_exit failed to lock"); -static long zap_and_exit_bucket_fail2; STATNODE_ULONG(zap_and_exit_bucket_fail2, +static long zap_and_exit_bucket_fail2; +DEBUGNODE_ULONG(zap_and_exit_bucket_fail2, "Number of times zap_and_exit failed to lock"); static long cache_lock_vnodes_cel_3_failures; -STATNODE_ULONG(cache_lock_vnodes_cel_3_failures, +DEBUGNODE_ULONG(cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); static void cache_zap_locked(struct namecache *ncp);