diff options
| author | dennis <dennis@NetBSD.org> | 2014-12-24 19:56:49 +0000 |
|---|---|---|
| committer | dennis <dennis@NetBSD.org> | 2014-12-24 19:56:49 +0000 |
| commit | a3c8748abbadd21cb7475f59229cf3b5dfd44c4a (patch) | |
| tree | be7a34515c2f3e2c1fb903709c074d6c476a95ea /sys | |
| parent | 338bdc1d18b033f46b49fd5fd53e5de43fc5e702 (diff) | |
Update stats-keeping in sys/kern/vfs_cache.c to remove (most)
races while allowing consistent lockless sampling of the per-cpu
statistics without atomic operations. Update comment describing
the locking protocol to include this.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/rump/include/rump/rump_namei.h | 4 | ||||
| -rw-r--r-- | sys/sys/namei.h | 94 |
2 files changed, 42 insertions, 56 deletions
diff --git a/sys/rump/include/rump/rump_namei.h b/sys/rump/include/rump/rump_namei.h index af4fdce27b6..1bb9478b34a 100644 --- a/sys/rump/include/rump/rump_namei.h +++ b/sys/rump/include/rump/rump_namei.h @@ -1,11 +1,11 @@ -/* $NetBSD: rump_namei.h,v 1.24 2014/06/03 21:16:37 joerg Exp $ */ +/* $NetBSD: rump_namei.h,v 1.25 2014/12/24 19:56:49 dennis Exp $ */ /* * WARNING: GENERATED FILE. DO NOT EDIT * (edit namei.src and run make namei in src/sys/sys) * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp - * from: NetBSD: namei.src,v 1.33 2014/06/03 21:16:15 joerg Exp + * from: NetBSD: namei.src,v 1.34 2014/12/24 19:50:04 dennis Exp */ #ifndef _RUMP_RUMP_NAMEI_H_ diff --git a/sys/sys/namei.h b/sys/sys/namei.h index ac70d04aea3..805da3d499e 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -1,11 +1,11 @@ -/* $NetBSD: namei.h,v 1.90 2014/09/05 05:42:50 matt Exp $ */ +/* $NetBSD: namei.h,v 1.91 2014/12/24 19:56:49 dennis Exp $ */ /* * WARNING: GENERATED FILE. DO NOT EDIT * (edit namei.src and run make namei in src/sys/sys) * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp - * from: NetBSD: namei.src,v 1.33 2014/06/03 21:16:15 joerg Exp + * from: NetBSD: namei.src,v 1.34 2014/12/24 19:50:04 dennis Exp */ /* @@ -85,26 +85,6 @@ void pathbuf_stringcopy_put(struct pathbuf *, const char *); int pathbuf_maybe_copyin(const char *userpath, enum uio_seg seg, struct pathbuf **ret); /* - * Lookup parameters: this structure describes the subset of - * information from the nameidata structure that is passed - * through the VOP interface. - */ -struct componentname { - /* - * Arguments to lookup. - */ - uint32_t cn_nameiop; /* namei operation */ - uint32_t cn_flags; /* flags to namei */ - kauth_cred_t cn_cred; /* credentials */ - /* - * Shared between lookup and commit routines. - */ - const char *cn_nameptr; /* pointer to looked up name */ - size_t cn_namelen; /* length of looked up comp */ - size_t cn_consume; /* chars to consume in lookup */ -}; - -/* * Encapsulation of namei parameters. */ struct nameidata { @@ -135,7 +115,20 @@ struct nameidata { * information from the nameidata structure that is passed * through the VOP interface. */ - struct componentname ni_cnd; + struct componentname { + /* + * Arguments to lookup. + */ + uint32_t cn_nameiop; /* namei operation */ + uint32_t cn_flags; /* flags to namei */ + kauth_cred_t cn_cred; /* credentials */ + /* + * Shared between lookup and commit routines. + */ + const char *cn_nameptr; /* pointer to looked up name */ + size_t cn_namelen; /* length of looked up comp */ + size_t cn_consume; /* chars to consume in lookup */ + } ni_cnd; }; /* @@ -236,8 +229,8 @@ struct cpu_info; extern pool_cache_t pnbuf_cache; /* pathname buffer cache */ -#define PNBUF_GET() ((char *)pool_cache_get(pnbuf_cache, PR_WAITOK)) -#define PNBUF_PUT(pnb) pool_cache_put(pnbuf_cache, (void *)(pnb)) +#define PNBUF_GET() pool_cache_get(pnbuf_cache, PR_WAITOK) +#define PNBUF_PUT(pnb) pool_cache_put(pnbuf_cache, (pnb)) /* * Typesafe flags for namei_simple/nameiat_simple. @@ -303,38 +296,31 @@ void namecache_print(struct vnode *, void (*)(const char *, ...) #endif /* - * Stats on usefulness of namei caches. - * XXX: should be 64-bit counters. + * Stats on usefulness of namei caches. A couple of structures are + * used for counting, with members having the same names but different + * types. Containerize member names with the preprocessor to avoid + * cut-'n'-paste. A (U) in the comment documents values that are + * incremented unlocked; we may treat these specially. */ -struct nchstats { - long ncs_goodhits; /* hits that we can really use */ - long ncs_neghits; /* negative hits that we can use */ - long ncs_badhits; /* hits we must drop */ - long ncs_falsehits; /* hits with id mismatch */ - long ncs_miss; /* misses */ - long ncs_long; /* long names that ignore cache */ - long ncs_pass2; /* names found with passes == 2 */ - long ncs_2passes; /* number of times we attempt it */ - long ncs_revhits; /* reverse-cache hits */ - long ncs_revmiss; /* reverse-cache misses */ -}; +#define _NAMEI_CACHE_STATS(type) { \ + type ncs_goodhits; /* hits that we can really use (U) */ \ + type ncs_neghits; /* negative hits that we can use */ \ + type ncs_badhits; /* hits we must drop */ \ + type ncs_falsehits; /* hits with id mismatch (U) */ \ + type ncs_miss; /* misses */ \ + type ncs_long; /* long names that ignore cache */ \ + type ncs_pass2; /* names found with passes == 2 (U) */ \ + type ncs_2passes; /* number of times we attempt it (U) */ \ + type ncs_revhits; /* reverse-cache hits */ \ + type ncs_revmiss; /* reverse-cache misses */ \ +} -struct nchstats_sysctl { - uint64_t ncs_goodhits; /* hits that we can really use */ - uint64_t ncs_neghits; /* negative hits that we can use */ - uint64_t ncs_badhits; /* hits we must drop */ - uint64_t ncs_falsehits; /* hits with id mismatch */ - uint64_t ncs_miss; /* misses */ - uint64_t ncs_long; /* long names that ignore cache */ - uint64_t ncs_pass2; /* names found with passes == 2 */ - uint64_t ncs_2passes; /* number of times we attempt it */ - uint64_t ncs_revhits; /* reverse-cache hits */ - uint64_t ncs_revmiss; /* reverse-cache misses */ -}; +/* + * Sysctl deals with a uint64_t version of the stats and summary + * totals are kept that way. + */ +struct nchstats _NAMEI_CACHE_STATS(uint64_t); -#ifdef _KERNEL -extern struct nchstats nchstats; -#endif /* #endif !_SYS_NAMEI_H_ (generated by gennameih.awk) */ /* Definitions match above, but with NAMEI_ prefix */ |
