Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Update stats-keeping in sys/kern/vfs_cache.c to remove (...



details:   https://anonhg.NetBSD.org/src/rev/6bc5f33bc593
branches:  trunk
changeset: 335083:6bc5f33bc593
user:      dennis <dennis%NetBSD.org@localhost>
date:      Wed Dec 24 19:56:49 2014 +0000

description:
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:

 sys/rump/include/rump/rump_namei.h |   4 +-
 sys/sys/namei.h                    |  94 ++++++++++++++++---------------------
 2 files changed, 42 insertions(+), 56 deletions(-)

diffs (155 lines):

diff -r 87bcc3fbf1c6 -r 6bc5f33bc593 sys/rump/include/rump/rump_namei.h
--- a/sys/rump/include/rump/rump_namei.h        Wed Dec 24 19:50:04 2014 +0000
+++ b/sys/rump/include/rump/rump_namei.h        Wed Dec 24 19:56:49 2014 +0000
@@ -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 -r 87bcc3fbf1c6 -r 6bc5f33bc593 sys/sys/namei.h
--- a/sys/sys/namei.h   Wed Dec 24 19:50:04 2014 +0000
+++ b/sys/sys/namei.h   Wed Dec 24 19:56:49 2014 +0000
@@ -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 @@
 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 @@
         * 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 @@
 
 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 @@
 #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 */



Home | Main Index | Thread Index | Old Index