Differences Between kmalloc, malloc, and vmalloc in Linux Systems

malloc: is a function provided by the C standard library, operating in user spaceIt requests memory from the operating system through system calls, then manages these memory pools to allocate to applications. The returned pointer points to a block of memory that is contiguous in the virtual address space, but may not be contiguous at the physical level.kmalloc: is a function provided by the Linux kernel, operating in kernel spaceIt allocates from the kernel’slow memory area. Low memory is linear mapped to the kernel’s virtual address space, with a fixed offset between virtual and physical addresses, and is contiguous at the physical address level. It has higher performance, based on the Slab allocator, and is very efficient for small memory allocations.vmalloc: is a function provided by the Linux kernel, operating in kernel space

It allocates non-contiguous physical memory pages, then modifies the kernel’s page table to map these pages into acontiguous virtual address space.

The pointer it returns points to a block of memory that iscontiguous in virtual address space, but the underlyingphysical page frames are non-contiguous.

Leave a Comment