linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mel@csn.ul.ie>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [patch] mm: compaction: prevent division-by-zero during user-requested compaction
Date: Tue, 18 Jan 2011 18:06:52 +0100	[thread overview]
Message-ID: <1295370412-2645-1-git-send-email-hannes@cmpxchg.org> (raw)

Up until '3e7d344 mm: vmscan: reclaim order-0 and use compaction
instead of lumpy reclaim', compaction skipped calculating the
fragmentation index of a zone when compaction was explicitely
requested through the procfs knob.

However, when compaction_suitable was introduced, it did not come with
an extra check for order == -1, set on explicit compaction requests,
and passed this order on to the fragmentation index calculation, where
it overshifts the number of requested pages, leading to a division by
zero.

This patch makes sure that order == -1 is recognized as the flag it is
rather than passing it along as valid order parameter.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/compaction.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 6d592a0..114c145 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -453,6 +453,9 @@ unsigned long compaction_suitable(struct zone *zone, int order)
 	if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
 		return COMPACT_SKIPPED;
 
+	if (order == -1)
+		return COMPACT_CONTINUE;
+
 	/*
 	 * fragmentation index determines if allocation failures are due to
 	 * low memory or external fragmentation
-- 
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 policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2011-01-18 17:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-18 17:06 Johannes Weiner [this message]
2011-01-18 17:21 ` 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=1295370412-2645-1-git-send-email-hannes@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --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