Re: slab-alignment-rework.patch in -mc

From: Linus Torvalds
Date: Tue Apr 20 2004 - 13:54:21 EST




On Tue, 20 Apr 2004, Andrew Morton wrote:
>
> But why would you choose to make the "SLAB_HWCACHE_ALIGN clear" case use
> sizeof(void*) rather than sizeof(int)?

Because a lot of architectures will cause unaligned faults on structures
that have pointers (or long's) in them if they are only aligned to "int"?

So "int"-aligned is no better than "char" alignment.

I suspect we should make the "minimum normal alignment" be architecture-
dependent, since some architectures can have even stricter requirements
(ie they may have compilers that assume 64-bit alignment for doing things
like multi-word loads).

My suggestion:

- if explicit alignment is passed in (non-zero), always use that. The
user knows best.

This allows a user to specify unaligned ("byte alignment", aka
"align=1") if he wants to.

- if the passed-in alignment was zero, use a CPU-specific alignment which
will depend on SLAB_HWCACHE_ALIGN, and will _usually_ be something like

align = (flags & SLAB_HWCACHE_ALIGN) ? cachelinesize : sizeof(ptr);

but some architecture might choose to do something different here.

Wouldn't that make everybody happy.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/