From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Martijn Coenen <maco@google.com>,
Android Kernel Team <kernel-team@android.com>,
Greg KH <gregkh@linuxfoundation.org>,
John Stultz <john.stultz@linaro.org>
Subject: [PATCH 5/9] staging: lowmemorykiller: Trace kill events.
Date: Fri, 29 Jan 2016 22:07:34 -0800 [thread overview]
Message-ID: <1454134058-16466-6-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1454134058-16466-1-git-send-email-john.stultz@linaro.org>
From: Martijn Coenen <maco@google.com>
Allows for capturing lmk kill events and
their rationale.
Cc: Android Kernel Team <kernel-team@android.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Martijn Coenen <maco@google.com>
[jstultz: Checkpatch fixups]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drivers/staging/android/lowmemorykiller.c | 14 +++++++--
drivers/staging/android/trace/lowmemorykiller.h | 40 +++++++++++++++++++++++++
2 files changed, 51 insertions(+), 3 deletions(-)
create mode 100644 drivers/staging/android/trace/lowmemorykiller.h
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 98abec7..bda0e8a 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -42,6 +42,9 @@
#include <linux/rcupdate.h>
#include <linux/notifier.h>
+#define CREATE_TRACE_POINTS
+#include "trace/lowmemorykiller.h"
+
static u32 lowmem_debug_level = 1;
static short lowmem_adj[6] = {
0,
@@ -157,6 +160,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
p->comm, p->pid, oom_score_adj, tasksize);
}
if (selected) {
+ long cache_size, cache_limit, free;
+
task_lock(selected);
send_sig(SIGKILL, selected, 0);
/*
@@ -167,6 +172,10 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
if (selected->mm)
mark_oom_victim(selected);
task_unlock(selected);
+ cache_size = other_file * (long)(PAGE_SIZE / 1024);
+ cache_limit = minfree * (long)(PAGE_SIZE / 1024);
+ 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"
@@ -175,10 +184,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;
}
diff --git a/drivers/staging/android/trace/lowmemorykiller.h b/drivers/staging/android/trace/lowmemorykiller.h
new file mode 100644
index 0000000..7d01bd4
--- /dev/null
+++ b/drivers/staging/android/trace/lowmemorykiller.h
@@ -0,0 +1,40 @@
+#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 /* !defined(_TRACE_LOWMEMORYKILLER_H) || defined(TRACE_HEADER_MULTI_READ) */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
1.9.1
next prev parent reply other threads:[~2016-01-30 6:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-30 6:07 [PATCH 0/9] staging: Updates from the Android tree John Stultz
2016-01-30 6:07 ` [PATCH 1/9] staging: ashmem: Avoid deadlock with mmap/shrink John Stultz
2016-01-30 6:07 ` [PATCH 2/9] staging: ashmem: Add missing include John Stultz
2016-01-30 6:07 ` [PATCH 3/9] staging: lowmemorykiller: Fix task_struct leak John Stultz
2016-02-07 22:49 ` Greg KH
2016-02-08 18:50 ` John Stultz
2016-01-30 6:07 ` [PATCH 4/9] staging: lowmemorykiller: Make default lowmemorykiller debug message useful John Stultz
2016-01-30 6:07 ` John Stultz [this message]
2016-01-30 6:07 ` [PATCH 6/9] staging: ion: Set minimum carveout heap allocation order to PAGE_SHIFT John Stultz
2016-02-01 20:23 ` Laura Abbott
2016-01-30 6:07 ` [PATCH 7/9] staging: ion: Handle the memory mapping correctly on x86 John Stultz
2016-01-30 6:07 ` [PATCH 8/9] staging: ion: Add X86 dependency for ION_POOL_CACHE_POLICY John Stultz
2016-01-30 6:07 ` [PATCH 9/9] staging: ion: Fix page pool cache policy John Stultz
2016-02-01 21:10 ` [PATCH 0/9] staging: Updates from the Android tree Laura Abbott
2016-02-01 21:28 ` John Stultz
2016-02-07 22:52 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454134058-16466-6-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).