lmkd: Add ability to trace lmkd kills
(cherry pick from commit c71355991d4bafb4694f6252ac10e288a5fb9f75) For tracing lmkd kills inside kernel it is useful to have traces indicating when and which process lmkd is killing. By default the tracing is disabled. Bug: 63631020 Test: alloc-stress Change-Id: I3ceb2bde0c292eec55855cb4535927f3b4c5d08b Merged-In: I3ceb2bde0c292eec55855cb4535927f3b4c5d08b Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
742897f28c
commit
a052dcd6a6
|
|
@ -10,4 +10,12 @@ cc_binary {
|
||||||
cflags: ["-Werror"],
|
cflags: ["-Werror"],
|
||||||
|
|
||||||
init_rc: ["lmkd.rc"],
|
init_rc: ["lmkd.rc"],
|
||||||
|
|
||||||
|
product_variables: {
|
||||||
|
debuggable: {
|
||||||
|
cflags: [
|
||||||
|
"-DLMKD_TRACE_KILLS"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
lmkd.c
23
lmkd.c
|
|
@ -37,6 +37,25 @@
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
#include <processgroup/processgroup.h>
|
#include <processgroup/processgroup.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define LMKD_TRACE_KILLS to record lmkd kills in kernel traces
|
||||||
|
* to profile and correlate with OOM kills
|
||||||
|
*/
|
||||||
|
#ifdef LMKD_TRACE_KILLS
|
||||||
|
|
||||||
|
#define ATRACE_TAG ATRACE_TAG_ALWAYS
|
||||||
|
#include <cutils/trace.h>
|
||||||
|
|
||||||
|
#define TRACE_KILL_START(pid) ATRACE_INT(__FUNCTION__, pid);
|
||||||
|
#define TRACE_KILL_END() ATRACE_INT(__FUNCTION__, 0);
|
||||||
|
|
||||||
|
#else /* LMKD_TRACE_KILLS */
|
||||||
|
|
||||||
|
#define TRACE_KILL_START(pid)
|
||||||
|
#define TRACE_KILL_END()
|
||||||
|
|
||||||
|
#endif /* LMKD_TRACE_KILLS */
|
||||||
|
|
||||||
#ifndef __unused
|
#ifndef __unused
|
||||||
#define __unused __attribute__((__unused__))
|
#define __unused __attribute__((__unused__))
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -638,6 +657,8 @@ static int kill_one_process(struct proc* procp, int min_score_adj,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE_KILL_START(pid);
|
||||||
|
|
||||||
r = kill(pid, SIGKILL);
|
r = kill(pid, SIGKILL);
|
||||||
ALOGI(
|
ALOGI(
|
||||||
"Killing '%s' (%d), uid %d, adj %d\n"
|
"Killing '%s' (%d), uid %d, adj %d\n"
|
||||||
|
|
@ -646,6 +667,8 @@ static int kill_one_process(struct proc* procp, int min_score_adj,
|
||||||
level_name[level], min_score_adj);
|
level_name[level], min_score_adj);
|
||||||
pid_remove(pid);
|
pid_remove(pid);
|
||||||
|
|
||||||
|
TRACE_KILL_END();
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
ALOGE("kill(%d): errno=%d", pid, errno);
|
ALOGE("kill(%d): errno=%d", pid, errno);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue