Question

Allocating more than 4 MB of pinned contiguous memory in the Linux Kernel

For some interaction with a PCI device that is being built, we'd like to create large contiguous pieces of memory that the board can access. As it stands now, the largest piece of memory that I've been able to allocate is 4 megabytes in size. I'm wondering if there are any methods to create larger regions.

I do know that I can use the boot option mem= to do this, but for numa reasons, I'd rather not go this route. If, on the other hand, someone knew a way to do this, but distribute it over numa nodes, that would be fine.

As I said initially, I'm limited to 4 Megabytes currently. Allocations are currently done by __alloc_pages, which is limited by MAX_ORDER. MAX_ORDER is a compile-time constant, and I'm also concerned that editing it could have affects elsewhere.

Thanks.

 21  9562  21
1 Jan 1970

Solution

 9

If you can compile your PCI device driver into the kernel (that is, not linked as a module), you could try allocating the memory at boot time. That should let you bypass the upper bounds on dynamic allocations. Refer to Linux Device Drivers, ed. 3 ch. 8 for details.

2011-05-09

Solution

 1

CMA(Contiguous Memory Allocator) are the best solution for your need IMO. You just need to ship to the newest kernel.

2012-07-14