2.1, Kmalloc
void * KMALLOC (size, flags)
Size, which allocates memory sizes. Flags, the flags of distribution, are generally more commonly used as gfp_kernel,gfp_aromic.
Kmalloc application memory, located in the DMA mapping area, most importantly, physically, is also contiguous, and they are only a fixed bargain with real physical addresses. This is critical for DMA.
Kmalloc allocates the size of the memory space, which is generally small compared to the size of 128kb-16b.
When the flags are Gfp_kernel, if the request for memory space is not met, the process will sleep and cause blocking. Therefore, if the flag is gfp_kernel, it cannot appear in the context of interrupts, spin locks, or atomic operations. Therefore, in the context of the interruption, Tasklet, the kernel of the timer, etc. can not appear in the process switch location, you can only use Gfp_atomic to apply for memory, if not at this time, do not wait for sleep, directly to return. 、
Use Kfree to release the requested memory space.
2.2, Vmalloc
Vmalloc uses similar methods, but Vmalloc is generally used for applications with large memory space, and vmalloc the requested memory space is contiguous only in virtual memory space, but in essence, the physical memory space is not necessarily contiguous. Therefore, the requested virtual address space and the actual physical address space do not have a fixed offset relationship.
Vmalloc internal implementation, is the use of the GFP_KERNEL flag Kmalloc to achieve, so, Vmalloc is also not used in the context of atoms.
In the same vein, use Vfree to release memory.