linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm: compaction: prevent division-by-zero during user-requested compaction
@ 2011-01-18 17:06 Johannes Weiner
  2011-01-18 17:21 ` Mel Gorman
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Weiner @ 2011-01-18 17:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mel Gorman, linux-mm, linux-kernel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] mm: compaction: prevent division-by-zero during user-requested compaction
  2011-01-18 17:06 [patch] mm: compaction: prevent division-by-zero during user-requested compaction Johannes Weiner
@ 2011-01-18 17:21 ` Mel Gorman
  0 siblings, 0 replies; 2+ messages in thread
From: Mel Gorman @ 2011-01-18 17:21 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: Andrew Morton, linux-mm, linux-kernel

On Tue, Jan 18, 2011 at 06:06:52PM +0100, Johannes Weiner wrote:
> 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>

It could do with a comment saying that order == -1 is expected when
compacting via /proc/sys/vm/compact_memory but otherwise;

Reviewed-by: Mel Gorman <mel@csn.ul.ie>

> ---
>  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
> 

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-18 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 17:06 [patch] mm: compaction: prevent division-by-zero during user-requested compaction Johannes Weiner
2011-01-18 17:21 ` Mel Gorman

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).