linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Johannes Hirte <johannes.hirte@fem.tu-ilmenau.de>
Cc: akpm@linux-foundation.org, mgorman@suse.de,
	Valdis.Kletnieks@vt.edu, jirislaby@gmail.com, jslaby@suse.cz,
	zkabelac@redhat.com, mm-commits@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: [PATCH] mm,vmscan: free pages if compaction_suitable tells us to
Date: Sun, 25 Nov 2012 13:29:50 -0500	[thread overview]
Message-ID: <20121125132950.11b15e38@annuminas.surriel.com> (raw)
In-Reply-To: <20121125175728.3db4ac6a@fem.tu-ilmenau.de>

On Sun, 25 Nov 2012 17:57:28 +0100
Johannes Hirte <johannes.hirte@fem.tu-ilmenau.de> wrote:

> With kernel 3.7-rc6 I've still problems with kswapd0 on my laptop

> And this is most of the time. I've only observed this behavior on the
> laptop. Other systems don't show this.

This suggests it may have something to do with small memory zones,
where we end up with the "funny" situation that the high watermark
(+ balance gap) for a particular zone is less than the low watermark
+ 2<<order pages, which is the number of free pages required to keep
compaction_suitable happy.

Could you try this patch?

---8<---
Subject: mm,vmscan: free pages if compaction_suitable tells us to

For small zones, it is possible for the low watermark + 2<<order pages
to exceed the high watermark + balance_gap. This could send kswapd into
an infinite loop.

The solution is to always free pages if compaction_suitable indicates
we need to do so.

Signed-off-by: Rik van Riel <riel@redhat.com>
---
 mm/vmscan.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 48550c6..b99ecba 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2614,7 +2614,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
 		 */
 		for (i = 0; i <= end_zone; i++) {
 			struct zone *zone = pgdat->node_zones + i;
-			int nr_slab, testorder;
+			int nr_slab, force_reclaim = 0;
 			unsigned long balance_gap;
 
 			if (!populated_zone(zone))
@@ -2648,21 +2648,21 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
 				(zone->present_pages +
 					KSWAPD_ZONE_BALANCE_GAP_RATIO-1) /
 				KSWAPD_ZONE_BALANCE_GAP_RATIO);
+
 			/*
 			 * Kswapd reclaims only single pages with compaction
-			 * enabled. Trying too hard to reclaim until contiguous
-			 * free pages have become available can hurt performance
-			 * by evicting too much useful data from memory.
-			 * Do not reclaim more than needed for compaction.
+			 * enabled. We reclaim memory if this zone is below
+			 * the normal reclaim watermark, or if there is not
+			 * enough memory available for compaction.
 			 */
-			testorder = order;
 			if (COMPACTION_BUILD && order &&
-					compaction_suitable(zone, order) !=
+					compaction_suitable(zone, order) ==
 						COMPACT_SKIPPED)
-				testorder = 0;
+				force_reclaim = 1;
 
 			if ((buffer_heads_over_limit && is_highmem_idx(i)) ||
-				    !zone_watermark_ok_safe(zone, testorder,
+				    force_reclaim ||
+				    !zone_watermark_ok_safe(zone, 0,
 					high_wmark_pages(zone) + balance_gap,
 					end_zone, 0)) {
 				shrink_zone(zone, &sc);
@@ -2691,7 +2691,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
 				continue;
 			}
 
-			if (!zone_watermark_ok_safe(zone, testorder,
+			if (!zone_watermark_ok_safe(zone, 0,
 					high_wmark_pages(zone), end_zone, 0)) {
 				all_zones_ok = 0;
 				/*

--
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:[~2012-11-25 18:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20121119202152.4B0E420004E@hpza10.eem.corp.google.com>
     [not found] ` <20121125175728.3db4ac6a@fem.tu-ilmenau.de>
2012-11-25 18:29   ` Rik van Riel [this message]
2012-11-25 22:44     ` [PATCH] mm,vmscan: free pages if compaction_suitable tells us to Johannes Weiner
2012-11-25 23:31       ` Rik van Riel
2012-11-26  0:16       ` [PATCH] mm,vmscan: only loop back if compaction would fail in all zones Rik van Riel
2012-11-26  3:15         ` Johannes Weiner
2012-11-26  4:10           ` Johannes Weiner
2012-11-26 11:17             ` Johannes Hirte
2012-11-26 15:32             ` Rik van Riel
2012-11-27 22:35             ` Valdis.Kletnieks
2012-11-26  1:21       ` [PATCH] mm,vmscan: free pages if compaction_suitable tells us to Jaegeuk Hanse

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=20121125132950.11b15e38@annuminas.surriel.com \
    --to=riel@redhat.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=jirislaby@gmail.com \
    --cc=johannes.hirte@fem.tu-ilmenau.de \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mm-commits@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=zkabelac@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).