From abd25eeff2afe4447c60848402e4abd5a14b232d Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Wed, 27 Jun 2018 22:04:07 +0900 Subject: [PATCH] mm: mm_event: add reclaim stat This patch adds page reclaim mm_event stat so that we could keep tracking [avg|max]_latency for the handling the event as well as count of the event. Direct reclaim latency is usually a most popular latency source caused by memory pressure so we need to track it down to hunt down application's jank problem. Mot-CRs-fixed: (CR) Bug: 80168800 Change-Id: I215c3972f76389404da7c4806a776bf753daac01 Signed-off-by: Minchan Kim Reviewed-on: https://gerrit.mot.com/1453721 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- mm/vmscan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 97857b94d218..0b92919df47f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3056,6 +3056,7 @@ out: unsigned long try_to_free_pages(struct zonelist *zonelist, int order, gfp_t gfp_mask, nodemask_t *nodemask) { + ktime_t event_ts; unsigned long nr_reclaimed; struct scan_control sc = { .nr_to_reclaim = SWAP_CLUSTER_MAX, @@ -3077,6 +3078,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, if (throttle_direct_reclaim(sc.gfp_mask, zonelist, nodemask)) return 1; + mm_event_start(&event_ts); trace_mm_vmscan_direct_reclaim_begin(order, sc.may_writepage, sc.gfp_mask, @@ -3085,6 +3087,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, nr_reclaimed = do_try_to_free_pages(zonelist, &sc); trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); + mm_event_end(MM_RECLAIM, event_ts); return nr_reclaimed; } @@ -3596,6 +3599,7 @@ static int kswapd(void *p) for ( ; ; ) { bool ret; + ktime_t event_ts; alloc_order = reclaim_order = pgdat->kswapd_order; classzone_idx = kswapd_classzone_idx(pgdat, classzone_idx); @@ -3631,7 +3635,9 @@ kswapd_try_sleep: trace_mm_vmscan_kswapd_wake(pgdat->node_id, classzone_idx, alloc_order); fs_reclaim_acquire(GFP_KERNEL); + mm_event_start(&event_ts); reclaim_order = balance_pgdat(pgdat, alloc_order, classzone_idx); + mm_event_end(MM_RECLAIM, event_ts); fs_reclaim_release(GFP_KERNEL); if (reclaim_order < alloc_order) goto kswapd_try_sleep; -- 2.20.1