summaryrefslogtreecommitdiffstats
path: root/include/linux/gfp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/gfp.h')
-rw-r--r--include/linux/gfp.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index fb07b503dc45..61f2f6ff9467 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -325,6 +325,29 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
325 return !!(gfp_flags & __GFP_DIRECT_RECLAIM); 325 return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
326} 326}
327 327
328/**
329 * gfpflags_normal_context - is gfp_flags a normal sleepable context?
330 * @gfp_flags: gfp_flags to test
331 *
332 * Test whether @gfp_flags indicates that the allocation is from the
333 * %current context and allowed to sleep.
334 *
335 * An allocation being allowed to block doesn't mean it owns the %current
336 * context. When direct reclaim path tries to allocate memory, the
337 * allocation context is nested inside whatever %current was doing at the
338 * time of the original allocation. The nested allocation may be allowed
339 * to block but modifying anything %current owns can corrupt the outer
340 * context's expectations.
341 *
342 * %true result from this function indicates that the allocation context
343 * can sleep and use anything that's associated with %current.
344 */
345static inline bool gfpflags_normal_context(const gfp_t gfp_flags)
346{
347 return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) ==
348 __GFP_DIRECT_RECLAIM;
349}
350
328#ifdef CONFIG_HIGHMEM 351#ifdef CONFIG_HIGHMEM
329#define OPT_ZONE_HIGHMEM ZONE_HIGHMEM 352#define OPT_ZONE_HIGHMEM ZONE_HIGHMEM
330#else 353#else