1
我正在开发Linux中的块驱动程序。要求分配一大块内存(例如超过128KB,2MB或8MB ......),将内存分成小垃圾并通过分散 - 收集列表发送。分散收集条目将由用户应用程序控制。分散 - 收集列表上需要的信息
我知道内核中存在严格的内存限制。我怎样才能在内核上实现这一点。任何帮助,高度赞赏。
我正在开发Linux中的块驱动程序。要求分配一大块内存(例如超过128KB,2MB或8MB ......),将内存分成小垃圾并通过分散 - 收集列表发送。分散收集条目将由用户应用程序控制。分散 - 收集列表上需要的信息
我知道内核中存在严格的内存限制。我怎样才能在内核上实现这一点。任何帮助,高度赞赏。
您可以使用vmalloc
从虚拟内存中分配。这样,你可以拥有所有你想要的内存(以内存量为上限)。
/**
* vmalloc - allocate virtually contiguous memory
* @size: allocation size
* Allocate enough pages to cover @size from the page level
* allocator and map them into contiguous kernel virtual space.
*
* For tight control over page level allocator and protection flags
* use __vmalloc() instead.
*/
vmalloc
版内存可以被释放,你猜对了,vfree
。
“块”而不是“垃圾”,哈哈哈。块意味着“块”,垃圾意味着“垃圾”。 – Shahbaz 2015-01-21 15:59:50