From: Rik van Riel <riel@redhat.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, Mel Gorman <mel@csn.ul.ie>,
akpm@linux-foundation.org,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
hughd@google.com, aarcange@redhat.com
Subject: [PATCH -mm 1/2] mm: kswapd test order 0 watermarks when compaction is enabled
Date: Mon, 9 Jan 2012 21:33:13 -0500 [thread overview]
Message-ID: <20120109213313.22841ef5@annuminas.surriel.com> (raw)
In-Reply-To: <20120109213156.0ff47ee5@annuminas.surriel.com>
When built with CONFIG_COMPACTION, kswapd does not try to free
contiguous pages. Because it is not trying, it should also not
test whether it succeeded, because that can result in continuous
page reclaim, until a large fraction of memory is free and large
fractions of the working set have been evicted.
Also remove a line of code that increments balanced right before
exiting the function.
Signed-off-by: Rik van Riel <riel@redhat.com>
---
mm/vmscan.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index f54a05b..c3eec6b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2608,7 +2608,7 @@ loop_again:
*/
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
- int nr_slab;
+ int nr_slab, testorder;
unsigned long balance_gap;
if (!populated_zone(zone))
@@ -2637,11 +2637,25 @@ loop_again:
* gap is either the low watermark or 1%
* of the zone, whichever is smaller.
*/
+ testorder = order;
balance_gap = min(low_wmark_pages(zone),
(zone->present_pages +
KSWAPD_ZONE_BALANCE_GAP_RATIO-1) /
KSWAPD_ZONE_BALANCE_GAP_RATIO);
- if (!zone_watermark_ok_safe(zone, order,
+ /*
+ * Kswapd reclaims only single pages when
+ * COMPACTION_BUILD. Trying too hard to get
+ * contiguous free pages can result in excessive
+ * amounts of free memory, and useful things
+ * getting kicked out of memory.
+ * Limit the amount of reclaim to something sane,
+ * plus space for compaction to do its thing.
+ */
+ if (COMPACTION_BUILD) {
+ testorder = 0;
+ balance_gap += 2<<order;
+ }
+ if (!zone_watermark_ok_safe(zone, testorder,
high_wmark_pages(zone) + balance_gap,
end_zone, 0)) {
shrink_zone(priority, zone, &sc);
@@ -2670,7 +2684,7 @@ loop_again:
continue;
}
- if (!zone_watermark_ok_safe(zone, order,
+ if (!zone_watermark_ok_safe(zone, testorder,
high_wmark_pages(zone), end_zone, 0)) {
all_zones_ok = 0;
/*
@@ -2776,8 +2790,6 @@ out:
/* If balanced, clear the congested flag */
zone_clear_flag(zone, ZONE_CONGESTED);
- if (i <= *classzone_idx)
- balanced += zone->present_pages;
}
}
next prev parent reply other threads:[~2012-01-10 2:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-10 2:31 [PATCH -mm 0/2] kswapd vs compaction improvements Rik van Riel
2012-01-10 2:33 ` Rik van Riel [this message]
2012-01-12 15:46 ` [PATCH -mm 1/2] mm: kswapd test order 0 watermarks when compaction is enabled Mel Gorman
2012-01-10 2:33 ` [PATCH -mm 2/2] mm: kswapd carefully invoke compaction Rik van Riel
2012-01-11 7:25 ` KOSAKI Motohiro
2012-01-11 13:34 ` Rik van Riel
2012-01-11 19:57 ` KOSAKI Motohiro
2012-01-12 16:12 ` 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=20120109213313.22841ef5@annuminas.surriel.com \
--to=riel@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kosaki.motohiro@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
/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).