From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux-foundation.org>,
Mel Gorman <mel@csn.ul.ie>, Rik van Riel <riel@redhat.com>,
Minchan Kim <minchan.kim@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>
Cc: kosaki.motohiro@jp.fujitsu.com
Subject: [PATCH 2/2] vmscan: don't subtraction of unsined
Date: Fri, 25 Jun 2010 20:23:29 +0900 (JST) [thread overview]
Message-ID: <20100625202126.806A.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20100625201915.8067.A69D9226@jp.fujitsu.com>
'slab_reclaimable' and 'nr_pages' are unsigned. so, subtraction is
unsafe.
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/vmscan.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index c927948..b1a90f8 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2612,6 +2612,8 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
slab_reclaimable = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
if (slab_reclaimable > zone->min_slab_pages) {
unsigned long lru_pages = zone_reclaimable_pages(zone);
+ unsigned long srec_new;
+
/*
* shrink_slab() does not currently allow us to determine how
* many pages were freed in this zone. So we take the current
@@ -2622,17 +2624,21 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
* Note that shrink_slab will free memory on all zones and may
* take a long time.
*/
- while (shrink_slab(sc.nr_scanned, gfp_mask, lru_pages) &&
- zone_page_state(zone, NR_SLAB_RECLAIMABLE) >
- slab_reclaimable - nr_pages)
- ;
+ for (;;) {
+ if (!shrink_slab(sc.nr_scanned, gfp_mask, lru_pages))
+ break;
+ srec_new = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
+ if (srec_new + nr_pages <= slab_reclaimable)
+ break;
+ }
/*
* Update nr_reclaimed by the number of slab pages we
* reclaimed from this zone.
*/
- sc.nr_reclaimed += slab_reclaimable -
- zone_page_state(zone, NR_SLAB_RECLAIMABLE);
+ srec_new = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
+ if (srec_new < slab_reclaimable)
+ sc.nr_reclaimed += slab_reclaimable - srec_new;
}
p->reclaim_state = NULL;
--
1.6.5.2
--
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>
next prev parent reply other threads:[~2010-06-25 11:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-25 11:21 [PATCH 1/2] vmscan: shrink_slab() require number of lru_pages, not page order KOSAKI Motohiro
2010-06-25 11:23 ` KOSAKI Motohiro [this message]
2010-06-25 14:17 ` [PATCH 2/2] vmscan: don't subtraction of unsined Christoph Lameter
2010-06-28 2:26 ` KOSAKI Motohiro
2010-06-29 15:14 ` Christoph Lameter
2010-06-25 14:07 ` [PATCH 1/2] vmscan: shrink_slab() require number of lru_pages, not page order Christoph Lameter
2010-06-27 1:03 ` Minchan Kim
2010-06-29 15:19 ` Christoph Lameter
2010-06-28 1:32 ` 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=20100625202126.806A.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=minchan.kim@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