mm: mm_event: add reclaim stat
authorMinchan Kim <minchan@google.com>
Wed, 27 Jun 2018 13:04:07 +0000 (22:04 +0900)
committerPDO SCM Team <hudsoncm@motorola.com>
Fri, 15 Nov 2019 06:58:42 +0000 (00:58 -0600)
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 <minchan@google.com>
Reviewed-on: https://gerrit.mot.com/1453721
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

mm/vmscan.c

index 97857b94d218f6c22f8916c859015fef5fed4cb9..0b92919df47fcee334065ad744d738dfd58196ed 100644 (file)
@@ -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;