]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: compaction: accounting fix
authorMinchan Kim <minchan.kim@gmail.com>
Wed, 5 Oct 2011 00:43:06 +0000 (11:43 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Oct 2011 06:06:41 +0000 (17:06 +1100)
I saw the following accouting of compaction during test of the series.

compact_blocks_moved 251
compact_pages_moved 44

It's very awkward to me although it's possbile because it means we try to
compact 251 blocks but it just migrated 44 pages.  As further
investigation, I found isolate_migratepages doesn't isolate any pages but
it returns ISOLATE_SUCCESS and then, it just increases
compact_blocks_moved but doesn't increased compact_pages_moved.

This patch makes accouting of compaction works only in case of success of
isolation.

Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
Acked-by: Johannes Weiner <jweiner@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/compaction.c

index 12c3b62e814e74b40ac7a0d367c12a00d271792f..167c8800da60f1abb55dd631175140385c002e8f 100644 (file)
@@ -260,6 +260,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
        unsigned long low_pfn, end_pfn;
        unsigned long last_pageblock_nr = 0, pageblock_nr;
        unsigned long nr_scanned = 0, nr_isolated = 0;
+       isolate_migrate_t ret = ISOLATE_NONE;
        struct list_head *migratelist = &cc->migratepages;
        isolate_mode_t mode = ISOLATE_ACTIVE | ISOLATE_INACTIVE |
                                ISOLATE_UNEVICTABLE;
@@ -273,7 +274,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
        /* Do not cross the free scanner or scan within a memory hole */
        if (end_pfn > cc->free_pfn || !pfn_valid(low_pfn)) {
                cc->migrate_pfn = end_pfn;
-               return ISOLATE_NONE;
+               return ret;
        }
 
        /*
@@ -370,14 +371,17 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
                        break;
        }
 
-       acct_isolated(zone, cc);
+       if (cc->nr_migratepages > 0) {
+               acct_isolated(zone, cc);
+               ret = ISOLATE_SUCCESS;
+       }
 
        spin_unlock_irq(&zone->lru_lock);
        cc->migrate_pfn = low_pfn;
 
        trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated);
 
-       return ISOLATE_SUCCESS;
+       return ret;
 }
 
 /*