Rearrange the struct bufobj and struct vnode layouts to reduce

padding.  On the amd64 kernel with INVARIANTS turned off, size of the
struct vnode is reduced from 496 to 472 bytes, saving 24 bytes of
memory and KVA per vnode.

Noted and reviewed by:	peter
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Konstantin Belousov 2013-01-14 05:46:49 +00:00
parent 614b9f9130
commit ab52a230cf
2 changed files with 23 additions and 21 deletions

View File

@ -89,12 +89,7 @@ struct buf_ops {
struct bufobj {
struct mtx bo_mtx; /* Mutex which protects "i" things */
struct bufv bo_clean; /* i Clean buffers */
struct bufv bo_dirty; /* i Dirty buffers */
long bo_numoutput; /* i Writes in progress */
u_int bo_flag; /* i Flags */
struct buf_ops *bo_ops; /* - Buffer operations */
int bo_bsize; /* - Block size for i/o */
struct vm_object *bo_object; /* v Place to store VM object */
LIST_ENTRY(bufobj) bo_synclist; /* S dirty vnode list */
void *bo_private; /* private pointer */
@ -103,6 +98,11 @@ struct bufobj {
* XXX: only to keep the syncer working
* XXX: for now.
*/
struct bufv bo_clean; /* i Clean buffers */
struct bufv bo_dirty; /* i Dirty buffers */
long bo_numoutput; /* i Writes in progress */
u_int bo_flag; /* i Flags */
int bo_bsize; /* - Block size for i/o */
};
/*

View File

@ -99,7 +99,6 @@ struct vnode {
* Fields which define the identity of the vnode. These fields are
* owned by the filesystem (XXX: and vgone() ?)
*/
enum vtype v_type; /* u vnode type */
const char *v_tag; /* u type of underlying data */
struct vop_vector *v_op; /* u vnode operations vector */
void *v_data; /* u private data for fs */
@ -122,10 +121,10 @@ struct vnode {
} v_un;
/*
* vfs_hash: (mount + inode) -> vnode hash.
* vfs_hash: (mount + inode) -> vnode hash. The hash value
* itself is grouped with other int fields, to avoid padding.
*/
LIST_ENTRY(vnode) v_hashlist;
u_int v_hash;
/*
* VFS_namecache stuff
@ -134,25 +133,12 @@ struct vnode {
TAILQ_HEAD(, namecache) v_cache_dst; /* c Cache entries to us */
struct namecache *v_cache_dd; /* c Cache entry for .. vnode */
/*
* clustering stuff
*/
daddr_t v_cstart; /* v start block of cluster */
daddr_t v_lasta; /* v last allocation */
daddr_t v_lastw; /* v last write */
int v_clen; /* v length of cur. cluster */
/*
* Locking
*/
struct lock v_lock; /* u (if fs don't have one) */
struct mtx v_interlock; /* lock for "i" things */
struct lock *v_vnlock; /* u pointer to vnode lock */
int v_holdcnt; /* i prevents recycling. */
int v_usecount; /* i ref count of users */
u_int v_iflag; /* i vnode flags (see below) */
u_int v_vflag; /* v vnode flags */
int v_writecount; /* v ref count of writers */
/*
* The machinery of being a vnode
@ -167,6 +153,22 @@ struct vnode {
struct label *v_label; /* MAC label for vnode */
struct lockf *v_lockf; /* Byte-level advisory lock list */
struct rangelock v_rl; /* Byte-range lock */
/*
* clustering stuff
*/
daddr_t v_cstart; /* v start block of cluster */
daddr_t v_lasta; /* v last allocation */
daddr_t v_lastw; /* v last write */
int v_clen; /* v length of cur. cluster */
int v_holdcnt; /* i prevents recycling. */
int v_usecount; /* i ref count of users */
u_int v_iflag; /* i vnode flags (see below) */
u_int v_vflag; /* v vnode flags */
int v_writecount; /* v ref count of writers */
u_int v_hash;
enum vtype v_type; /* u vnode type */
};
#endif /* defined(_KERNEL) || defined(_KVM_VNODE) */