diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2021-02-21 19:48:49 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2021-02-21 21:07:14 +0000 |
commit | 2443068d486020ed9a4250e0d3b28168c40f741a (patch) | |
tree | b98a63da6fdaad9e83d6a53583df3cf5a048a736 | |
parent | ee9b37ae5c115c41835119bb5c9d2e14c83abd65 (diff) | |
download | src-2443068d486020ed9a4250e0d3b28168c40f741a.tar.gz src-2443068d486020ed9a4250e0d3b28168c40f741a.zip |
vfs: shrink struct vnode to 448 bytes on LP64
... by moving v_hash into a 4 byte hole.
Combined with several previous size reductions this makes the size small
enough to fit 9 vnodes per page as opposed to 8.
Add a compilation time assert so that this is not unknowingly worsened.
Note the structure still remains bigger than it should be.
-rw-r--r-- | sys/sys/vnode.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index d71f3bfcb817..0e46bea14b64 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -109,6 +109,7 @@ struct vnode { short v_irflag; /* i frequently read flags */ seqc_t v_seqc; /* i modification count */ uint32_t v_nchash; /* u namecache hash */ + u_int v_hash; struct vop_vector *v_op; /* u vnode operations vector */ void *v_data; /* u private data for fs */ @@ -172,9 +173,19 @@ struct vnode { int v_writecount; /* I ref count of writers or (negative) text users */ int v_seqc_users; /* i modifications pending */ - u_int v_hash; }; +#ifndef DEBUG_LOCKS +#ifdef _LP64 +/* + * Not crossing 448 bytes fits 9 vnodes per page. If you have to add fields + * to the structure and there is nothing which can be done to prevent growth + * then so be it. But don't grow it without a good reason. + */ +_Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); +#endif +#endif + #endif /* defined(_KERNEL) || defined(_KVM_VNODE) */ #define bo2vnode(bo) __containerof((bo), struct vnode, v_bufobj) |