Kernel Memory Allocation Two mechanisms exist in the kernel for memory allocation by kernel code (and kernel modules): kmalloc, and get_free_page. kmalloc and kfree are very similar to malloc and free as used by user-level C programs. The difference is that we also supply some flags to kmalloc. When writing a kernel module, we'll use the GFP_KERNEL flag. get_free_page is used to allocate full memory pages. It is used by kmalloc to allocate pages when its lists of pre-allocated pages is exhausted. free_page is used to free pages allocated by get_free_page.