diff options
| author | Mel Gorman <mgorman@suse.de> | 2012-07-31 19:44:03 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-31 21:42:45 -0400 |
| commit | b37f1dd0f543d9714f96c2f9b9f74f7bdfdfdf31 (patch) | |
| tree | 4d01913bd950d60c65605cd14e0ff88b74f5f716 /mm | |
| parent | 5091b74a95d447e34530e713a8971450a45498b3 (diff) | |
mm: introduce __GFP_MEMALLOC to allow access to emergency reserves
__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. This removes the need for ALLOC_PFMEMALLOC as callers
using __GFP_MEMALLOC can get the ALLOC_NO_WATERMARK flag which is now
enough to identify allocations related to page reclaim.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Cc: David Miller <davem@davemloft.net>
Cc: Neil Brown <neilb@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Christoph Lameter <cl@linux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/page_alloc.c | 22 | ||||
| -rw-r--r-- | mm/slab.c | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 38e5be65f24e..8f65abeb9ad6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
| @@ -1513,7 +1513,6 @@ failed: | |||
| 1513 | #define ALLOC_HARDER 0x10 /* try to alloc harder */ | 1513 | #define ALLOC_HARDER 0x10 /* try to alloc harder */ |
| 1514 | #define ALLOC_HIGH 0x20 /* __GFP_HIGH set */ | 1514 | #define ALLOC_HIGH 0x20 /* __GFP_HIGH set */ |
| 1515 | #define ALLOC_CPUSET 0x40 /* check for correct cpuset */ | 1515 | #define ALLOC_CPUSET 0x40 /* check for correct cpuset */ |
| 1516 | #define ALLOC_PFMEMALLOC 0x80 /* Caller has PF_MEMALLOC set */ | ||
| 1517 | 1516 | ||
| 1518 | #ifdef CONFIG_FAIL_PAGE_ALLOC | 1517 | #ifdef CONFIG_FAIL_PAGE_ALLOC |
| 1519 | 1518 | ||
| @@ -2294,11 +2293,10 @@ gfp_to_alloc_flags(gfp_t gfp_mask) | |||
| 2294 | } else if (unlikely(rt_task(current)) && !in_interrupt()) | 2293 | } else if (unlikely(rt_task(current)) && !in_interrupt()) |
| 2295 | alloc_flags |= ALLOC_HARDER; | 2294 | alloc_flags |= ALLOC_HARDER; |
| 2296 | 2295 | ||
| 2297 | if ((current->flags & PF_MEMALLOC) || | 2296 | if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) { |
| 2298 | unlikely(test_thread_flag(TIF_MEMDIE))) { | 2297 | if (gfp_mask & __GFP_MEMALLOC) |
| 2299 | alloc_flags |= ALLOC_PFMEMALLOC; | 2298 | alloc_flags |= ALLOC_NO_WATERMARKS; |
| 2300 | 2299 | else if (likely(!(gfp_mask & __GFP_NOMEMALLOC)) && !in_interrupt()) | |
| 2301 | if (likely(!(gfp_mask & __GFP_NOMEMALLOC)) && !in_interrupt()) | ||
| 2302 | alloc_flags |= ALLOC_NO_WATERMARKS; | 2300 | alloc_flags |= ALLOC_NO_WATERMARKS; |
| 2303 | } | 2301 | } |
| 2304 | 2302 | ||
| @@ -2307,7 +2305,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask) | |||
| 2307 | 2305 | ||
| 2308 | bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) | 2306 | bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) |
| 2309 | { | 2307 | { |
| 2310 | return !!(gfp_to_alloc_flags(gfp_mask) & ALLOC_PFMEMALLOC); | 2308 | return !!(gfp_to_alloc_flags(gfp_mask) & ALLOC_NO_WATERMARKS); |
| 2311 | } | 2309 | } |
| 2312 | 2310 | ||
| 2313 | static inline struct page * | 2311 | static inline struct page * |
| @@ -2498,12 +2496,12 @@ nopage: | |||
| 2498 | return page; | 2496 | return page; |
| 2499 | got_pg: | 2497 | got_pg: |
| 2500 | /* | 2498 | /* |
| 2501 | * page->pfmemalloc is set when the caller had PFMEMALLOC set or is | 2499 | * page->pfmemalloc is set when the caller had PFMEMALLOC set, is |
| 2502 | * been OOM killed. The expectation is that the caller is taking | 2500 | * been OOM killed or specified __GFP_MEMALLOC. The expectation is |
| 2503 | * steps that will free more memory. The caller should avoid the | 2501 | * that the caller is taking steps that will free more memory. The |
| 2504 | * page being used for !PFMEMALLOC purposes. | 2502 | * caller should avoid the page being used for !PFMEMALLOC purposes. |
| 2505 | */ | 2503 | */ |
| 2506 | page->pfmemalloc = !!(alloc_flags & ALLOC_PFMEMALLOC); | 2504 | page->pfmemalloc = !!(alloc_flags & ALLOC_NO_WATERMARKS); |
| 2507 | 2505 | ||
| 2508 | if (kmemcheck_enabled) | 2506 | if (kmemcheck_enabled) |
| 2509 | kmemcheck_pagealloc_alloc(page, order, gfp_mask); | 2507 | kmemcheck_pagealloc_alloc(page, order, gfp_mask); |
| @@ -1884,7 +1884,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) | |||
| 1884 | return NULL; | 1884 | return NULL; |
| 1885 | } | 1885 | } |
| 1886 | 1886 | ||
| 1887 | /* Record if ALLOC_PFMEMALLOC was set when allocating the slab */ | 1887 | /* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */ |
| 1888 | if (unlikely(page->pfmemalloc)) | 1888 | if (unlikely(page->pfmemalloc)) |
| 1889 | pfmemalloc_active = true; | 1889 | pfmemalloc_active = true; |
| 1890 | 1890 | ||
