[Switch] vmalloc, kmalloc, malloc

Transfer from  https://blog.csdn.net/macrossdzh/article/details/5958368

 

 

Dynamic open the device drivers or memory kernel module, not by malloc, but kmalloc, vmalloc, release the memory used it is kfree, vfree, kmalloc function returns a virtual address (linear address). Kmalloc is special in that it is assigned physically contiguous memory, which is very important for the device to perform the DMA. vmalloc and the memory allocation with only continuous linear address, a physical address is not necessarily continuous and can not be used directly in the DMA.

simply put:
kmalloc and vmalloc are allocated kernel memory, malloc allocation is the memory of users
kmalloc ensure that allocated memory is physically contiguous, vmalloc ensure that continuous in the virtual address space, malloc does not guarantee anything (this point own guess is not necessarily correct)
kmalloc can allocate limited size, vmalloc and malloc can allocate a relatively large size of
memory to be accessed only when the DMA only requires physically contiguous
vmalloc slower than kmalloc
 

 

DMA work:

In order to reduce the device quickly into and out of the CPU operation can be referred to a dedicated interface card (DMA Interface) by the batch data transfer process is controlled, so that instead of the CPU card DMA control between the flash device and to transmit data directly to the main memory its mechanism is probably working in DMA mode, CPU only need to give instructions to the DMA controller, DMA controller to allow processing of transmission data, the data transfer is completed and then feedback to the CPU, thus substantially reduce CPU resources share.

    Schematic probably work as follows:

 

 


----------------
Disclaimer: This article is CSDN blogger "macrossdzh 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/macrossdzh/article/details/5958368

Guess you like

Origin www.cnblogs.com/yi-mu-xi/p/12640650.html