svn commit: r356915 - head/sys/kern
Konstantin Belousov
kostikbel at gmail.com
Mon Jan 20 15:49:08 UTC 2020
On Mon, Jan 20, 2020 at 02:42:11PM +0000, Mateusz Guzik wrote:
> Author: mjg
> Date: Mon Jan 20 14:42:11 2020
> New Revision: 356915
> URL: https://svnweb.freebsd.org/changeset/base/356915
>
> Log:
> cache: make numcachehv use counter(9) on all archs
>
> Requested by: kib
Thank you.
>
> Modified:
> head/sys/kern/vfs_cache.c
>
> Modified: head/sys/kern/vfs_cache.c
> ==============================================================================
> --- head/sys/kern/vfs_cache.c Mon Jan 20 13:46:09 2020 (r356914)
> +++ head/sys/kern/vfs_cache.c Mon Jan 20 14:42:11 2020 (r356915)
> @@ -340,16 +340,6 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, namecache, CTLFLAG
> sizeof(struct namecache), "sizeof(struct namecache)");
>
> /*
> - * Use counter(9) for numcachehv if the machine is 64-bit.
> - *
> - * Stick to an atomic for the rest since there is no long-sized equivalent and
> - * 64-bit size is both way more than needed and a pessimization.
> - */
> -#ifdef __LP64__
> -#define CACHE_NUMCACHEHV_U64
> -#endif
> -
> -/*
> * The new name cache statistics
> */
> static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW, 0,
> @@ -361,12 +351,7 @@ static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW,
> SYSCTL_COUNTER_U64(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, descr);
> STATNODE_ULONG(numneg, "Number of negative cache entries");
> STATNODE_ULONG(numcache, "Number of cache entries");
> -#ifdef CACHE_NUMCACHEHV_U64
> STATNODE_COUNTER(numcachehv, "Number of namecache entries with vnodes held");
> -#else
> -static u_long __exclusive_cache_line numcachehv;/* number of cache entries with vnodes held */
> -STATNODE_ULONG(numcachehv, "Number of namecache entries with vnodes held");
> -#endif
> STATNODE_COUNTER(numcalls, "Number of cache lookups");
> STATNODE_COUNTER(dothits, "Number of '.' hits");
> STATNODE_COUNTER(dotdothits, "Number of '..' hits");
> @@ -407,36 +392,6 @@ static int vn_fullpath1(struct thread *td, struct vnod
>
> static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries");
>
> -#ifdef CACHE_NUMCACHEHV_U64
> -static void
> -cache_numcachehv_inc(void)
> -{
> -
> - counter_u64_add(numcachehv, 1);
> -}
> -
> -static void
> -cache_numcachehv_dec(void)
> -{
> -
> - counter_u64_add(numcachehv, -1);
> -}
> -#else
> -static void
> -cache_numcachehv_inc(void)
> -{
> -
> - atomic_add_long(&numcachehv, 1);
> -}
> -
> -static void
> -cache_numcachehv_dec(void)
> -{
> -
> - atomic_subtract_long(&numcachehv, 1);
> -}
> -#endif
> -
> static int cache_yield;
> SYSCTL_INT(_vfs_cache, OID_AUTO, yield, CTLFLAG_RD, &cache_yield, 0,
> "Number of times cache called yield");
> @@ -917,7 +872,7 @@ cache_zap_locked(struct namecache *ncp, bool neg_locke
> LIST_REMOVE(ncp, nc_src);
> if (LIST_EMPTY(&ncp->nc_dvp->v_cache_src)) {
> ncp->nc_flag |= NCF_DVDROP;
> - cache_numcachehv_dec();
> + counter_u64_add(numcachehv, -1);
> }
> }
> atomic_subtract_rel_long(&numcache, 1);
> @@ -1786,7 +1741,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp,
> held_dvp = false;
> if (LIST_EMPTY(&dvp->v_cache_src) && flag != NCF_ISDOTDOT) {
> vhold(dvp);
> - cache_numcachehv_inc();
> + counter_u64_add(numcachehv, 1);
> held_dvp = true;
> }
>
> @@ -1881,7 +1836,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp,
> if (LIST_EMPTY(&dvp->v_cache_src)) {
> if (!held_dvp) {
> vhold(dvp);
> - cache_numcachehv_inc();
> + counter_u64_add(numcachehv, 1);
> }
> } else {
> if (held_dvp) {
> @@ -1892,7 +1847,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp,
> * this from changing.
> */
> vdrop(dvp);
> - cache_numcachehv_dec();
> + counter_u64_add(numcachehv, -1);
> }
> }
> LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src);
> @@ -1930,7 +1885,7 @@ out_unlock_free:
> cache_free(ncp);
> if (held_dvp) {
> vdrop(dvp);
> - cache_numcachehv_dec();
> + counter_u64_add(numcachehv, -1);
> }
> return;
> }
> @@ -2001,9 +1956,7 @@ nchinit(void *dummy __unused)
>
> mtx_init(&ncneg_shrink_lock, "ncnegs", NULL, MTX_DEF);
>
> -#ifdef CACHE_NUMCACHEHV_U64
> numcachehv = counter_u64_alloc(M_WAITOK);
> -#endif
> numcalls = counter_u64_alloc(M_WAITOK);
> dothits = counter_u64_alloc(M_WAITOK);
> dotdothits = counter_u64_alloc(M_WAITOK);
More information about the svn-src-head
mailing list