From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: linux-mm@kvack.org
Subject: [PATCH] mm: Fix theoretical sleeping in atomic.
Date: Tue, 2 Jun 2015 21:37:01 +0900 [thread overview]
Message-ID: <201506022137.FEE05202.FSHtJOVFQFOLOM@I-love.SAKURA.ne.jp> (raw)
>From 7e4775600798d24680ff449412f2d0479711948c Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Tue, 2 Jun 2015 21:14:28 +0900
Subject: [PATCH] mm: Fix theoretical sleeping in atomic.
We could theoretically be too late to warn on
(gfp_mask & (__GFP_NOFAIL | __GFP_WAIT)) == __GFP_NOFAIL
if get_page_from_freelist(ALLOC_NO_WATERMARKS) failed at
__alloc_pages_high_priority(), for wait_iff_congested() in
__alloc_pages_high_priority() might have already slept for
kmalloc(GFP_ATOMIC | __GFP_NOFAIL) allocation request because
ALLOC_NO_WATERMARKS can be automatically supplied due to
e.g. TIF_MEMDIE.
Make sure that __alloc_pages_high_priority() will not loop
unless both __GFP_NOFAIL and __GFP_WAIT are given.
Maybe
if (!wait)
WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
part should be moved to immediately after
if (order >= MAX_ORDER) {
WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
return NULL;
}
?
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
mm/page_alloc.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 73aa335..187a0b5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2880,16 +2880,15 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
{
struct page *page;
- do {
+ for (;;) {
page = get_page_from_freelist(gfp_mask, order,
ALLOC_NO_WATERMARKS, ac);
- if (!page && gfp_mask & __GFP_NOFAIL)
- wait_iff_congested(ac->preferred_zone, BLK_RW_ASYNC,
- HZ/50);
- } while (!page && (gfp_mask & __GFP_NOFAIL));
-
- return page;
+ if (page || (gfp_mask & (__GFP_NOFAIL | __GFP_WAIT)) !=
+ (__GFP_NOFAIL | __GFP_WAIT))
+ return page;
+ wait_iff_congested(ac->preferred_zone, BLK_RW_ASYNC, HZ/50);
+ }
}
static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac)
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
reply other threads:[~2015-06-02 12:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201506022137.FEE05202.FSHtJOVFQFOLOM@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox