Source-Changes-HG archive

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

[src/trunk]: src/sys/sys - make nc_nlen short since we can now accommodate mo...



details:   https://anonhg.NetBSD.org/src/rev/65eed761866b
branches:  trunk
changeset: 454327:65eed761866b
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Sep 13 13:58:53 2019 +0000

description:
- make nc_nlen short since we can now accommodate more than len 256 names.
- reorder the struct to have the lists first for performance
- put name last and make it variable length
- add an assert to make sure we don't waster space
- bump the size we can store in the pool a little because we have more space
  now because of alignment.

diffstat:

 sys/sys/namei.src |  34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diffs (65 lines):

diff -r 3bd194432bc6 -r 65eed761866b sys/sys/namei.src
--- a/sys/sys/namei.src Fri Sep 13 13:56:04 2019 +0000
+++ b/sys/sys/namei.src Fri Sep 13 13:58:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: namei.src,v 1.42 2019/06/03 06:04:21 msaitoh Exp $     */
+/*     $NetBSD: namei.src,v 1.43 2019/09/13 13:58:53 christos Exp $    */
 
 /*
  * Copyright (c) 1985, 1989, 1991, 1993
@@ -187,20 +187,17 @@
 
 #endif
 
+#ifdef __NAMECACHE_PRIVATE
 /*
- * This structure describes the elements in the cache of recent
- * names looked up by namei. NCHNAMLEN is sized to make structure
- * size a power of two to optimize allocations.  Minimum reasonable
- * size is 15.
+ * For simplicity (and economy of storage), names longer than
+ * a maximum length of NCHNAMLEN are stored in non-pooled storage.
  */
-
-#define        NCHNAMLEN       31      /* maximum name segment length we bother with */
+#define        NCHNAMLEN       32      /* up to this size gets stored in pool */
 
 /*
- * Namecache entry.  This structure is arranged so that frequently
- * accessed and mostly read-only data is toward the front, with
- * infrequently accessed data and the lock towards the rear.  The
- * lock is then more likely to be in a separate cache line.
+ * Namecache entry.  
+ * This structure describes the elements in the cache of recent
+ * names looked up by namei.
  *
  * Locking rules:
  *
@@ -214,18 +211,21 @@
 struct namecache {
        LIST_ENTRY(namecache) nc_hash;  /* L/C hash chain */
        LIST_ENTRY(namecache) nc_vhash; /* L directory hash chain */
+       TAILQ_ENTRY(namecache) nc_lru;  /* L pseudo-lru chain */
+       LIST_ENTRY(namecache) nc_dvlist;/* L dvp's list of cache entries */
+       LIST_ENTRY(namecache) nc_vlist; /* L vp's list of cache entries */
        struct  vnode *nc_dvp;          /* N vnode of parent of name */
        struct  vnode *nc_vp;           /* N vnode the name refers to */
-       int     nc_flags;               /* - copy of componentname ISWHITEOUT */
-       char    nc_nlen;                /* - length of name */
-       char    nc_name[NCHNAMLEN];     /* - segment name */
        void    *nc_gcqueue;            /* N queue for garbage collection */
-       TAILQ_ENTRY(namecache) nc_lru;  /* L psuedo-lru chain */
-       LIST_ENTRY(namecache) nc_dvlist;/* L dvp's list of cache entries */
-       LIST_ENTRY(namecache) nc_vlist; /* L vp's list of cache entries */
        kmutex_t nc_lock;               /*   lock on this entry */
        int     nc_hittime;             /* N last time scored a hit */
+       int     nc_flags;               /* - copy of componentname ISWHITEOUT */
+       u_short nc_nlen;                /* - length of name */
+       char    nc_name[0];             /* - segment name */
 };
+__CTASSERT((sizeof(struct namecache) + NCHNAMLEN)
+    % __alignof(struct namecache) == 0);
+#endif
 
 #ifdef _KERNEL
 #include <sys/pool.h>



Home | Main Index | Thread Index | Old Index