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 <minchan@google.com>
(cherry picked from commit 04ff5ec537a5f9f546dcb32257d8fbc1f4d9ca2d)
Signed-off-by: Martin Liu <liumartin@google.com>
[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 <surenb@google.com>
Change-Id: Iacdba61298ba15fc71b46e0323b4160f174300b7
This commit is contained in:
Minchan Kim 2019-04-23 00:04:59 +08:00 committed by Saravana Kannan
parent c69ff7a87b
commit 14ede71790
5 changed files with 53 additions and 1 deletions

22
include/linux/mm_event.h Normal file
View File

@ -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

View File

@ -26,6 +26,7 @@
#include <linux/sched/prio.h>
#include <linux/signal_types.h>
#include <linux/mm_types_task.h>
#include <linux/mm_event.h>
#include <linux/task_io_accounting.h>
#include <linux/rseq.h>
@ -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;

View File

@ -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

View File

@ -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

7
mm/mm_event.c Normal file
View File

@ -0,0 +1,7 @@
#include <linux/mm.h>
#include <linux/mm_event.h>
void mm_event_count(enum mm_event_type event, int count)
{
}
EXPORT_SYMBOL_GPL(mm_event_count);