public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Allocating memory aligned on 1M boundary?
@ 2010-08-25 18:35 david.hagood
  2010-08-25 19:34 ` Timur Tabi
  0 siblings, 1 reply; 2+ messages in thread
From: david.hagood @ 2010-08-25 18:35 UTC (permalink / raw)
  To: linux-kernel

Is there a way to allocate a block of memory that is
a) contiguous in physical layout
b) large (ca. 1M or so)
c) aligned on a large boundary (e.g. 1M boundary) in physical address

I have a hardware device (specifically, the PCIe controller of a Freescale
8641D PPC microprocessor) that requires a large amount of RAM to operate,
and requires that RAM to be aligned on the size of the element (that is,
if you use a 1M buffer, then the starting address of that RAM must be
0x???00000 so that the address translation unit can map from the PCIe
address to the local address).

Hugepages might work, but I see no guarantee that the alignment would be met.

Yes, I could allocate 2x the desired size, then use that part of what I
allocate that is correctly aligned, but then I am guaranteed to waste half
of what I allocate.

I'd rather NOT use the boottime allocation tricks if possible.

Scatter/Gather is not supported by the hardware, so that is out.

Any good suggestions?



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

* Re: Allocating memory aligned on 1M boundary?
  2010-08-25 18:35 Allocating memory aligned on 1M boundary? david.hagood
@ 2010-08-25 19:34 ` Timur Tabi
  0 siblings, 0 replies; 2+ messages in thread
From: Timur Tabi @ 2010-08-25 19:34 UTC (permalink / raw)
  To: david.hagood; +Cc: linux-kernel

On Wed, Aug 25, 2010 at 1:35 PM,  <david.hagood@gmail.com> wrote:

> Yes, I could allocate 2x the desired size, then use that part of what I
> allocate that is correctly aligned, but then I am guaranteed to waste half
> of what I allocate.

You can use the mechanism used in alloc_pages_exact() to free the
pages that you don't need.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

end of thread, other threads:[~2010-08-25 19:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-25 18:35 Allocating memory aligned on 1M boundary? david.hagood
2010-08-25 19:34 ` Timur Tabi

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