* kmalloc alignment
@ 2004-10-19 14:51 Atsushi Nemoto
2004-10-19 16:59 ` Ralf Baechle
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2004-10-19 14:51 UTC (permalink / raw)
To: linux-mips
In include/asm-mips/cache.h:
#define ARCH_KMALLOC_MINALIGN 8
Is this line really needed?
If it was not defined (and ARCH_KMALLOC_FLAGS was also not defined),
default alignment (cache_line_size()) will be used for kmalloc. It is
enough, isn't it?
Also, with current 8 byte alignment, many PCI drivers which are using
kmalloc and dma_map_single are broken on non-coherent system. I was
told that those drivers should use dma_get_cache_alignment() API, but
currently nobody do it anyway. Removing ARCH_KMALLOC_MINALIGN will
help those (broken?) drivers.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: kmalloc alignment
2004-10-19 14:51 kmalloc alignment Atsushi Nemoto
@ 2004-10-19 16:59 ` Ralf Baechle
2004-10-20 5:56 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Ralf Baechle @ 2004-10-19 16:59 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips
On Tue, Oct 19, 2004 at 11:51:29PM +0900, Atsushi Nemoto wrote:
> In include/asm-mips/cache.h:
>
> #define ARCH_KMALLOC_MINALIGN 8
>
> Is this line really needed?
>
> If it was not defined (and ARCH_KMALLOC_FLAGS was also not defined),
> default alignment (cache_line_size()) will be used for kmalloc. It is
> enough, isn't it?
The alignment needs to be large enough to store an arbitrary fundamental
data type including the 64-bit types such as long long or double.
cache_line_size() is only used if a slab has SLAB_HWCACHE_ALIGN set.
The effect of not guaranteeing 8 byte alignment are subtle at times because
the kernel unaligned handling is going to hide the problem. So just
performance will suffer. It used to show up clearly only in the
floating point context switch because we don't support software emulation
of missaligned floating point loads and stores.
> Also, with current 8 byte alignment, many PCI drivers which are using
> kmalloc and dma_map_single are broken on non-coherent system. I was
> told that those drivers should use dma_get_cache_alignment() API, but
> currently nobody do it anyway. Removing ARCH_KMALLOC_MINALIGN will
> help those (broken?) drivers.
The alignment requirements are documented in Documentation/DMA-API.txt
and they are specified the way they are for good reason.
Ralf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: kmalloc alignment
2004-10-19 16:59 ` Ralf Baechle
@ 2004-10-20 5:56 ` Atsushi Nemoto
0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2004-10-20 5:56 UTC (permalink / raw)
To: ralf; +Cc: linux-mips
>>>>> On Tue, 19 Oct 2004 18:59:01 +0200, Ralf Baechle <ralf@linux-mips.org> said:
ralf> The alignment needs to be large enough to store an arbitrary
ralf> fundamental data type including the 64-bit types such as long
ralf> long or double.
ralf> cache_line_size() is only used if a slab has SLAB_HWCACHE_ALIGN
ralf> set.
SLAB_HWCACHE_ALIGN is default ARCH_KMALLOC_FLAGS, so normal kmalloc
will use cache_line_size() (if no ARCH_KMALLOC_MINALIGN).
ralf> The alignment requirements are documented in
ralf> Documentation/DMA-API.txt and they are specified the way they
ralf> are for good reason.
Hmm... I had been thought of many PCI ether driver (which maps
skbuff), but I found skb_init() calls kmem_cache_create with
SLAB_HWCACHE_ALIGN. Maybe I should learn much about it... Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-10-20 5:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-19 14:51 kmalloc alignment Atsushi Nemoto
2004-10-19 16:59 ` Ralf Baechle
2004-10-20 5:56 ` Atsushi Nemoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox