DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK
Hi,
In dcache.h, DNAME_INLINE_LEN is carefully chosen so that sizeof(struct dentry) is a (specific) multiple of 64 bytes. Obviously this breaks when certain debug options are chosen (DEBUG_LOCK_ALLOC and DEBUG_SPINLOCK), but also, AFAICT, on architectures with CONFIG_GENERIC_LOCKBREAK.
I'm not sure it matters, but if it does, I'd suggest putting a BUILD_BUG_ON somewhere, protected by suitable #ifdefs, so that the code documents the assumptions that went into the particular choice of DNAME_INLINE_LEN (this would also help catch changes to some of the structures embedded in struct dentry which would violate those assumptions).
Rasmus
Something like this, which correctly fails for me on x86_64 when I transplant CONFIG_GENERIC_LOCKBREAK to its Kconfig.
fs/dcache.c +8 -0
@@ -1433,6 +1433,14 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)struct dentry *dentry;char *dname; +#if !defined(CONFIG_DEBUG_LOCK_ALLOC ) && !defined(CONFIG_DEBUG_SPINLOCK ) +# ifdef CONFIG_64BIT +BUILD_BUG_ON (sizeof (struct dentry ) !=192 ); +# else +BUILD_BUG_ON (sizeof (struct dentry ) !=128 ); +# endif +#endif + dentry =kmem_cache_alloc (dentry_cache,GFP_KERNEL );if (!dentry)return NULL ;
Quoted 11 lines · Rasmus Villemoes
In
dcache.h,DNAME_INLINE_LENis carefully chosen so that sizeof(struct dentry) is a (specific) multiple of 64 bytes. Obviously this breaks when certain debug options are chosen (DEBUG_LOCK_ALLOCandDEBUG_SPINLOCK), but also, AFAICT, on architectures withCONFIG_GENERIC_LOCKBREAK.I'm not sure it matters, but if it does, I'd suggest putting a
BUILD_BUG_ONsomewhere, protected by suitable #ifdefs, so that the code documents the assumptions that went into the particular choice ofDNAME_INLINE_LEN(this would also help catch changes to some of the structures embedded in struct dentry which would violate those assumptions).
The right fix would be to pad it correctly for these other variants too.
Checking for magic numbers would be nasty though.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 14 lines · Andi Kleen
Quoted 11 lines · Rasmus Villemoes
In
dcache.h,DNAME_INLINE_LENis carefully chosen so that sizeof(struct dentry) is a (specific) multiple of 64 bytes. Obviously this breaks when certain debug options are chosen (DEBUG_LOCK_ALLOCandDEBUG_SPINLOCK), but also, AFAICT, on architectures withCONFIG_GENERIC_LOCKBREAK.I'm not sure it matters, but if it does, I'd suggest putting a
BUILD_BUG_ONsomewhere, protected by suitable #ifdefs, so that the code documents the assumptions that went into the particular choice ofDNAME_INLINE_LEN(this would also help catch changes to some of the structures embedded in struct dentry which would violate those assumptions).
Quoted 2 lines
The right fix would be to pad it correctly for these other variants too.
IF you've turned on debugging options, then you've already lost more performance that careful packing of the dentry slab cache gains you. There's no point in carefully tuning DNAME_INLINE_LEN for debug options - it's just code that will break and annoy people as debug implementations change.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 5 lines
IF you've turned on debugging options, then you've already lost more performance that careful packing of the dentry slab cache gains you. There's no point in carefully tuning
DNAME_INLINE_LENfor debug options - it's just code that will break and annoy people as debug implementations change.
lockbreak is not a debug option.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.