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

Bill Lynch picture Bill Lynch · May 9, 2011 · Viewed 8.6k times · Source

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.

Answer

Karmastan picture Karmastan · May 9, 2011

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.