Experimenting with various values of DENTRY_STORAGE dentry size objs/slab dentry size * objs/slab inline string 148 26 3848 32 152 26 3952 36 156 25 3900 40 160 24 4000 44 We're currently at 160. The patch fairly arbitrarily takes it down to 152, so we can fit a 35-char name into the inline part of the dentry. Also, go back to the old way of sizing d_iname so that any arch-specific compiler-forced alignemnts are honoured. --- 25-akpm/fs/dcache.c | 9 ++------- 25-akpm/include/linux/dcache.h | 7 +++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff -puN fs/dcache.c~dentry-size-tuning fs/dcache.c --- 25/fs/dcache.c~dentry-size-tuning 2004-05-14 22:29:09.222244904 -0700 +++ 25-akpm/fs/dcache.c 2004-05-14 22:29:09.228243992 -0700 @@ -41,12 +41,7 @@ EXPORT_SYMBOL(dcache_lock); static kmem_cache_t *dentry_cache; -/* - * The allocation size for each dentry. It is a multiple of 16 bytes. We - * leave the final 32-47 bytes for the inline name. - */ -#define DENTRY_STORAGE (((sizeof(struct dentry)+32) + 15) & ~15) -#define DNAME_INLINE_LEN (DENTRY_STORAGE - sizeof(struct dentry)) +#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname)) /* * This is the single most critical data structure when it comes @@ -1573,7 +1568,7 @@ static void __init dcache_init(unsigned * of the dcache. */ dentry_cache = kmem_cache_create("dentry_cache", - DENTRY_STORAGE, + sizeof(struct dentry), 0, SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, NULL, NULL); diff -puN include/linux/dcache.h~dentry-size-tuning include/linux/dcache.h --- 25/include/linux/dcache.h~dentry-size-tuning 2004-05-14 22:29:09.224244600 -0700 +++ 25-akpm/include/linux/dcache.h 2004-05-14 22:29:09.229243840 -0700 @@ -78,9 +78,8 @@ full_name_hash(const unsigned char *name struct dcookie_struct; -/* - * On x86, dentries are a multiple of 16 bytes, with 16-byte alignment. - */ +#define DNAME_INLINE_LEN_MIN 36 + struct dentry { atomic_t d_count; unsigned int d_flags; /* protected by d_lock */ @@ -107,7 +106,7 @@ struct dentry { struct rcu_head d_rcu; struct dcookie_struct *d_cookie; /* cookie, if any */ struct hlist_node d_hash; /* lookup hash list */ - unsigned char d_iname[0]; /* small names */ + unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ }; struct dentry_operations { _