linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: Mel Gorman <mel@csn.ul.ie>,
	Andrew Morton <akpm@linux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>,
	Christoph Lameter <cl@linux-foundation.org>,
	Wu Fengguang <fengguang.wu@intel.com>,
	linuxram@us.ibm.com, linux-mm <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] vmscan: Fix use of delta in zone_pagecache_reclaimable()
Date: Mon, 15 Jun 2009 12:14:41 +0100	[thread overview]
Message-ID: <1245064482-19245-2-git-send-email-mel@csn.ul.ie> (raw)
In-Reply-To: <1245064482-19245-1-git-send-email-mel@csn.ul.ie>

zone_pagecache_reclaimable() works out how many pages are in a state
that zone_reclaim() can reclaim based on the current zone_reclaim_mode.
As part of this, it calculates a delta to the number of unmapped pages.
The code was meant to check delta would not cause underflows and then apply
it but it got accidentally removed.

This patch properly uses delta. It's excessively paranoid at the moment
because it's impossible to underflow but the current form will make future
patches to zone_pagecache_reclaimable() fixing any other scan-heuristic
breakage easier to read and acts as self-documentation reminding authors
of future patches to consider underflow.

This is a fix to patch
vmscan-properly-account-for-the-number-of-page-cache-pages-zone_reclaim-can-reclaim.patch
and they should be merged together.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>
---
 mm/vmscan.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 026f452..bd8e3ed 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2398,7 +2398,11 @@ static long zone_pagecache_reclaimable(struct zone *zone)
 	if (!(zone_reclaim_mode & RECLAIM_WRITE))
 		delta += zone_page_state(zone, NR_FILE_DIRTY);
 
-	return nr_pagecache_reclaimable;
+	/* Watch for any possible underflows due to delta */
+	if (unlikely(delta > nr_pagecache_reclaimable))
+		delta = nr_pagecache_reclaimable;
+
+	return nr_pagecache_reclaimable - delta;
 }
 
 /*
-- 
1.5.6.5

--
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:[~2009-06-15 11:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 11:14 [PATCH 0/2] Two fixes for patch vmscan-properly-account-for-the-number-of-page-cache-pages-zone_reclaim-can-reclaim.patch Mel Gorman
2009-06-15 11:14 ` Mel Gorman [this message]
2009-06-16  9:41   ` [PATCH 1/2] vmscan: Fix use of delta in zone_pagecache_reclaimable() KOSAKI Motohiro
2009-06-15 11:14 ` [PATCH 2/2] mm: Fix documentation of min_unmapped_ratio Mel Gorman
2009-06-16  9:41   ` KOSAKI Motohiro

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=1245064482-19245-2-git-send-email-mel@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxram@us.ibm.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).