From: Laura Abbott <lauraa@codeaurora.org>
To: Andrew Morton <akpm@linux-foundation.org>, Mel Gorman <mgorman@suse.de>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Vlastimil Babka <vbabka@suse.cz>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Laura Abbott <lauraa@codeaurora.org>
Subject: [PATCH] mm/compaction: Break out of loop on !PageBuddy in isolate_freepages_block
Date: Wed, 5 Mar 2014 18:26:40 -0800 [thread overview]
Message-ID: <1394072800-11776-1-git-send-email-lauraa@codeaurora.org> (raw)
We received several reports of bad page state when freeing CMA pages
previously allocated with alloc_contig_range:
<1>[ 1258.084111] BUG: Bad page state in process Binder_A pfn:63202
<1>[ 1258.089763] page:d21130b0 count:0 mapcount:1 mapping: (null) index:0x7dfbf
<1>[ 1258.096109] page flags: 0x40080068(uptodate|lru|active|swapbacked)
Based on the page state, it looks like the page was still in use. The page
flags do not make sense for the use case though. Further debugging showed
that despite alloc_contig_range returning success, at least one page in the
range still remained in the buddy allocator.
There is an issue with isolate_freepages_block. In strict mode (which CMA
uses), if any pages in the range cannot be isolated, isolate_freepages_block
should return failure 0. The current check keeps track of the total number
of isolated pages and compares against the size of the range:
if (strict && nr_strict_required > total_isolated)
total_isolated = 0;
After taking the zone lock, if one of the pages in the range is not
in the buddy allocator, we continue through the loop and do not
increment total_isolated. If we end up over isolating by more than
one page (e.g. last since page needed is a higher order page), it
is not possible to detect that the page was skipped. The fix is to
bail out if the loop immediately if we are in strict mode. There's
no benfit to continuing anyway since we need all pages to be
isolated.
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
mm/compaction.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/mm/compaction.c b/mm/compaction.c
index b48c525..3190cef 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -263,12 +263,21 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
struct page *page = cursor;
nr_scanned++;
- if (!pfn_valid_within(blockpfn))
- continue;
+ if (!pfn_valid_within(blockpfn)) {
+ if (strict)
+ break;
+ else
+ continue;
+ }
+
if (!valid_page)
valid_page = page;
- if (!PageBuddy(page))
- continue;
+ if (!PageBuddy(page)) {
+ if (strict)
+ break;
+ else
+ continue;
+ }
/*
* The zone lock must be held to isolate freepages.
@@ -288,8 +297,12 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
break;
/* Recheck this is a buddy page under lock */
- if (!PageBuddy(page))
- continue;
+ if (!PageBuddy(page)) {
+ if (strict)
+ break;
+ else
+ continue;
+ }
/* Found a free page, break it into order-0 pages */
isolated = split_free_page(page);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
--
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>
next reply other threads:[~2014-03-06 2:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 2:26 Laura Abbott [this message]
2014-03-06 10:22 ` [PATCH] mm/compaction: Break out of loop on !PageBuddy in isolate_freepages_block Vlastimil Babka
2014-03-06 17:41 ` Laura Abbott
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=1394072800-11776-1-git-send-email-lauraa@codeaurora.org \
--to=lauraa@codeaurora.org \
--cc=akpm@linux-foundation.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).