What is the meaning of GFP
flags in kmalloc
? For instance GFP_KERNEL
, GFP_ATOMIC
?
* GFP flags are commonly used throughout Linux to indicate how memory. * should be allocated. The GFP acronym stands for get_free_pages(), * the underlying memory allocation function.
The kmalloc() function guarantees that the pages are physically contiguous (and virtually contiguous). The vmalloc() function works in a similar fashion to kmalloc() , except it allocates memory that is only virtually contiguous and not necessarily physically contiguous.
The most commonly used allocation flag is GFP_KERNEL means that allocation is performed on behalf of a process running in the kernel space. This means that the calling function is executing a system call on behalf of a process.
GFP_ATOMIC prevents sleeping by telling the memory allocation code that it's not allowed to sleep to satisfy the allocation - that's all. If the memory allocation code needs to sleep, and GFP_ATOMIC has been passed, then it will return an error to the caller instead.
GFP = Get Free Pages = __get_free_pages
.
These flags are flags passed to functions that allocate memory, such as __get_free_pages
and kmalloc
, telling them what can and can't be done while allocating.
For example, GFP_ATOMIC
means no context-switch must happen while allocating (which means paging isn't possible).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With