diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2017-08-31 19:15:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-08-31 19:33:14 -0400 |
commit | e746bf730a76fe53b82c9e6b6da72d58e9ae3565 (patch) | |
tree | 5d0170fe8a0bbfbbf4940a2c452ce0f505d14ade /mm/page_alloc.c | |
parent | 42ff72cf27027fa28dd79acabe01d9196f1480a7 (diff) |
mm,page_alloc: don't call __node_reclaim() with oom_lock held.
We are doing a last second memory allocation attempt before calling
out_of_memory(). But since slab shrinker functions might indirectly
wait for other thread's __GFP_DIRECT_RECLAIM && !__GFP_NORETRY memory
allocations via sleeping locks, calling slab shrinker functions from
node_reclaim() from get_page_from_freelist() with oom_lock held has
possibility of deadlock. Therefore, make sure that last second memory
allocation attempt does not call slab shrinker functions.
Link: http://lkml.kernel.org/r/1503577106-9196-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7a58eb5757e3..1423da8dd16f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -3291,10 +3291,13 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, | |||
3291 | /* | 3291 | /* |
3292 | * Go through the zonelist yet one more time, keep very high watermark | 3292 | * Go through the zonelist yet one more time, keep very high watermark |
3293 | * here, this is only to catch a parallel oom killing, we must fail if | 3293 | * here, this is only to catch a parallel oom killing, we must fail if |
3294 | * we're still under heavy pressure. | 3294 | * we're still under heavy pressure. But make sure that this reclaim |
3295 | * attempt shall not depend on __GFP_DIRECT_RECLAIM && !__GFP_NORETRY | ||
3296 | * allocation which will never fail due to oom_lock already held. | ||
3295 | */ | 3297 | */ |
3296 | page = get_page_from_freelist(gfp_mask | __GFP_HARDWALL, order, | 3298 | page = get_page_from_freelist((gfp_mask | __GFP_HARDWALL) & |
3297 | ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac); | 3299 | ~__GFP_DIRECT_RECLAIM, order, |
3300 | ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac); | ||
3298 | if (page) | 3301 | if (page) |
3299 | goto out; | 3302 | goto out; |
3300 | 3303 | ||