* DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK
@ 2014-07-03 9:18 Rasmus Villemoes
2014-07-03 19:53 ` Andi Kleen
0 siblings, 1 reply; 4+ messages in thread
From: Rasmus Villemoes @ 2014-07-03 9:18 UTC (permalink / raw)
To: Nick Piggin, Al Viro; +Cc: linux-fsdevel, linux-kernel
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.
diff --git a/fs/dcache.c b/fs/dcache.c
index 06f6585..aa72a86 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -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;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK
2014-07-03 9:18 DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK Rasmus Villemoes
@ 2014-07-03 19:53 ` Andi Kleen
2014-07-04 1:32 ` Dave Chinner
0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2014-07-03 19:53 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Nick Piggin, Al Viro, linux-fsdevel, linux-kernel
Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
> 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).
The right fix would be to pad it correctly for these other variants
too.
Checking for magic numbers would be nasty though.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK
2014-07-03 19:53 ` Andi Kleen
@ 2014-07-04 1:32 ` Dave Chinner
2014-07-04 3:16 ` Andi Kleen
0 siblings, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2014-07-04 1:32 UTC (permalink / raw)
To: Andi Kleen
Cc: Rasmus Villemoes, Nick Piggin, Al Viro, linux-fsdevel,
linux-kernel
On Thu, Jul 03, 2014 at 12:53:01PM -0700, Andi Kleen wrote:
> Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
>
> > 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).
>
> 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.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK
2014-07-04 1:32 ` Dave Chinner
@ 2014-07-04 3:16 ` Andi Kleen
0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2014-07-04 3:16 UTC (permalink / raw)
To: Dave Chinner
Cc: Andi Kleen, Rasmus Villemoes, Nick Piggin, Al Viro, linux-fsdevel,
linux-kernel
> 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.
lockbreak is not a debug option.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-04 3:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-03 9:18 DNAME_INLINE_LEN versus CONFIG_GENERIC_LOCKBREAK Rasmus Villemoes
2014-07-03 19:53 ` Andi Kleen
2014-07-04 1:32 ` Dave Chinner
2014-07-04 3:16 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox