mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
lowmemorykiller: trace kill events.
Allows for capturing lmk kill events and their rationale. Change-Id: Ibe215db5bb9806fc550c72c0b9832c85cbd56bf6 Signed-off-by: Martijn Coenen <maco@google.com>
This commit is contained in:
committed by
John Stultz
parent
758a1cb1f6
commit
29d59f1152
@@ -43,6 +43,9 @@
|
||||
#include <linux/profile.h>
|
||||
#include <linux/notifier.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include "trace/lowmemorykiller.h"
|
||||
|
||||
static uint32_t lowmem_debug_level = 1;
|
||||
static short lowmem_adj[6] = {
|
||||
0,
|
||||
@@ -168,6 +171,10 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
|
||||
if (selected->mm)
|
||||
mark_oom_victim(selected);
|
||||
task_unlock(selected);
|
||||
long cache_size = other_file * (long)(PAGE_SIZE / 1024);
|
||||
long cache_limit = minfree * (long)(PAGE_SIZE / 1024);
|
||||
long free = other_free * (long)(PAGE_SIZE / 1024);
|
||||
trace_lowmemory_kill(selected, cache_size, cache_limit, free);
|
||||
lowmem_print(1, "Killing '%s' (%d), adj %hd,\n" \
|
||||
" to free %ldkB on behalf of '%s' (%d) because\n" \
|
||||
" cache %ldkB is below limit %ldkB for oom_score_adj %hd\n" \
|
||||
@@ -176,10 +183,9 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
|
||||
selected_oom_score_adj,
|
||||
selected_tasksize * (long)(PAGE_SIZE / 1024),
|
||||
current->comm, current->pid,
|
||||
other_file * (long)(PAGE_SIZE / 1024),
|
||||
minfree * (long)(PAGE_SIZE / 1024),
|
||||
cache_size, cache_limit,
|
||||
min_score_adj,
|
||||
other_free * (long)(PAGE_SIZE / 1024));
|
||||
free);
|
||||
lowmem_deathpending_timeout = jiffies + HZ;
|
||||
rem += selected_tasksize;
|
||||
}
|
||||
|
||||
41
drivers/staging/android/trace/lowmemorykiller.h
Normal file
41
drivers/staging/android/trace/lowmemorykiller.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_INCLUDE_PATH ../../drivers/staging/android/trace
|
||||
#define TRACE_SYSTEM lowmemorykiller
|
||||
|
||||
#if !defined(_TRACE_LOWMEMORYKILLER_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_LOWMEMORYKILLER_H
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
|
||||
TRACE_EVENT(lowmemory_kill,
|
||||
TP_PROTO(struct task_struct *killed_task, long cache_size, \
|
||||
long cache_limit, long free),
|
||||
|
||||
TP_ARGS(killed_task, cache_size, cache_limit, free),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__array(char, comm, TASK_COMM_LEN)
|
||||
__field(pid_t, pid)
|
||||
__field(long, pagecache_size)
|
||||
__field(long, pagecache_limit)
|
||||
__field(long, free)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
memcpy(__entry->comm, killed_task->comm, TASK_COMM_LEN);
|
||||
__entry->pid = killed_task->pid;
|
||||
__entry->pagecache_size = cache_size;
|
||||
__entry->pagecache_limit = cache_limit;
|
||||
__entry->free = free;
|
||||
),
|
||||
|
||||
TP_printk("%s (%d), page cache %ldkB (limit %ldkB), free %ldKb",
|
||||
__entry->comm, __entry->pid, __entry->pagecache_size,
|
||||
__entry->pagecache_limit, __entry->free)
|
||||
);
|
||||
|
||||
|
||||
#endif /* if !defined(_TRACE_LOWMEMORYKILLER_H) || defined(TRACE_HEADER_MULTI_READ) */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
Reference in New Issue
Block a user