mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
mm: compaction: prevent division-by-zero during user-requested compaction
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.
[akpm@linux-foundation.org: add comment, per Mel]
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3305de51bf
commit
82478fb7bc
1 changed files with 11 additions and 0 deletions
|
@ -406,6 +406,10 @@ static int compact_finished(struct zone *zone,
|
||||||
if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
|
if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
|
||||||
return COMPACT_CONTINUE;
|
return COMPACT_CONTINUE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* order == -1 is expected when compacting via
|
||||||
|
* /proc/sys/vm/compact_memory
|
||||||
|
*/
|
||||||
if (cc->order == -1)
|
if (cc->order == -1)
|
||||||
return COMPACT_CONTINUE;
|
return COMPACT_CONTINUE;
|
||||||
|
|
||||||
|
@ -453,6 +457,13 @@ unsigned long compaction_suitable(struct zone *zone, int order)
|
||||||
if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
|
if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
|
||||||
return COMPACT_SKIPPED;
|
return COMPACT_SKIPPED;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* order == -1 is expected when compacting via
|
||||||
|
* /proc/sys/vm/compact_memory
|
||||||
|
*/
|
||||||
|
if (order == -1)
|
||||||
|
return COMPACT_CONTINUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fragmentation index determines if allocation failures are due to
|
* fragmentation index determines if allocation failures are due to
|
||||||
* low memory or external fragmentation
|
* low memory or external fragmentation
|
||||||
|
|
Loading…
Reference in a new issue