Module Name:    src
Committed By:   dennis
Date:           Wed Dec 24 19:56:49 UTC 2014

Modified Files:
        src/sys/rump/include/rump: rump_namei.h
        src/sys/sys: namei.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/rump/include/rump/rump_namei.h
cvs rdiff -u -r1.90 -r1.91 src/sys/sys/namei.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/include/rump/rump_namei.h
diff -u src/sys/rump/include/rump/rump_namei.h:1.24 src/sys/rump/include/rump/rump_namei.h:1.25
--- src/sys/rump/include/rump/rump_namei.h:1.24	Tue Jun  3 21:16:37 2014
+++ src/sys/rump/include/rump/rump_namei.h	Wed Dec 24 19:56:49 2014
@@ -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_

Index: src/sys/sys/namei.h
diff -u src/sys/sys/namei.h:1.90 src/sys/sys/namei.h:1.91
--- src/sys/sys/namei.h:1.90	Fri Sep  5 05:42:50 2014
+++ src/sys/sys/namei.h	Wed Dec 24 19:56:49 2014
@@ -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 pathb
 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 *, voi
 #endif
 
 /*
- * Stats on usefulness of namei caches.
- * XXX: should be 64-bit counters.
- */
-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 */
-};
+ * 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.
+ */
+#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 */

Reply via email to