15

GFP中的flags是什么意思kmalloc?例如GFP_KERNELGFP_ATOMIC

4

2 回答 2

23

GFP = 获取免费页面 = __get_free_pages

这些标志是传递给分配内存的函数的标志,例如__get_free_pagesand kmalloc,告诉它们在分配时可以做什么和不可以做什么。

例如,GFP_ATOMIC意味着在分配时不必发生上下文切换(这意味着不可能进行分页)。

于 2012-06-27T11:22:25.147 回答
2

查看include/linux/gfp.h文件了解详细信息。

 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)
于 2012-06-27T14:49:29.597 回答