Author: kib
Date: Mon Jan 14 05:46:49 2013
New Revision: 245410
URL: http://svnweb.freebsd.org/changeset/base/245410

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

Modified:
  head/sys/sys/bufobj.h
  head/sys/sys/vnode.h

Modified: head/sys/sys/bufobj.h
==============================================================================
--- head/sys/sys/bufobj.h       Mon Jan 14 05:45:33 2013        (r245409)
+++ head/sys/sys/bufobj.h       Mon Jan 14 05:46:49 2013        (r245410)
@@ -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 */
 };
 
 /*

Modified: head/sys/sys/vnode.h
==============================================================================
--- head/sys/sys/vnode.h        Mon Jan 14 05:45:33 2013        (r245409)
+++ head/sys/sys/vnode.h        Mon Jan 14 05:46:49 2013        (r245410)
@@ -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
@@ -135,24 +134,11 @@ struct vnode {
        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) */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to