]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Peter Zijlstra <a.p.zijlstra@chello.nl> |
2 | Subject: mm: __GFP_MEMALLOC | |
3 | Patch-mainline: No | |
4 | References: FATE#303834 | |
5 | ||
6 | __GFP_MEMALLOC will allow the allocation to disregard the watermarks, | |
7 | much like PF_MEMALLOC. | |
8 | ||
9 | It allows one to pass along the memalloc state in object related allocation | |
10 | flags as opposed to task related flags, such as sk->sk_allocation. | |
11 | ||
12 | Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> | |
13 | Acked-by: Neil Brown <neilb@suse.de> | |
14 | Acked-by: Suresh Jayaraman <sjayaraman@suse.de> | |
15 | ||
16 | --- | |
17 | include/linux/gfp.h | 3 ++- | |
18 | mm/page_alloc.c | 4 +++- | |
19 | 2 files changed, 5 insertions(+), 2 deletions(-) | |
20 | ||
21 | --- a/include/linux/gfp.h | |
22 | +++ b/include/linux/gfp.h | |
23 | @@ -43,6 +43,7 @@ struct vm_area_struct; | |
24 | #define __GFP_REPEAT ((__force gfp_t)0x400u) /* See above */ | |
25 | #define __GFP_NOFAIL ((__force gfp_t)0x800u) /* See above */ | |
26 | #define __GFP_NORETRY ((__force gfp_t)0x1000u)/* See above */ | |
27 | +#define __GFP_MEMALLOC ((__force gfp_t)0x2000u)/* Use emergency reserves */ | |
28 | #define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ | |
29 | #define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ | |
30 | #define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ | |
31 | @@ -88,7 +89,7 @@ struct vm_area_struct; | |
32 | /* Control page allocator reclaim behavior */ | |
33 | #define GFP_RECLAIM_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\ | |
34 | __GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\ | |
35 | - __GFP_NORETRY|__GFP_NOMEMALLOC) | |
36 | + __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC) | |
37 | ||
38 | /* Control allocation constraints */ | |
39 | #define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE) | |
40 | --- a/mm/page_alloc.c | |
41 | +++ b/mm/page_alloc.c | |
42 | @@ -1480,7 +1480,9 @@ int gfp_to_alloc_flags(gfp_t gfp_mask) | |
43 | alloc_flags |= ALLOC_HARDER; | |
44 | ||
45 | if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) { | |
46 | - if (!in_irq() && (p->flags & PF_MEMALLOC)) | |
47 | + if (gfp_mask & __GFP_MEMALLOC) | |
48 | + alloc_flags |= ALLOC_NO_WATERMARKS; | |
49 | + else if (!in_irq() && (p->flags & PF_MEMALLOC)) | |
50 | alloc_flags |= ALLOC_NO_WATERMARKS; | |
51 | else if (!in_interrupt() && | |
52 | unlikely(test_thread_flag(TIF_MEMDIE))) |