mm: mm_event: add swapin stat
authorMinchan Kim <minchan@google.com>
Mon, 6 Aug 2018 06:07:57 +0000 (15:07 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:24:01 +0000 (20:24 +0300)
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 2d574897547354a05135044bb10efda7dcb1a2ec..8506ad65c974d6637d8b04a2e52fe64143420e9c 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 bb6f5033dbd3733b27439a2de710f840757a1bc9..e0449a2950e61e91a1be990d8cc0510e0ef4b3f6 100644 (file)
@@ -1197,6 +1197,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 f4649971e0f73f6e3d50b6ecdc0b0dfc0773c005..90b570dd35e9a69888bfa050949825a3db60a93f 100644 (file)
@@ -3167,7 +3167,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);
@@ -3179,7 +3179,7 @@ out_release:
                unlock_page(swapcache);
                put_page(swapcache);
        }
-       return ret;
+       return ret | VM_FAULT_SWAP;
 }
 
 /*