Type flags

With so many categories of modifier flags (each addressing different attributes), programmers exercise extreme care when choosing flags for corresponding allocations. To make the process easier and quicker, type flags were introduced, which enable programmers to make quick allocation choices. Type flags are derived from combinations of various modifier constants (listed previously) for specific allocation use cases. Programmers however can further customize type flags if required:

#define GFP_ATOMIC (__GFP_HIGH|__GFP_ATOMIC|__GFP_KSWAPD_RECLAIM)
#define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS)
#define GFP_KERNEL_ACCOUNT (GFP_KERNEL | __GFP_ACCOUNT)
#define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM)
#define GFP_NOIO (__GFP_RECLAIM)
#define GFP_NOFS (__GFP_RECLAIM | __GFP_IO)
#define GFP_TEMPORARY (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_RECLAIMABLE)
#define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
#define GFP_DMA __GFP_DMA
#define GFP_DMA32 __GFP_DMA32
#define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM)
#define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE)
#define GFP_TRANSHUGE_LIGHT ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
#define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)

The following is the list of type flags:

  • GFP_ATOMIC: This flag is specified for non blocking allocations that cannot fail. This flag will cause allocations from emergency reserves. This is generally used while invoking the allocator from an atomic context.
  • GFP_KERNEL: This flag is used while allocating memory for kernel use. These requests are processed from normal zone. This flag might cause the allocator to enter direct reclaim.
  • GFP_KERNEL_ACCOUNT: Same as GFP_KERNEL with an addition that allocation is tracked by the kmem control group.
  • GFP_NOWAIT: This flag is used for kernel allocations that are non-blocking.
  • GFP_NOIO: This flag allows the allocator to begin direct reclaim on clean pages that do not require physical I/O(swap).
  • GFP_NOFS: This flag allows the allocator to begin direct reclaim but prevents invocation of filesystem interfaces.
  • GFP_TEMPORARY: This flag is used while allocating pages for kernel caches, which are reclaimable through the appropriate shrinker interface. This flag sets the __GFP_RECLAIMABLE flag we discussed earlier.
  • GFP_USER: This flag is used for user-space allocations. Memory allocated is mapped to a user process and can also be accessed by kernel services or hardware for DMA transfers from device into buffer or vice versa.
  • GFP_DMA: This flag causes allocation from the lowest zone, called ZONE_DMA. This flag is still supported for backward compatibility.
  • GFP_DMA32: This flag causes allocation to be processed from ZONE_DMA32 which contains pages in < 4G memory.
  • GFP_HIGHUSER: This flag is used for user space allocations from ZONE_HIGHMEM (relevant only on 32-bit platforms).
  • GFP_HIGHUSER_MOVABLE: This flag is similar to GFP_HIGHUSER, with an addition that allocations are carried out from movable pages, which enables page migration and reclaim.
  • GFP_TRANSHUGE_LIGHT: This causes the allocation of transparent huge allocations (THP), which are compound allocations. This type flag sets __GFP_COMP, which we discussed earlier.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.150.163