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