CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Sun Mar 22 14:23:27 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: vnode_impl.h Log Message: Keeping the namecache lock next to the vnode lock has a repeatable detrimental effect. So shuffle some stuff around in vnode_impl to save a bit of space, and give the namecache locks their own cache line. To generate a diff of this commit: cvs rdiff -u -r1.19.2.5 -r1.19.2.6 src/sys/sys/vnode_impl.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/sys/vnode_impl.h diff -u src/sys/sys/vnode_impl.h:1.19.2.5 src/sys/sys/vnode_impl.h:1.19.2.6 --- src/sys/sys/vnode_impl.h:1.19.2.5 Fri Jan 24 16:05:23 2020 +++ src/sys/sys/vnode_impl.h Sun Mar 22 14:23:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode_impl.h,v 1.19.2.5 2020/01/24 16:05:23 ad Exp $ */ +/* $NetBSD: vnode_impl.h,v 1.19.2.6 2020/03/22 14:23:27 ad Exp $ */ /*- * Copyright (c) 2016, 2019, 2020 The NetBSD Foundation, Inc. @@ -76,6 +76,19 @@ struct vnode_impl { struct vcache_key vi_key; /* c vnode cache key */ /* + * vnode cache, LRU and syncer. This all changes with some + * regularity so keep it together. + */ + struct vnodelst *vi_lrulisthd; /* d current lru list head */ + TAILQ_ENTRY(vnode_impl) vi_lrulist; /* d lru list */ + int vi_synclist_slot; /* s synclist slot index */ + int vi_lrulisttm; /* i time of lru enqueue */ + TAILQ_ENTRY(vnode_impl) vi_synclist; /* s vnodes with dirty bufs */ + SLIST_ENTRY(vnode_impl) vi_hash; /* c vnode cache list */ + enum vnode_state vi_state; /* i current state */ + TAILQ_ENTRY(vnode_impl) vi_mntvnodes; /* m vnodes for mount point */ + + /* * Namecache. Give it a separate line so activity doesn't impinge * on the stable stuff. */ @@ -88,27 +101,14 @@ struct vnode_impl { uint32_t vi_nc_spare; /* - spare (padding) */ /* - * vnode cache, LRU and syncer. This all changes with some - * regularity so keep it together. - */ - struct vnodelst *vi_lrulisthd /* d current lru list head */ - __aligned(COHERENCY_UNIT); - TAILQ_ENTRY(vnode_impl) vi_lrulist; /* d lru list */ - int vi_synclist_slot; /* s synclist slot index */ - int vi_lrulisttm; /* i time of lru enqueue */ - TAILQ_ENTRY(vnode_impl) vi_synclist; /* s vnodes with dirty bufs */ - SLIST_ENTRY(vnode_impl) vi_hash; /* c vnode cache list */ - enum vnode_state vi_state; /* i current state */ - - /* * Locks and expensive to access items which can be expected to * generate a cache miss. */ krwlock_t vi_lock /* - lock for this vnode */ __aligned(COHERENCY_UNIT); - krwlock_t vi_nc_lock; /* - lock on node */ + krwlock_t vi_nc_lock /* - lock on node */ + __aligned(COHERENCY_UNIT); krwlock_t vi_nc_listlock; /* - lock on nn_list */ - TAILQ_ENTRY(vnode_impl) vi_mntvnodes; /* m vnodes for mount point */ }; typedef struct vnode_impl vnode_impl_t;
CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Sat Mar 21 22:04:17 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: namei.src Log Message: Move nc_key up, so cache_lookup_entry() only needs to touch one cache line at each step. To generate a diff of this commit: cvs rdiff -u -r1.47.2.7 -r1.47.2.8 src/sys/sys/namei.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/namei.src diff -u src/sys/sys/namei.src:1.47.2.7 src/sys/sys/namei.src:1.47.2.8 --- src/sys/sys/namei.src:1.47.2.7 Wed Mar 4 20:21:05 2020 +++ src/sys/sys/namei.src Sat Mar 21 22:04:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: namei.src,v 1.47.2.7 2020/03/04 20:21:05 ad Exp $ */ +/* $NetBSD: namei.src,v 1.47.2.8 2020/03/21 22:04:17 ad Exp $ */ /* * Copyright (c) 1985, 1989, 1991, 1993 @@ -199,11 +199,12 @@ NAMEIFL PARAMASK 0x02ef800 /* mask of pa #define NCHNAMLEN sizeof(((struct namecache *)NULL)->nc_name) /* - * Namecache entry. + * Namecache entry. * * This structure describes the elements in the cache of recent names looked * up by namei. It's carefully sized to take up 128 bytes on _LP64, to make - * good use of space and the CPU caches. + * good use of space and the CPU caches. Items used during RB tree lookup + * (nc_tree, nc_key) are clustered at the start of the structure. * * Field markings and their corresponding locks: * @@ -216,11 +217,11 @@ NAMEIFL PARAMASK 0x02ef800 /* mask of pa struct nchnode; struct namecache { struct rb_node nc_tree; /* d red-black tree, must be first */ + int64_t nc_key; /* - hash key */ TAILQ_ENTRY(namecache) nc_list; /* v vp's list of cache entries */ TAILQ_ENTRY(namecache) nc_lru; /* l pseudo-lru chain */ struct vnode *nc_dvp; /* - vnode of parent of name */ struct vnode *nc_vp; /* - vnode the name refers to */ - int64_t nc_key; /* - hash key */ int nc_lrulist; /* l which LRU list its on */ short nc_nlen; /* - length of the name */ char nc_whiteout; /* - true if a whiteout */
CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Wed Mar 4 20:21:05 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: namei.src Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.47.2.6 -r1.47.2.7 src/sys/sys/namei.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/namei.src diff -u src/sys/sys/namei.src:1.47.2.6 src/sys/sys/namei.src:1.47.2.7 --- src/sys/sys/namei.src:1.47.2.6 Fri Jan 24 16:48:59 2020 +++ src/sys/sys/namei.src Wed Mar 4 20:21:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: namei.src,v 1.47.2.6 2020/01/24 16:48:59 ad Exp $ */ +/* $NetBSD: namei.src,v 1.47.2.7 2020/03/04 20:21:05 ad Exp $ */ /* * Copyright (c) 1985, 1989, 1991, 1993 @@ -203,8 +203,7 @@ NAMEIFL PARAMASK 0x02ef800 /* mask of pa * * This structure describes the elements in the cache of recent names looked * up by namei. It's carefully sized to take up 128 bytes on _LP64, to make - * good use of space and the CPU caches; nc_name is aligned on an 8-byte - * boundary to make string comparisons cheaper. + * good use of space and the CPU caches. * * Field markings and their corresponding locks: *
CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Fri Jan 24 16:49:12 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: namei.h Log Message: Regen. To generate a diff of this commit: cvs rdiff -u -r1.103.2.4 -r1.103.2.5 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/sys/namei.h diff -u src/sys/sys/namei.h:1.103.2.4 src/sys/sys/namei.h:1.103.2.5 --- src/sys/sys/namei.h:1.103.2.4 Sun Jan 19 21:24:01 2020 +++ src/sys/sys/namei.h Fri Jan 24 16:49:12 2020 @@ -1,11 +1,11 @@ -/* $NetBSD: namei.h,v 1.103.2.4 2020/01/19 21:24:01 ad Exp $ */ +/* $NetBSD: namei.h,v 1.103.2.5 2020/01/24 16:49:12 ad 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.47.2.5 2020/01/19 21:19:25 ad Exp + * from: NetBSD: namei.src,v 1.47.2.6 2020/01/24 16:48:59 ad Exp */ /* @@ -227,14 +227,13 @@ struct namecache { struct rb_node nc_tree; /* d red-black tree, must be first */ TAILQ_ENTRY(namecache) nc_list; /* v vp's list of cache entries */ TAILQ_ENTRY(namecache) nc_lru; /* l pseudo-lru chain */ - struct nchnode *nc_dnn; /* - nchnode of parent of name */ - struct nchnode *nc_nn; /* - nchnode the name refers to */ + struct vnode *nc_dvp; /* - vnode of parent of name */ struct vnode *nc_vp; /* - vnode the name refers to */ int64_t nc_key; /* - hash key */ int nc_lrulist; /* l which LRU list its on */ short nc_nlen; /* - length of the name */ char nc_whiteout; /* - true if a whiteout */ - char nc_name[33]; /* - segment name */ + char nc_name[41]; /* - segment name */ }; #endif @@ -305,8 +304,7 @@ int cache_revlookup(struct vnode *, stru int cache_diraccess(struct vnode *, int); void cache_enter(struct vnode *, struct vnode *, const char *, size_t, uint32_t); -void cache_set_id(struct vnode *, mode_t, uid_t, gid_t); -void cache_update_id(struct vnode *, mode_t, uid_t, gid_t); +void cache_enter_id(struct vnode *, mode_t, uid_t, gid_t); bool cache_have_id(struct vnode *); void cache_vnode_init(struct vnode * ); void cache_vnode_fini(struct vnode * ); @@ -340,8 +338,6 @@ void namecache_print(struct vnode *, voi type ncs_revhits; /* reverse-cache hits */ \ type ncs_revmiss; /* reverse-cache misses */ \ type ncs_collisions; /* hash value collisions */ \ - type ncs_active; /* active cache entries */ \ - type ncs_inactive; /* inactive cache entries */ \ type ncs_denied; /* access denied */ \ }
CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Thu Jan 23 21:24:54 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: fstypes.h Log Message: Add an IMNT_NCLOOKUP flag to indicate the FS is OK with lookup directly from cache. To generate a diff of this commit: cvs rdiff -u -r1.37.6.1 -r1.37.6.2 src/sys/sys/fstypes.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/sys/fstypes.h diff -u src/sys/sys/fstypes.h:1.37.6.1 src/sys/sys/fstypes.h:1.37.6.2 --- src/sys/sys/fstypes.h:1.37.6.1 Sun Jan 19 21:19:25 2020 +++ src/sys/sys/fstypes.h Thu Jan 23 21:24:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstypes.h,v 1.37.6.1 2020/01/19 21:19:25 ad Exp $ */ +/* $NetBSD: fstypes.h,v 1.37.6.2 2020/01/23 21:24:54 ad Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -220,6 +220,7 @@ typedef struct fhandle fhandle_t; #define IMNT_UNMOUNT 0x0002 /* unmount in progress */ #define IMNT_WANTRDWR 0x0004 /* upgrade to read/write requested */ #define IMNT_WANTRDONLY 0x0008 /* upgrade to readonly requested */ +#define IMNT_NCLOOKUP 0x0020 /* can do lookop direct in namecache */ #define IMNT_DTYPE 0x0040 /* returns d_type fields */ #define IMNT_SHRLOOKUP 0x0080 /* can do LK_SHARED lookups */ #define IMNT_MPSAFE 0x0100 /* file system code MP safe */ @@ -274,6 +275,7 @@ typedef struct fhandle fhandle_t; "\11IMNT_MPSAFE" \ "\10IMNT_SHRLOOKUP" \ "\07IMNT_DTYPE" \ + "\06IMNT_NCLOOKUP" \ "\04IMNT_WANTRDONLY" \ "\03IMNT_WANTRDWR" \ "\02IMNT_UNMOUNT" \
CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Sun Jan 19 21:24:01 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: namei.h Log Message: Regen. To generate a diff of this commit: cvs rdiff -u -r1.103.2.3 -r1.103.2.4 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/sys/namei.h diff -u src/sys/sys/namei.h:1.103.2.3 src/sys/sys/namei.h:1.103.2.4 --- src/sys/sys/namei.h:1.103.2.3 Fri Jan 17 21:47:37 2020 +++ src/sys/sys/namei.h Sun Jan 19 21:24:01 2020 @@ -1,11 +1,11 @@ -/* $NetBSD: namei.h,v 1.103.2.3 2020/01/17 21:47:37 ad Exp $ */ +/* $NetBSD: namei.h,v 1.103.2.4 2020/01/19 21:24:01 ad 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.47.2.3 2020/01/14 11:07:40 ad Exp + * from: NetBSD: namei.src,v 1.47.2.5 2020/01/19 21:19:25 ad Exp */ /* @@ -47,6 +47,7 @@ #ifdef _KERNEL #include +#include /* * Abstraction for a single pathname. @@ -159,13 +160,14 @@ struct nameidata { (pseudo) */ #define EMULROOTSET 0x0080 /* emulation root already in ni_erootdir */ +#define LOCKSHARED 0x0100 /* want shared locks if possible */ #define NOCHROOT 0x0100 /* no chroot on abs path lookups */ -#define MODMASK 0x01fc /* mask of operational modifiers */ +#define MODMASK 0x010001fc /* mask of operational modifiers */ /* * Namei parameter descriptors. */ -#define NOCROSSMOUNT 0x100 /* do not cross mount points */ -#define RDONLY 0x200 /* lookup with read-only semantics */ +#define NOCROSSMOUNT 0x800 /* do not cross mount points */ +#define RDONLY 0x0001000 /* lookup with read-only semantics */ #define ISDOTDOT 0x0002000 /* current component name is .. */ #define MAKEENTRY 0x0004000 /* entry is to be added to name cache */ #define ISLASTCN 0x0008000 /* this is last component of pathname */ @@ -173,7 +175,7 @@ struct nameidata { #define DOWHITEOUT 0x004 /* do whiteouts */ #define REQUIREDIR 0x008 /* must be a directory */ #define CREATEDIR 0x020 /* trailing slashes are ok */ -#define PARAMASK 0x02ee300 /* mask of parameter descriptors */ +#define PARAMASK 0x02ef800 /* mask of parameter descriptors */ /* * Initialization of a nameidata structure. @@ -209,7 +211,8 @@ struct nameidata { * * This structure describes the elements in the cache of recent names looked * up by namei. It's carefully sized to take up 128 bytes on _LP64, to make - * good use of space and the CPU caches. + * good use of space and the CPU caches; nc_name is aligned on an 8-byte + * boundary to make string comparisons cheaper. * * Field markings and their corresponding locks: * @@ -219,16 +222,19 @@ struct nameidata { * l protected by cache_lru_lock * u accesses are unlocked, no serialization applied */ +struct nchnode; struct namecache { - struct rb_node nc_node; /* d red-black tree node */ + struct rb_node nc_tree; /* d red-black tree, must be first */ + TAILQ_ENTRY(namecache) nc_list; /* v vp's list of cache entries */ TAILQ_ENTRY(namecache) nc_lru; /* l pseudo-lru chain */ - TAILQ_ENTRY(namecache) nc_vlist;/* v vp's list of cache entries */ - struct vnode *nc_dvp; /* - vnode of parent of name */ + struct nchnode *nc_dnn; /* - nchnode of parent of name */ + struct nchnode *nc_nn; /* - nchnode the name refers to */ struct vnode *nc_vp; /* - vnode the name refers to */ + int64_t nc_key; /* - hash key */ int nc_lrulist; /* l which LRU list its on */ - u_short nc_nlen; /* - length of name */ - bool nc_whiteout; /* - true if a whiteout */ - char nc_name[49]; /* - segment name */ + short nc_nlen; /* - length of the name */ + char nc_whiteout; /* - true if a whiteout */ + char nc_name[33]; /* - segment name */ }; #endif @@ -292,9 +298,16 @@ bool cache_lookup(struct vnode *, const int *, struct vnode **); bool cache_lookup_raw(struct vnode *, const char *, size_t, uint32_t, int *, struct vnode **); -int cache_revlookup(struct vnode *, struct vnode **, char **, char *); +bool cache_lookup_linked(struct vnode *, const char *, size_t, + struct vnode **, krwlock_t **, kauth_cred_t); +int cache_revlookup(struct vnode *, struct vnode **, char **, char *, + bool, int); +int cache_diraccess(struct vnode *, int); void cache_enter(struct vnode *, struct vnode *, const char *, size_t, uint32_t); +void cache_set_id(struct vnode *, mode_t, uid_t, gid_t); +void cache_update_id(struct vnode *, mode_t, uid_t, gid_t); +bool cache_have_id(struct vnode *); void cache_vnode_init(struct vnode * ); void cache_vnode_fini(struct vnode * ); void cache_cpu_init(struct cpu_info *); @@ -326,6 +339,10 @@ void namecache_print(struct vnode *, voi type ncs_2passes; /* number of times we attempt it (U) */ \
CVS commit: [ad-namecache] src/sys/sys
Module Name:src Committed By: ad Date: Sat Jan 18 17:14:35 UTC 2020 Modified Files: src/sys/sys [ad-namecache]: vnode_if.h Log Message: Regen. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.103.2.1 src/sys/sys/vnode_if.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/sys/vnode_if.h diff -u src/sys/sys/vnode_if.h:1.103 src/sys/sys/vnode_if.h:1.103.2.1 --- src/sys/sys/vnode_if.h:1.103 Sun Dec 1 13:58:53 2019 +++ src/sys/sys/vnode_if.h Sat Jan 18 17:14:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode_if.h,v 1.103 2019/12/01 13:58:53 ad Exp $ */ +/* $NetBSD: vnode_if.h,v 1.103.2.1 2020/01/18 17:14:35 ad Exp $ */ /* * Warning: DO NOT EDIT! This file is automatically generated! @@ -7,7 +7,7 @@ * Created from the file: * NetBSD: vnode_if.src,v 1.78 2019/10/11 08:04:52 hannken Exp * by the script: - * NetBSD: vnode_if.sh,v 1.68 2019/12/01 13:56:29 ad Exp + * NetBSD: vnode_if.sh,v 1.68.2.1 2020/01/18 17:12:59 ad Exp */ /*