summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZlatko Calusic <zlatko.calusic@iskon.hr>2013-02-22 16:32:34 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 17:50:10 -0800
commitdafcb73e385e39b9a7ebd5c4ecbc4ae921862eb9 (patch)
tree407a7710a7c4c6382bb9d415cd8de05430821600
parent7103f16dbff20fa969c9500902d980d17f953fa6 (diff)
downloadlinux-dafcb73e385e39b9a7ebd5c4ecbc4ae921862eb9.tar.bz2
mm: avoid calling pgdat_balanced() needlessly
Now that balance_pgdat() is slightly tidied up, thanks to more capable pgdat_balanced(), it's become obvious that pgdat_balanced() is called to check the status, then break the loop if pgdat is balanced, just to be immediately called again. The second call is completely unnecessary, of course. The patch introduces pgdat_is_balanced boolean, which helps resolve the above suboptimal behavior, with the added benefit of slightly better documenting one other place in the function where we jump and skip lots of code. Signed-off-by: Zlatko Calusic <zlatko.calusic@iskon.hr> Cc: Mel Gorman <mgorman@suse.de> Cc: Hugh Dickins <hughd@google.com> Cc: Minchan Kim <minchan.kim@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/vmscan.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 463990941a78..4093b99044f6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2616,6 +2616,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,
static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
int *classzone_idx)
{
+ bool pgdat_is_balanced = false;
struct zone *unbalanced_zone;
int i;
int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */
@@ -2690,8 +2691,11 @@ loop_again:
zone_clear_flag(zone, ZONE_CONGESTED);
}
}
- if (i < 0)
+
+ if (i < 0) {
+ pgdat_is_balanced = true;
goto out;
+ }
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
@@ -2818,8 +2822,11 @@ loop_again:
pfmemalloc_watermark_ok(pgdat))
wake_up(&pgdat->pfmemalloc_wait);
- if (pgdat_balanced(pgdat, order, *classzone_idx))
+ if (pgdat_balanced(pgdat, order, *classzone_idx)) {
+ pgdat_is_balanced = true;
break; /* kswapd: all done */
+ }
+
/*
* OK, kswapd is getting into trouble. Take a nap, then take
* another pass across the zones.
@@ -2840,9 +2847,9 @@ loop_again:
if (sc.nr_reclaimed >= SWAP_CLUSTER_MAX)
break;
} while (--sc.priority >= 0);
-out:
- if (!pgdat_balanced(pgdat, order, *classzone_idx)) {
+out:
+ if (!pgdat_is_balanced) {
cond_resched();
try_to_freeze();