public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slab debug and ARCH_SLAB_MINALIGN don't get along
@ 2006-10-19 19:57 Kevin Hilman
  2006-10-20  8:56 ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hilman @ 2006-10-19 19:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kevin Hilman

When CONFIG_SLAB_DEBUG is used in combination with ARCH_SLAB_MINALIGN,
some debug flags should be disabled which depend on BYTES_PER_WORD
alignment.

The disabling of these debug flags is not properly handled when
BYTES_PER_WORD < ARCH_SLAB_MEMALIGN < cache_line_size()

This patch fixes that and also adds an alignment check to
cache_alloc_debugcheck_after() when ARCH_SLAB_MINALIGN is used.

Signed-off-by: Kevin Hilman <khilman@mvista.com>
---
 mm/slab.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 266449d..5b71267 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2197,18 +2197,17 @@ #endif
 	if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER)
 		ralign = BYTES_PER_WORD;
 
-	/* 2) arch mandated alignment: disables debug if necessary */
+	/* 2) arch mandated alignment */
 	if (ralign < ARCH_SLAB_MINALIGN) {
 		ralign = ARCH_SLAB_MINALIGN;
-		if (ralign > BYTES_PER_WORD)
-			flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
 	}
-	/* 3) caller mandated alignment: disables debug if necessary */
+	/* 3) caller mandated alignment */
 	if (ralign < align) {
 		ralign = align;
-		if (ralign > BYTES_PER_WORD)
-			flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
 	}
+	/* disable deubg if necessary */
+	if (ralign > BYTES_PER_WORD)
+		flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
 	/*
 	 * 4) Store it.
 	 */
@@ -3063,6 +3062,12 @@ #endif
 
 		cachep->ctor(objp, cachep, ctor_flags);
 	}
+#if ARCH_SLAB_MINALIGN
+	if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
+		printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
+		       objp, ARCH_SLAB_MINALIGN);
+	}
+#endif
 	return objp;
 }
 #else
-- 
1.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] slab debug and ARCH_SLAB_MINALIGN don't get along
  2006-10-19 19:57 [PATCH] slab debug and ARCH_SLAB_MINALIGN don't get along Kevin Hilman
@ 2006-10-20  8:56 ` Pekka Enberg
  2006-10-20 16:22   ` Kevin Hilman
  0 siblings, 1 reply; 3+ messages in thread
From: Pekka Enberg @ 2006-10-20  8:56 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-kernel

Hi Kevin,

On 10/19/06, Kevin Hilman <khilman@mvista.com> wrote:
> When CONFIG_SLAB_DEBUG is used in combination with ARCH_SLAB_MINALIGN,
> some debug flags should be disabled which depend on BYTES_PER_WORD
> alignment.
>
> The disabling of these debug flags is not properly handled when
> BYTES_PER_WORD < ARCH_SLAB_MEMALIGN < cache_line_size()
>
> This patch fixes that and also adds an alignment check to
> cache_alloc_debugcheck_after() when ARCH_SLAB_MINALIGN is used.

You forgot to mention which case you are fixing in the patch
description (that is, SLAB_HWCACHE_ALIGN, when cache_line_size() >
BYTES_PER_WORD) which made the patch bit hard to decipher. Anyway,
looks good, thanks!

                                              Pekka

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] slab debug and ARCH_SLAB_MINALIGN don't get along
  2006-10-20  8:56 ` Pekka Enberg
@ 2006-10-20 16:22   ` Kevin Hilman
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Hilman @ 2006-10-20 16:22 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: linux-kernel

Pekka Enberg wrote:

> On 10/19/06, Kevin Hilman <khilman@mvista.com> wrote:
>> When CONFIG_SLAB_DEBUG is used in combination with ARCH_SLAB_MINALIGN,
>> some debug flags should be disabled which depend on BYTES_PER_WORD
>> alignment.
>>
>> The disabling of these debug flags is not properly handled when
>> BYTES_PER_WORD < ARCH_SLAB_MEMALIGN < cache_line_size()
>>
>> This patch fixes that and also adds an alignment check to
>> cache_alloc_debugcheck_after() when ARCH_SLAB_MINALIGN is used.
> 
> You forgot to mention which case you are fixing in the patch
> description (that is, SLAB_HWCACHE_ALIGN, when cache_line_size() >
> BYTES_PER_WORD) which made the patch bit hard to decipher. Anyway,
> looks good, thanks!

Hi Pekka,

I found this on an ARM platform where ARCH_SLAB_MINALIGN=8, and the
default SLAB_HWCACHE_ALIGN is set also.

The ARM EABI requires 8-byte alignment to take full advantage of 8-byte
loads/stores for ARM arch >= v5.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-20 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-19 19:57 [PATCH] slab debug and ARCH_SLAB_MINALIGN don't get along Kevin Hilman
2006-10-20  8:56 ` Pekka Enberg
2006-10-20 16:22   ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox