From 14ede7179093de613754b0e80c16205c56c90d6a Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Tue, 23 Apr 2019 00:04:59 +0800 Subject: [PATCH] ANDROID: GKI: add fields from per-process mm event tracking feature mm_event feature exports mm_event_count function and adds new fields in the task_struct. Fix ABI diffs by adding the necessary padding. Bug: 80168800 Bug: 116825053 Bug: 153442668 Test: boot Change-Id: I4e69c994f47402766481c58ab5ec2071180964b8 Signed-off-by: Minchan Kim (cherry picked from commit 04ff5ec537a5f9f546dcb32257d8fbc1f4d9ca2d) Signed-off-by: Martin Liu [surenb: cherry picked and trimmed the original patch to include only necessary changes to resolve ABI diff for task_struct and mm_event_count, changed enum mm_event_type to contain the final members] Bug: 149182139 Test: build and boot Signed-off-by: Suren Baghdasaryan Change-Id: Iacdba61298ba15fc71b46e0323b4160f174300b7 --- include/linux/mm_event.h | 22 ++++++++++++++++++++++ include/linux/sched.h | 6 +++++- mm/Kconfig | 16 ++++++++++++++++ mm/Makefile | 3 +++ mm/mm_event.c | 7 +++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 include/linux/mm_event.h create mode 100644 mm/mm_event.c diff --git a/include/linux/mm_event.h b/include/linux/mm_event.h new file mode 100644 index 000000000000..71962f3955f4 --- /dev/null +++ b/include/linux/mm_event.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_EVENT_H +#define _LINUX_MM_EVENT_H + +enum mm_event_type { + MM_MIN_FAULT = 0, + MM_MAJ_FAULT = 1, + MM_READ_IO = 2, + MM_COMPACTION = 3, + MM_RECLAIM = 4, + MM_SWP_FAULT = 5, + MM_KERN_ALLOC = 6, + MM_TYPE_NUM = 7, +}; + +struct mm_event_task { + unsigned int count; + unsigned int max_lat; + u64 accm_lat; +} __attribute__ ((packed)); + +#endif diff --git a/include/linux/sched.h b/include/linux/sched.h index e0cdbcb3fc7b..f0c271acfa4f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -971,7 +972,10 @@ struct task_struct { /* Deadlock detection and priority inheritance handling: */ struct rt_mutex_waiter *pi_blocked_on; #endif - +#ifdef CONFIG_MM_EVENT_STAT + struct mm_event_task mm_event[MM_TYPE_NUM]; + unsigned long next_period; +#endif #ifdef CONFIG_DEBUG_MUTEXES /* Mutex deadlock detection: */ struct mutex_waiter *blocked_on; diff --git a/mm/Kconfig b/mm/Kconfig index b457e94ae618..036466b34e18 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -614,6 +614,22 @@ config ZSMALLOC_STAT information to userspace via debugfs. If unsure, say N. +config MM_EVENT_STAT + bool "Track per-process MM event" + depends on MMU + help + This option enables per-process mm event stat(e.g., fault, reclaim, + compaction and so on ) with some interval(Default is 0.5sec). + Admin can see the stat from trace file via debugfs(e.g., + /sys/kernel/debug/tracing/trace) + + It includes max/average memory allocation latency for the interval + as well as event count so that admin can see what happens in VM side + (how many each event happens and how much processes spent time for + the MM event). If it's too large, that would be not good situation. + + System can dump the trace into bugreport when user allows the dump. + config GENERIC_EARLY_IOREMAP bool diff --git a/mm/Makefile b/mm/Makefile index 26ef77a3883b..60727566b47e 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -28,6 +28,9 @@ mmu-$(CONFIG_MMU) := gup.o highmem.o memory.o mincore.o \ rmap.o vmalloc.o +ifdef CONFIG_MM_EVENT_STAT +mmu-$(CONFIG_MMU) += mm_event.o +endif ifdef CONFIG_CROSS_MEMORY_ATTACH mmu-$(CONFIG_MMU) += process_vm_access.o endif diff --git a/mm/mm_event.c b/mm/mm_event.c new file mode 100644 index 000000000000..02e1daba6582 --- /dev/null +++ b/mm/mm_event.c @@ -0,0 +1,7 @@ +#include +#include + +void mm_event_count(enum mm_event_type event, int count) +{ +} +EXPORT_SYMBOL_GPL(mm_event_count);