All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: kmalloc() alignment
@ 2001-03-04 22:41 Manfred Spraul
  2001-03-06  0:06 ` Kenn Humborg
  0 siblings, 1 reply; 21+ messages in thread
From: Manfred Spraul @ 2001-03-04 22:41 UTC (permalink / raw)
  To: kenn; +Cc: linux-kernel

>
> Does kmalloc() make any guarantees of the alignment of allocated 
> blocks? Will the returned block always be 4-, 8- or 16-byte 
> aligned, for example? 
>

4-byte alignment is guaranteed on 32-bit cpus, 8-byte alignment on
64-bit cpus.

--
	Manfred

^ permalink raw reply	[flat|nested] 21+ messages in thread
* kmalloc alignment
@ 2004-10-19 14:51 Atsushi Nemoto
  2004-10-19 16:59 ` Ralf Baechle
  0 siblings, 1 reply; 21+ 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] 21+ messages in thread
* kmalloc alignment
@ 2003-05-05 22:03 Thomas Heinz
  0 siblings, 0 replies; 21+ messages in thread
From: Thomas Heinz @ 2003-05-05 22:03 UTC (permalink / raw)
  To: linux-kernel

Hi

Does the following property hold for kmalloc (2.4.x)?

Allocating a memory block of size: PAGE_SIZE >= 2^i >= 32 (or 64)
returns an address which is at least 2^i bytes aligned.

I flew over the code and as far as I can see the slabs are allocated
via __get_free_pages which returns PAGE_SIZE bytes aligned memory.
Since each slab allocates only blocks of the same size the property
follows immeadiately.

True or not?

Thanks for your help.
BTW, please cc your reply to my private e-mail since I'm currently
not subscribed.


Regards,

Thomas


^ permalink raw reply	[flat|nested] 21+ messages in thread
* kmalloc() alignment
@ 2001-03-04 22:17 Kenn Humborg
  2001-03-04 22:34 ` Alan Cox
  0 siblings, 1 reply; 21+ messages in thread
From: Kenn Humborg @ 2001-03-04 22:17 UTC (permalink / raw)
  To: Linux-Kernel


Does kmalloc() make any guarantees of the alignment of allocated
blocks?  Will the returned block always be 4-, 8- or 16-byte
aligned, for example?

Later,
Kenn


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

end of thread, other threads:[~2004-10-20  5:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-04 22:41 kmalloc() alignment Manfred Spraul
2001-03-06  0:06 ` Kenn Humborg
2001-03-06  0:15   ` H. Peter Anvin
2001-03-06  0:29     ` Kenn Humborg
2001-03-06  2:14       ` Alan Cox
2001-03-06  5:05         ` H. Peter Anvin
2001-03-06  8:31     ` Rogier Wolff
2001-03-06 12:10       ` Xavier Bestel
2001-03-07  7:53       ` RAID, 2.4.2 and Buslogic Jauder Ho
2001-03-07  8:20         ` Andreas Dilger
  -- strict thread matches above, loose matches on Subject: below --
2004-10-19 14:51 kmalloc alignment Atsushi Nemoto
2004-10-19 16:59 ` Ralf Baechle
2004-10-20  5:56   ` Atsushi Nemoto
2003-05-05 22:03 Thomas Heinz
2001-03-04 22:17 kmalloc() alignment Kenn Humborg
2001-03-04 22:34 ` Alan Cox
2001-03-05  9:40   ` Rogier Wolff
2001-03-05 13:24     ` Alan Cox
2001-03-05 13:22       ` Rogier Wolff
2001-03-06  8:59   ` Philipp Rumpf
2001-03-06 12:14     ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.