cache: convert numcachehv to counter(9) on 64-bit platforms
This commit is contained in:
parent
512fa9a4e0
commit
1399033590
@ -205,7 +205,6 @@ 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 */
|
||||
static u_long __exclusive_cache_line numcachehv;/* number of cache entries with vnodes held */
|
||||
u_int ncsizefactor = 2;
|
||||
SYSCTL_UINT(_vfs, OID_AUTO, ncsizefactor, CTLFLAG_RW, &ncsizefactor, 0,
|
||||
"Size factor for namecache");
|
||||
@ -340,6 +339,16 @@ SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0,
|
||||
SYSCTL_INT(_debug_sizeof, OID_AUTO, namecache, CTLFLAG_RD, SYSCTL_NULL_INT_PTR,
|
||||
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
|
||||
*/
|
||||
@ -352,7 +361,12 @@ static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW, 0,
|
||||
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");
|
||||
@ -393,6 +407,36 @@ static int vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
|
||||
|
||||
static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries");
|
||||
|
||||
#ifdef CACHE_NUMCACHEHV_U64
|
||||
static void
|
||||
cache_numcachehv_inc(void)
|
||||
{
|
||||
|
||||
counter_u64_add_protected(numcachehv, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
cache_numcachehv_dec(void)
|
||||
{
|
||||
|
||||
counter_u64_add_protected(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");
|
||||
@ -873,7 +917,7 @@ cache_zap_locked(struct namecache *ncp, bool neg_locked)
|
||||
LIST_REMOVE(ncp, nc_src);
|
||||
if (LIST_EMPTY(&ncp->nc_dvp->v_cache_src)) {
|
||||
ncp->nc_flag |= NCF_DVDROP;
|
||||
atomic_subtract_rel_long(&numcachehv, 1);
|
||||
cache_numcachehv_dec();
|
||||
}
|
||||
}
|
||||
atomic_subtract_rel_long(&numcache, 1);
|
||||
@ -1742,7 +1786,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
|
||||
held_dvp = false;
|
||||
if (LIST_EMPTY(&dvp->v_cache_src) && flag != NCF_ISDOTDOT) {
|
||||
vhold(dvp);
|
||||
atomic_add_long(&numcachehv, 1);
|
||||
cache_numcachehv_inc();
|
||||
held_dvp = true;
|
||||
}
|
||||
|
||||
@ -1837,7 +1881,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
|
||||
if (LIST_EMPTY(&dvp->v_cache_src)) {
|
||||
if (!held_dvp) {
|
||||
vhold(dvp);
|
||||
atomic_add_long(&numcachehv, 1);
|
||||
cache_numcachehv_inc();
|
||||
}
|
||||
} else {
|
||||
if (held_dvp) {
|
||||
@ -1848,7 +1892,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
|
||||
* this from changing.
|
||||
*/
|
||||
vdrop(dvp);
|
||||
atomic_subtract_long(&numcachehv, 1);
|
||||
cache_numcachehv_dec();
|
||||
}
|
||||
}
|
||||
LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src);
|
||||
@ -1886,7 +1930,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
|
||||
cache_free(ncp);
|
||||
if (held_dvp) {
|
||||
vdrop(dvp);
|
||||
atomic_subtract_long(&numcachehv, 1);
|
||||
cache_numcachehv_dec();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1957,6 +2001,9 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user