From: Mark Fortescue Verious alignment fixes in the SLAB alocator that increased the size of the RedZone words failed to ensure that RedZone word 2 is aligned on a 64bit boundary. This has resulted in random invalid instruction occourances on Sparc32 (sun4c). By increasing the size of the User Word (BYTES_PER_WORD) to 64bits seams to ensure that correct alignment is maintained but assumes that: sizeof (void *) <= sizeof (unsigned dlong long) Signed-off-by: Mark Fortescue --- Alternative solutions would involve correcting the size caculations on lines 2175 to 2275 and may also involve additional changes to the calculations to get a pointer to the RedZone Word 2. --- linux-2.6/mm/slab.c 2007-07-03 17:35:07.000000000 +0100 +++ linux-test/mm/slab.c 2007-07-03 19:05:19.000000000 +0100 @@ -136,7 +136,8 @@ #endif /* Shouldn't this be in a header file somewhere? */ -#define BYTES_PER_WORD sizeof(void *) +/* Fix alignment of redzone2. Assumes sizeof (void*) <= sizeof (unsigned long long) */ +#define BYTES_PER_WORD sizeof(unsigned long long) #ifndef cache_line_size #define cache_line_size() L1_CACHE_BYTES @@ -538,7 +539,7 @@ static unsigned long long *dbg_redzone1( { BUG_ON(!(cachep->flags & SLAB_RED_ZONE)); return (unsigned long long*) (objp + obj_offset(cachep) - - sizeof(unsigned long long)); + BYTES_PER_WORD); } static unsigned long long *dbg_redzone2(struct kmem_cache *cachep, void *objp) @@ -546,10 +547,9 @@ static unsigned long long *dbg_redzone2( BUG_ON(!(cachep->flags & SLAB_RED_ZONE)); if (cachep->flags & SLAB_STORE_USER) return (unsigned long long *)(objp + cachep->buffer_size - - sizeof(unsigned long long) - - BYTES_PER_WORD); + 2 * BYTES_PER_WORD); return (unsigned long long *) (objp + cachep->buffer_size - - sizeof(unsigned long long)); + BYTES_PER_WORD); } static void **dbg_userword(struct kmem_cache *cachep, void *objp) @@ -2256,8 +2256,8 @@ kmem_cache_create (const char *name, siz */ if (flags & SLAB_RED_ZONE) { /* add space for red zone words */ - cachep->obj_offset += sizeof(unsigned long long); - size += 2 * sizeof(unsigned long long); + cachep->obj_offset += BYTES_PER_WORD; + size += 2 * BYTES_PER_WORD; } if (flags & SLAB_STORE_USER) { /* user store requires one word storage behind the end of