What is the meaning of GFP in kmalloc flags?
Asked Answered
G

2

20

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

Gametophyte answered 27/6, 2012 at 9:51 Comment(0)
G
29

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

Gono answered 27/6, 2012 at 11:22 Comment(0)
S
3

Look at the include/linux/gfp.h file for details.

 100 /* This equals 0, but use constants in case they ever change */
 101 #define GFP_NOWAIT      (GFP_ATOMIC & ~__GFP_HIGH)
 102 /* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */
 103 #define GFP_ATOMIC      (__GFP_HIGH)
 104 #define GFP_NOIO        (__GFP_WAIT)
 105 #define GFP_NOFS        (__GFP_WAIT | __GFP_IO)
 106 #define GFP_KERNEL      (__GFP_WAIT | __GFP_IO | __GFP_FS)
 107 #define GFP_TEMPORARY   (__GFP_WAIT | __GFP_IO | __GFP_FS | \
 108                         __GFP_RECLAIMABLE)
 109 #define GFP_USER        (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
 110 #define GFP_HIGHUSER    (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \
 111                         __GFP_HIGHMEM)
 112 #define GFP_HIGHUSER_MOVABLE    (__GFP_WAIT | __GFP_IO | __GFP_FS | \
 113                                 __GFP_HARDWALL | __GFP_HIGHMEM | \
 114                                 __GFP_MOVABLE)
 115 #define GFP_IOFS        (__GFP_IO | __GFP_FS)
 116 #define GFP_TRANSHUGE   (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
 117                         __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \
 118                         __GFP_NO_KSWAPD)
Sent answered 27/6, 2012 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.