2010-07-07 11:12:45 +00:00
|
|
|
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
|
|
|
Subject: [PATCH 10/31] mm: __GFP_MEMALLOC
|
|
|
|
Patch-mainline: not yet
|
|
|
|
|
|
|
|
__GFP_MEMALLOC will allow the allocation to disregard the watermarks,
|
|
|
|
much like PF_MEMALLOC.
|
|
|
|
|
|
|
|
It allows one to pass along the memalloc state in object related allocation
|
|
|
|
flags as opposed to task related flags, such as sk->sk_allocation.
|
|
|
|
|
|
|
|
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
|
|
|
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
|
|
|
|
---
|
2011-04-19 20:09:59 +00:00
|
|
|
include/linux/gfp.h | 4 +++-
|
2010-07-07 11:12:45 +00:00
|
|
|
mm/page_alloc.c | 4 +++-
|
2011-04-19 20:09:59 +00:00
|
|
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
2010-07-07 11:12:45 +00:00
|
|
|
|
|
|
|
--- a/include/linux/gfp.h
|
|
|
|
+++ b/include/linux/gfp.h
|
2011-04-19 20:09:59 +00:00
|
|
|
@@ -23,6 +23,7 @@ struct vm_area_struct;
|
|
|
|
#define ___GFP_REPEAT 0x400u
|
|
|
|
#define ___GFP_NOFAIL 0x800u
|
|
|
|
#define ___GFP_NORETRY 0x1000u
|
|
|
|
+#define ___GFP_MEMALLOC 0x2000u
|
|
|
|
#define ___GFP_COMP 0x4000u
|
|
|
|
#define ___GFP_ZERO 0x8000u
|
|
|
|
#define ___GFP_NOMEMALLOC 0x10000u
|
|
|
|
@@ -73,6 +74,7 @@ struct vm_area_struct;
|
|
|
|
#define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */
|
|
|
|
#define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */
|
|
|
|
#define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */
|
|
|
|
+#define __GFP_MEMALLOC ((__force gfp_t)___GFP_MEMALLOC)/* Use emergency reserves */
|
|
|
|
#define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */
|
|
|
|
#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */
|
|
|
|
#define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves */
|
|
|
|
@@ -119,7 +121,7 @@ struct vm_area_struct;
|
2010-07-07 11:12:45 +00:00
|
|
|
/* Control page allocator reclaim behavior */
|
|
|
|
#define GFP_RECLAIM_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\
|
|
|
|
__GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\
|
|
|
|
- __GFP_NORETRY|__GFP_NOMEMALLOC)
|
|
|
|
+ __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC)
|
|
|
|
|
|
|
|
/* Control slab gfp mask during early boot */
|
2011-04-19 20:09:59 +00:00
|
|
|
#define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_WAIT|__GFP_IO|__GFP_FS))
|
2010-07-07 11:12:45 +00:00
|
|
|
--- a/mm/page_alloc.c
|
|
|
|
+++ b/mm/page_alloc.c
|
2011-04-19 20:09:59 +00:00
|
|
|
@@ -1944,7 +1944,9 @@ int gfp_to_alloc_flags(gfp_t gfp_mask)
|
2010-07-07 11:12:45 +00:00
|
|
|
alloc_flags |= ALLOC_HARDER;
|
|
|
|
|
|
|
|
if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) {
|
2011-04-19 20:09:59 +00:00
|
|
|
- if (!in_irq() && (current->flags & PF_MEMALLOC))
|
2010-07-07 11:12:45 +00:00
|
|
|
+ if (gfp_mask & __GFP_MEMALLOC)
|
|
|
|
+ alloc_flags |= ALLOC_NO_WATERMARKS;
|
2011-04-19 20:09:59 +00:00
|
|
|
+ else if (!in_irq() && (current->flags & PF_MEMALLOC))
|
2010-07-07 11:12:45 +00:00
|
|
|
alloc_flags |= ALLOC_NO_WATERMARKS;
|
|
|
|
else if (!in_interrupt() &&
|
|
|
|
unlikely(test_thread_flag(TIF_MEMDIE)))
|