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);