From eea9532aabb4efc909d20b4c489c253e58113104 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Mon, 6 Aug 2018 15:07:57 +0900 Subject: [PATCH] mm: mm_event: add swapin stat 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 Reviewed-on: https://gerrit.mot.com/1453723 Tested-by: Jira Key SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- arch/arm64/mm/fault.c | 5 ++++- include/linux/mm.h | 1 + include/linux/mm_event.h | 1 + include/trace/events/mm_event.h | 3 ++- mm/memory.c | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 6a9520698944..a1404ae4a12d 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -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, diff --git a/include/linux/mm.h b/include/linux/mm.h index 5c96d4395948..b14ca733a2b9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -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 */ diff --git a/include/linux/mm_event.h b/include/linux/mm_event.h index 5a9069ea0fa7..2778fa09c650 100644 --- a/include/linux/mm_event.h +++ b/include/linux/mm_event.h @@ -10,6 +10,7 @@ enum mm_event_type { MM_MAJ_FAULT, MM_COMPACTION, MM_RECLAIM, + MM_SWP_FAULT, MM_TYPE_NUM, }; diff --git a/include/trace/events/mm_event.h b/include/trace/events/mm_event.h index f43dee51f46f..34e6d55f0266 100644 --- a/include/trace/events/mm_event.h +++ b/include/trace/events/mm_event.h @@ -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, diff --git a/mm/memory.c b/mm/memory.c index fb9f7737c1ff..16956844e553 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -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; } /* -- 2.20.1