Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of GFP in kmalloc flags?

What is the meaning of GFP flags in kmalloc? For instance GFP_KERNEL, GFP_ATOMIC?

like image 722
user1485214 Avatar asked Jun 27 '12 09:06

user1485214


People also ask

What is GFP in Linux?

* 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.

What is the difference between Kmalloc and Vmalloc?

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.

What is Gfp_kernel?

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.

What is Gfp_atomic?

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.


1 Answers

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).

like image 150
ugoren Avatar answered Oct 12 '22 02:10

ugoren