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

三世轮回 提交于 2019-12-03 03:17:31

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5940101/allocating-more-than-4-mb-of-pinned-contiguous-memory-in-the-linux-kernel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!