diff options
author | Jianyu Zhan <nasa4836@gmail.com> | 2014-06-04 19:10:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:11 -0400 |
commit | 4be89a34609659042ef0bf883ad76388fb5251bb (patch) | |
tree | 7a438185cb78e2c6d3aec1e64960e64188cb4afe /mm | |
parent | b7596fb43aa786fb3ee5015a73034fbb9e80feaa (diff) |
mm/vmscan.c: use DIV_ROUND_UP for calculation of zone's balance_gap and correct comments.
Currently, we use (zone->managed_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1)
/ KSWAPD_ZONE_BALANCE_GAP_RATIO to avoid a zero gap value. It's better to
use DIV_ROUND_UP macro for neater code and clear meaning.
Besides, the gap value is calculated against the per-zone "managed pages",
not "present pages". This patch also corrects the comment and do some
rephrasing.
Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: Rafael Aquini <aquini@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/vmscan.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c index 494cd632178c..cc29fca8d989 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -2295,9 +2295,8 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc) | |||
2295 | * there is a buffer of free pages available to give compaction | 2295 | * there is a buffer of free pages available to give compaction |
2296 | * a reasonable chance of completing and allocating the page | 2296 | * a reasonable chance of completing and allocating the page |
2297 | */ | 2297 | */ |
2298 | balance_gap = min(low_wmark_pages(zone), | 2298 | balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP( |
2299 | (zone->managed_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1) / | 2299 | zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO)); |
2300 | KSWAPD_ZONE_BALANCE_GAP_RATIO); | ||
2301 | watermark = high_wmark_pages(zone) + balance_gap + (2UL << sc->order); | 2300 | watermark = high_wmark_pages(zone) + balance_gap + (2UL << sc->order); |
2302 | watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0); | 2301 | watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0); |
2303 | 2302 | ||
@@ -2949,9 +2948,8 @@ static bool kswapd_shrink_zone(struct zone *zone, | |||
2949 | * high wmark plus a "gap" where the gap is either the low | 2948 | * high wmark plus a "gap" where the gap is either the low |
2950 | * watermark or 1% of the zone, whichever is smaller. | 2949 | * watermark or 1% of the zone, whichever is smaller. |
2951 | */ | 2950 | */ |
2952 | balance_gap = min(low_wmark_pages(zone), | 2951 | balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP( |
2953 | (zone->managed_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1) / | 2952 | zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO)); |
2954 | KSWAPD_ZONE_BALANCE_GAP_RATIO); | ||
2955 | 2953 | ||
2956 | /* | 2954 | /* |
2957 | * If there is no low memory pressure or the zone is balanced then no | 2955 | * If there is no low memory pressure or the zone is balanced then no |