我想分配一个大的 DMA 缓冲区,大小约为 40 MB。当我使用dma_alloc_coherent()
,它失败了,我看到的是:
------------[ cut here ]------------
WARNING: at mm/page_alloc.c:2106 __alloc_pages_nodemask+0x1dc/0x788()
Modules linked in:
[<8004799c>] (unwind_backtrace+0x0/0xf8) from [<80078ae4>] (warn_slowpath_common+0x4c/0x64)
[<80078ae4>] (warn_slowpath_common+0x4c/0x64) from [<80078b18>] (warn_slowpath_null+0x1c/0x24)
[<80078b18>] (warn_slowpath_null+0x1c/0x24) from [<800dfbd0>] (__alloc_pages_nodemask+0x1dc/0x788)
[<800dfbd0>] (__alloc_pages_nodemask+0x1dc/0x788) from [<8004a880>] (__dma_alloc+0xa4/0x2fc)
[<8004a880>] (__dma_alloc+0xa4/0x2fc) from [<8004b0b4>] (dma_alloc_coherent+0x54/0x60)
[<8004b0b4>] (dma_alloc_coherent+0x54/0x60) from [<803ced70>] (mxc_ipu_ioctl+0x270/0x3ec)
[<803ced70>] (mxc_ipu_ioctl+0x270/0x3ec) from [<80123b78>] (do_vfs_ioctl+0x80/0x54c)
[<80123b78>] (do_vfs_ioctl+0x80/0x54c) from [<8012407c>] (sys_ioctl+0x38/0x5c)
[<8012407c>] (sys_ioctl+0x38/0x5c) from [<80041f80>] (ret_fast_syscall+0x0/0x30)
---[ end trace 4e0c10ffc7ffc0d8 ]---
我尝试过不同的值,看起来像dma_alloc_coherent()
无法分配超过 2^25 字节 (32 MB)。
这么大的DMA缓冲区如何分配?
系统启动后dma_alloc_coherent()
对于大量分配不一定可靠。这仅仅是因为不可移动的页面很快就会填满您的物理内存,从而使得大的连续范围变得罕见。这一直是一个问题。
最近的补丁集可能会帮助您,这是内核 3.5 中出现的连续内存分配器。如果您使用带有此功能的内核,那么您应该能够通过cma=64M
在您的内核命令行上,将保留那么多内存(仅可移动页面将放置在那里)。当您随后请求 40M 分配时,它应该可靠地成功。简单!
欲了解更多信息,请查看这篇 LWN 文章:
https://lwn.net/Articles/486301/ https://lwn.net/Articles/486301/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)