mm: mm_event: add compaction stat
authorMinchan Kim <minchan@google.com>
Wed, 27 Jun 2018 13:04:37 +0000 (22:04 +0900)
committerPDO SCM Team <hudsoncm@motorola.com>
Fri, 15 Nov 2019 06:58:43 +0000 (00:58 -0600)
This patch adds compaction mm_event stat so that we could keep track
latency of compaction as well as count of the event.

Under heavy memory fragmentation, high-order page allocation(e.g.
fork, ION memory allocation) triggers compaction, which is
another major part of latency. Let's track it down, too.

Mot-CRs-fixed: (CR)

Bug: 80168800
Change-Id: Ia3da9324f123ba2542863eafaf72024b5351785b
Signed-off-by: Minchan Kim <minchan@google.com>
Reviewed-on: https://gerrit.mot.com/1453722
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

mm/compaction.c

index f174a8966f1fb59afabfc7b606ab8f22b28d7cbc..c4fd6f95734854152411b7f1dcb5e9683e009165 100644 (file)
@@ -1509,6 +1509,7 @@ static enum compact_result compact_zone(struct zone *zone, struct compact_contro
        unsigned long start_pfn = zone->zone_start_pfn;
        unsigned long end_pfn = zone_end_pfn(zone);
        const bool sync = cc->mode != MIGRATE_ASYNC;
+       ktime_t event_ts;
 
        cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
        ret = compaction_suitable(zone, cc->order, cc->alloc_flags,
@@ -1555,6 +1556,7 @@ static enum compact_result compact_zone(struct zone *zone, struct compact_contro
 
        cc->last_migrated_pfn = 0;
 
+       mm_event_start(&event_ts);
        trace_mm_compaction_begin(start_pfn, cc->migrate_pfn,
                                cc->free_pfn, end_pfn, sync);
 
@@ -1639,6 +1641,7 @@ check_drain:
        }
 
 out:
+       mm_event_end(MM_COMPACTION, event_ts);
        /*
         * Release free pages and update where the free scanner should restart,
         * so we don't leave any returned pages behind in the next attempt.
@@ -1720,6 +1723,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
        struct zoneref *z;
        struct zone *zone;
        enum compact_result rc = COMPACT_SKIPPED;
+       ktime_t event_ts;
 
        /*
         * Check if the GFP flags allow compaction - GFP_NOIO is really
@@ -1728,6 +1732,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
        if (!may_perform_io)
                return COMPACT_SKIPPED;
 
+       mm_event_start(&event_ts);
        trace_mm_compaction_try_to_compact_pages(order, gfp_mask, prio);
 
        /* Compact each zone in the list */
@@ -1777,6 +1782,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
                        break;
        }
 
+       mm_event_end(MM_COMPACTION, event_ts);
        return rc;
 }