From f9b66639b8bbf0a6a8fe449723bda121d06851d3 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Wed, 27 Jun 2018 22:04:37 +0900 Subject: [PATCH] mm: mm_event: add compaction stat 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 Reviewed-on: https://gerrit.mot.com/1453722 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- mm/compaction.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index f174a8966f1f..c4fd6f957348 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -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; } -- 2.20.1