From: Mel Gorman <mgorman@suse.de>
To: Linux-MM <linux-mm@kvack.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
Minchan Kim <minchan.kim@gmail.com>, Jan Kara <jack@suse.cz>,
Andy Isaacson <adi@hexapodia.org>,
Johannes Weiner <jweiner@redhat.com>,
Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
Nai Xia <nai.xia@gmail.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 6/7] mm: page allocator: Limit when direct reclaim is used when compaction is deferred
Date: Mon, 21 Nov 2011 18:36:47 +0000 [thread overview]
Message-ID: <1321900608-27687-7-git-send-email-mgorman@suse.de> (raw)
In-Reply-To: <1321900608-27687-1-git-send-email-mgorman@suse.de>
If compaction is deferred, we enter direct reclaim to try reclaim the
pages that way. For small high-orders, this has a reasonable chance
of success. However, if the caller as specified __GFP_NO_KSWAPD to
limit the disruption to the system, it makes more sense to fail the
allocation rather than stall the caller in direct reclaim. This patch
will skip direct reclaim if compaction is deferred and the caller
specifies __GFP_NO_KSWAPD.
Async compaction only considers a subset of pages so it is possible for
compaction to be deferred prematurely and not enter direct reclaim even
in cases where it should. To compensate for this, this patch also defers
compaction only if sync compaction failed.
Signed-off-by: Mel Gorman <mgorman@suse.de>
---
mm/page_alloc.c | 45 +++++++++++++++++++++++++++++++++++----------
1 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9dd443d..d979376 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1886,14 +1886,20 @@ static struct page *
__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
struct zonelist *zonelist, enum zone_type high_zoneidx,
nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone,
- int migratetype, unsigned long *did_some_progress,
- bool sync_migration)
+ int migratetype, bool sync_migration,
+ bool *deferred_compaction,
+ unsigned long *did_some_progress)
{
struct page *page;
- if (!order || compaction_deferred(preferred_zone))
+ if (!order)
return NULL;
+ if (compaction_deferred(preferred_zone)) {
+ *deferred_compaction = true;
+ return NULL;
+ }
+
current->flags |= PF_MEMALLOC;
*did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask,
nodemask, sync_migration);
@@ -1921,7 +1927,13 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
* but not enough to satisfy watermarks.
*/
count_vm_event(COMPACTFAIL);
- defer_compaction(preferred_zone);
+
+ /*
+ * As async compaction considers a subset of pageblocks, only
+ * defer if the failure was a sync compaction failure.
+ */
+ if (sync_migration)
+ defer_compaction(preferred_zone);
cond_resched();
}
@@ -1933,8 +1945,9 @@ static inline struct page *
__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
struct zonelist *zonelist, enum zone_type high_zoneidx,
nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone,
- int migratetype, unsigned long *did_some_progress,
- bool sync_migration)
+ int migratetype, bool sync_migration,
+ bool *deferred_compaction,
+ unsigned long *did_some_progress)
{
return NULL;
}
@@ -2084,6 +2097,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
unsigned long pages_reclaimed = 0;
unsigned long did_some_progress;
bool sync_migration = false;
+ bool deferred_compaction = false;
/*
* In the slowpath, we sanity check order to avoid ever trying to
@@ -2164,12 +2178,22 @@ rebalance:
zonelist, high_zoneidx,
nodemask,
alloc_flags, preferred_zone,
- migratetype, &did_some_progress,
- sync_migration);
+ migratetype, sync_migration,
+ &deferred_compaction,
+ &did_some_progress);
if (page)
goto got_pg;
sync_migration = true;
+ /*
+ * If compaction is deferred for high-order allocations, it is because
+ * sync compaction recently failed. In this is the case and the caller
+ * has requested the system not be heavily disrupted, fail the
+ * allocation now instead of entering direct reclaim
+ */
+ if (deferred_compaction && (gfp_mask & __GFP_NO_KSWAPD))
+ goto nopage;
+
/* Try direct reclaim and then allocating */
page = __alloc_pages_direct_reclaim(gfp_mask, order,
zonelist, high_zoneidx,
@@ -2232,8 +2256,9 @@ rebalance:
zonelist, high_zoneidx,
nodemask,
alloc_flags, preferred_zone,
- migratetype, &did_some_progress,
- sync_migration);
+ migratetype, sync_migration,
+ &deferred_compaction,
+ &did_some_progress);
if (page)
goto got_pg;
}
--
1.7.3.4
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-11-21 18:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-21 18:36 [RFC PATCH 0/7] Reduce compaction-related stalls and improve asynchronous migration of dirty pages v4r2 Mel Gorman
2011-11-21 18:36 ` [PATCH 1/7] mm: compaction: Allow compaction to isolate dirty pages Mel Gorman
2011-11-22 16:58 ` Minchan Kim
2011-11-21 18:36 ` [PATCH 2/7] mm: compaction: Use synchronous compaction for /proc/sys/vm/compact_memory Mel Gorman
2011-11-22 17:00 ` Minchan Kim
2011-11-21 18:36 ` [PATCH 3/7] mm: check if we isolated a compound page during lumpy scan Mel Gorman
2011-11-22 17:05 ` Minchan Kim
2011-11-21 18:36 ` [PATCH 4/7] mm: compaction: Determine if dirty pages can be migrated without blocking within ->migratepage Mel Gorman
2011-11-21 18:36 ` [PATCH 5/7] mm: compaction: make isolate_lru_page() filter-aware again Mel Gorman
2011-11-22 17:30 ` Minchan Kim
2011-11-23 9:19 ` Mel Gorman
2011-11-21 18:36 ` Mel Gorman [this message]
2011-11-22 17:50 ` [PATCH 6/7] mm: page allocator: Limit when direct reclaim is used when compaction is deferred Minchan Kim
2011-11-21 18:36 ` [PATCH 7/7] mm: compaction: Introduce sync-light migration for use by compaction Mel Gorman
2011-11-22 6:56 ` Shaohua Li
2011-11-22 10:14 ` Mel Gorman
2011-11-22 11:54 ` Jan Kara
2011-11-22 13:59 ` Nai Xia
2011-11-22 15:07 ` Nai Xia
2011-11-22 19:13 ` Jan Kara
2011-11-22 22:44 ` Nai Xia
2011-11-23 11:39 ` Jan Kara
2011-11-23 12:20 ` Nai Xia
2011-11-23 2:01 ` Nai Xia
2011-11-23 2:25 ` Shaohua Li
2011-11-23 11:00 ` Mel Gorman
2011-11-23 12:51 ` Nai Xia
2011-11-23 13:05 ` Nai Xia
2011-11-23 13:45 ` Mel Gorman
2011-11-23 14:35 ` Nai Xia
2011-11-23 15:08 ` Mel Gorman
2011-11-23 15:23 ` Nai Xia
2011-11-23 15:57 ` Mel Gorman
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=1321900608-27687-7-git-send-email-mgorman@suse.de \
--to=mgorman@suse.de \
--cc=aarcange@redhat.com \
--cc=adi@hexapodia.org \
--cc=jack@suse.cz \
--cc=jweiner@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan.kim@gmail.com \
--cc=nai.xia@gmail.com \
--cc=riel@redhat.com \
/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).