mm: mm_event: add swapin stat
authorMinchan Kim <minchan@google.com>
Mon, 6 Aug 2018 06:07:57 +0000 (15:07 +0900)
committerPDO SCM Team <hudsoncm@motorola.com>
Fri, 15 Nov 2019 06:58:44 +0000 (00:58 -0600)
Many embedded devices use zram as swap. Compared to storage swap
(e.g. UFS), swapin from zram(ie., decompression) is extremly fast
so it might be not major fault but minor. So this patch provides
swapin latency tracking to distinguish them from storage major
fault.

Mot-CRs-fixed: (CR)

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

arch/arm64/mm/fault.c
include/linux/mm.h
include/linux/mm_event.h
include/trace/events/mm_event.h
mm/memory.c

index 6a9520698944b618e6609e33c8118f95df8477d4..a1404ae4a12d60ce1ebdc33e8134622944cc9867 100644 (file)
@@ -510,7 +510,10 @@ retry:
                        tsk->maj_flt++;
                        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
                                      addr);
-                       mm_event_end(MM_MAJ_FAULT, event_ts);
+                       if (fault & VM_FAULT_SWAP)
+                               mm_event_end(MM_SWP_FAULT, event_ts);
+                       else
+                               mm_event_end(MM_MAJ_FAULT, event_ts);
                } else {
                        tsk->min_flt++;
                        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
index 5c96d43959486e95ccce5cf78f1698157e80dd45..b14ca733a2b9b7929ab139cdcd6153cccdd737f8 100644 (file)
@@ -1177,6 +1177,7 @@ static inline void clear_page_pfmemalloc(struct page *page)
 #define VM_FAULT_HWPOISON 0x0010       /* Hit poisoned small page */
 #define VM_FAULT_HWPOISON_LARGE 0x0020  /* Hit poisoned large page. Index encoded in upper bits */
 #define VM_FAULT_SIGSEGV 0x0040
+#define VM_FAULT_SWAP 0x0080
 
 #define VM_FAULT_NOPAGE        0x0100  /* ->fault installed the pte, not return page */
 #define VM_FAULT_LOCKED        0x0200  /* ->fault locked the returned page */
index 5a9069ea0fa755c4cdbe6b548aacf67f6b8a1c29..2778fa09c65088bec2350282db74550dffc3037f 100644 (file)
@@ -10,6 +10,7 @@ enum mm_event_type {
        MM_MAJ_FAULT,
        MM_COMPACTION,
        MM_RECLAIM,
+       MM_SWP_FAULT,
        MM_TYPE_NUM,
 };
 
index f43dee51f46fbad88be85ed65eb63ced7360b7cb..34e6d55f0266cfcb449f10b3bb832e141e01a130 100644 (file)
@@ -15,7 +15,8 @@ struct mm_event_task;
        { MM_MIN_FAULT, "min_flt" },                                    \
        { MM_MAJ_FAULT, "maj_flt" },                                    \
        { MM_COMPACTION, "compaction" },                                \
-       { MM_RECLAIM, "reclaim" })
+       { MM_RECLAIM, "reclaim" },                                      \
+       { MM_SWP_FAULT, "swp_flt" })
 
 TRACE_EVENT(mm_event_record,
 
index fb9f7737c1ff6f043da92339d74dec588c767d9e..16956844e5535450ea80926db381c4b98c34ff52 100644 (file)
@@ -3052,7 +3052,7 @@ int do_swap_page(struct vm_fault *vmf)
 unlock:
        pte_unmap_unlock(vmf->pte, vmf->ptl);
 out:
-       return ret;
+       return ret | VM_FAULT_SWAP;
 out_nomap:
        mem_cgroup_cancel_charge(page, memcg, false);
        pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -3064,7 +3064,7 @@ out_release:
                unlock_page(swapcache);
                put_page(swapcache);
        }
-       return ret;
+       return ret | VM_FAULT_SWAP;
 }
 
 /*