From: Rik van Riel <riel@redhat.com>
To: Richard Davies <richard@arachsys.com>
Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, linux-mm@kvack.org,
Mel Gorman <mgorman@suse.de>, Shaohua Li <shli@kernel.org>,
Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] Revert "mm: have order > 0 compaction start near a pageblock with free pages"
Date: Thu, 13 Sep 2012 15:47:40 -0400 [thread overview]
Message-ID: <20120913154740.0d9a9a07@cuia.bos.redhat.com> (raw)
In-Reply-To: <20120912164615.GA14173@alpha.arachsys.com>
On Wed, 12 Sep 2012 17:46:15 +0100
Richard Davies <richard@arachsys.com> wrote:
> Mel Gorman wrote:
> > I see that this is an old-ish bug but I did not read the full history.
> > Is it now booting faster than 3.5.0 was? I'm asking because I'm
> > interested to see if commit c67fe375 helped your particular case.
>
> Yes, I think 3.6.0-rc5 is already better than 3.5.x but can still be
> improved, as discussed.
Re-reading Mel's commit de74f1cc3b1e9730d9b58580cd11361d30cd182d,
I believe it re-introduces the quadratic behaviour that the code
was suffering from before, by not moving zone->compact_cached_free_pfn
down when no more free pfns are found in a page block.
This mail reverts that changeset, the next introduces what I hope to
be the proper fix. Richard, would you be willing to give these patches
a try, since your system seems to reproduce this bug easily?
---8<---
Revert "mm: have order > 0 compaction start near a pageblock with free pages"
This reverts commit de74f1cc3b1e9730d9b58580cd11361d30cd182d.
Mel found a real issue with my "skip ahead" logic in the
compaction code, but unfortunately his approach appears to
have re-introduced quadratic behaviour in that the value
of zone->compact_cached_free_pfn is never advanced until
the compaction run wraps around the start of the zone.
This merely moved the starting point for the quadratic behaviour
further into the zone, but the behaviour has still been observed.
It looks like another fix is required.
Signed-off-by: Rik van Riel <riel@redhat.com>
Reported-by: Richard Davies <richard@daviesmail.org>
diff --git a/mm/compaction.c b/mm/compaction.c
index 7fcd3a5..771775d 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -431,20 +431,6 @@ static bool suitable_migration_target(struct page *page)
}
/*
- * Returns the start pfn of the last page block in a zone. This is the starting
- * point for full compaction of a zone. Compaction searches for free pages from
- * the end of each zone, while isolate_freepages_block scans forward inside each
- * page block.
- */
-static unsigned long start_free_pfn(struct zone *zone)
-{
- unsigned long free_pfn;
- free_pfn = zone->zone_start_pfn + zone->spanned_pages;
- free_pfn &= ~(pageblock_nr_pages-1);
- return free_pfn;
-}
-
-/*
* Based on information in the current compact_control, find blocks
* suitable for isolating free pages from and then isolate them.
*/
@@ -483,6 +469,17 @@ static void isolate_freepages(struct zone *zone,
pfn -= pageblock_nr_pages) {
unsigned long isolated;
+ /*
+ * Skip ahead if another thread is compacting in the area
+ * simultaneously. If we wrapped around, we can only skip
+ * ahead if zone->compact_cached_free_pfn also wrapped to
+ * above our starting point.
+ */
+ if (cc->order > 0 && (!cc->wrapped ||
+ zone->compact_cached_free_pfn >
+ cc->start_free_pfn))
+ pfn = min(pfn, zone->compact_cached_free_pfn);
+
if (!pfn_valid(pfn))
continue;
@@ -533,15 +530,7 @@ static void isolate_freepages(struct zone *zone,
*/
if (isolated) {
high_pfn = max(high_pfn, pfn);
-
- /*
- * If the free scanner has wrapped, update
- * compact_cached_free_pfn to point to the highest
- * pageblock with free pages. This reduces excessive
- * scanning of full pageblocks near the end of the
- * zone
- */
- if (cc->order > 0 && cc->wrapped)
+ if (cc->order > 0)
zone->compact_cached_free_pfn = high_pfn;
}
}
@@ -551,11 +540,6 @@ static void isolate_freepages(struct zone *zone,
cc->free_pfn = high_pfn;
cc->nr_freepages = nr_freepages;
-
- /* If compact_cached_free_pfn is reset then set it now */
- if (cc->order > 0 && !cc->wrapped &&
- zone->compact_cached_free_pfn == start_free_pfn(zone))
- zone->compact_cached_free_pfn = high_pfn;
}
/*
@@ -642,6 +626,20 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
return ISOLATE_SUCCESS;
}
+/*
+ * Returns the start pfn of the last page block in a zone. This is the starting
+ * point for full compaction of a zone. Compaction searches for free pages from
+ * the end of each zone, while isolate_freepages_block scans forward inside each
+ * page block.
+ */
+static unsigned long start_free_pfn(struct zone *zone)
+{
+ unsigned long free_pfn;
+ free_pfn = zone->zone_start_pfn + zone->spanned_pages;
+ free_pfn &= ~(pageblock_nr_pages-1);
+ return free_pfn;
+}
+
static int compact_finished(struct zone *zone,
struct compact_control *cc)
{
next prev parent reply other threads:[~2012-09-13 19:48 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-16 10:47 [Qemu-devel] Windows slow boot: contractor wanted Richard Davies
2012-08-16 11:39 ` Avi Kivity
2012-08-17 12:36 ` Richard Davies
2012-08-17 13:02 ` Robert Vineyard
2012-08-18 14:44 ` Richard Davies
2012-08-19 5:02 ` Brian Jackson
2012-08-20 8:16 ` Richard Davies
2012-08-19 8:40 ` Avi Kivity
2012-08-19 8:51 ` Richard Davies
2012-08-19 14:04 ` Avi Kivity
2012-08-20 13:56 ` Richard Davies
2012-08-21 9:00 ` Avi Kivity
2012-08-21 15:21 ` Richard Davies
2012-08-21 15:39 ` Troy Benjegerdes
2012-08-22 9:08 ` Avi Kivity
2012-08-22 12:40 ` Richard Davies
2012-08-22 12:44 ` Avi Kivity
2012-08-22 14:41 ` Richard Davies
2012-08-22 14:53 ` Avi Kivity
2012-08-22 15:26 ` Richard Davies
2012-08-22 17:22 ` Troy Benjegerdes
2012-08-25 17:51 ` Richard Davies
2012-08-22 15:21 ` Rik van Riel
2012-08-22 15:34 ` Richard Davies
2012-08-25 17:45 ` Richard Davies
2012-08-25 18:11 ` Rik van Riel
2012-08-26 10:58 ` Richard Davies
2012-09-06 9:20 ` Richard Davies
2012-09-12 10:56 ` [Qemu-devel] Windows VM slow boot Richard Davies
2012-09-12 12:25 ` Mel Gorman
2012-09-12 16:46 ` Richard Davies
2012-09-13 9:50 ` Mel Gorman
2012-09-13 19:47 ` Rik van Riel [this message]
2012-09-13 19:48 ` [Qemu-devel] [PATCH 2/2] make the compaction "skip ahead" logic robust Rik van Riel
2012-09-13 19:54 ` [Qemu-devel] [PATCH -v2 " Rik van Riel
2012-09-15 15:55 ` Richard Davies
2012-09-16 19:12 ` Richard Davies
2012-09-17 12:26 ` Mel Gorman
2012-09-18 8:14 ` Richard Davies
2012-09-18 11:21 ` Mel Gorman
2012-09-18 17:58 ` Richard Davies
2012-09-17 13:50 ` Rik van Riel
2012-09-17 14:07 ` Mel Gorman
2012-08-16 14:10 ` [Qemu-devel] Windows slow boot: contractor wanted Benoît Canet
2012-08-16 15:53 ` Troy Benjegerdes
2012-09-18 15:12 ` [Qemu-devel] Windows slow boot Michael Tokarev
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=20120913154740.0d9a9a07@cuia.bos.redhat.com \
--to=riel@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=richard@arachsys.com \
--cc=shli@kernel.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;
as well as URLs for NNTP newsgroup(s).