]> git.hungrycats.org Git - linux/commitdiff
[PATCH] dentry layout tweaks
authorAndrew Morton <akpm@osdl.org>
Fri, 14 May 2004 12:47:27 +0000 (05:47 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 14 May 2004 12:47:27 +0000 (05:47 -0700)
Lookup typically touches three fields of the dentry: d_bucket, d_name.hash and
d_parent.

Change the layout of things so that these will always be in the same
cacheline.

include/linux/dcache.h

index 2735683d6c44b165a5534574676b2c6fb5afed12..255242fef22b6abc6f6b5e008f6625f163eb8cc2 100644 (file)
@@ -27,11 +27,14 @@ struct vfsmount;
 /*
  * "quick string" -- eases parameter passing, but more importantly
  * saves "metadata" about the string (ie length and the hash).
+ *
+ * hash comes first so it snuggles against d_parent and d_bucket in the
+ * dentry.
  */
 struct qstr {
+       unsigned int hash;
        const unsigned char *name;
        unsigned int len;
-       unsigned int hash;
 };
 
 struct dentry_stat_t {
@@ -75,12 +78,23 @@ full_name_hash(const unsigned char *name, unsigned int len)
 
 struct dcookie_struct;
 
+/*
+ * On x86, dentries are a multiple of 16 bytes, with 16-byte alignment.
+ */
 struct dentry {
        atomic_t d_count;
        unsigned int d_flags;           /* protected by d_lock */
        spinlock_t d_lock;              /* per dentry lock */
        struct inode *d_inode;          /* Where the name belongs to - NULL is
                                         * negative */
+       /*
+        * The next three fields are touched by __d_lookup.  Place them here
+        * so they all fit in a 16-byte range, with 16-byte alignment.
+        */
+       struct dentry *d_parent;        /* parent directory */
+       struct hlist_head *d_bucket;    /* lookup hash bucket */
+       struct qstr d_name;
+
        struct list_head d_lru;         /* LRU list */
        struct list_head d_child;       /* child of parent list */
        struct list_head d_subdirs;     /* our children */
@@ -92,10 +106,7 @@ struct dentry {
        void *d_fsdata;                 /* fs-specific data */
        struct rcu_head d_rcu;
        struct dcookie_struct *d_cookie; /* cookie, if any */
-       struct dentry *d_parent;        /* parent directory */
-       struct qstr d_name;
        struct hlist_node d_hash;       /* lookup hash list */  
-       struct hlist_head *d_bucket;    /* lookup hash bucket */
        unsigned char d_iname[0];       /* small names */
 };