Merge "lmkd: Fix kill failure handling"

am: 46bc39ba23

Change-Id: Ia581ad84feaf56ebff1320e8f69e757590f7a864
This commit is contained in:
Suren Baghdasaryan 2019-10-01 13:55:01 -07:00 committed by android-build-merger
commit 613fa51aaf
1 changed files with 19 additions and 18 deletions

37
lmkd.c
View File

@ -1793,6 +1793,14 @@ static int kill_one_process(struct proc* procp, int min_oom_score, const char *r
/* CAP_KILL required */ /* CAP_KILL required */
r = kill(pid, SIGKILL); r = kill(pid, SIGKILL);
TRACE_KILL_END();
if (r) {
ALOGE("kill(%d): errno=%d", pid, errno);
/* Delete process record even when we fail to kill so that we don't get stuck on it */
goto out;
}
set_process_group_and_prio(pid, SP_FOREGROUND, ANDROID_PRIORITY_HIGHEST); set_process_group_and_prio(pid, SP_FOREGROUND, ANDROID_PRIORITY_HIGHEST);
inc_killcnt(procp->oomadj); inc_killcnt(procp->oomadj);
@ -1804,28 +1812,21 @@ static int kill_one_process(struct proc* procp, int min_oom_score, const char *r
uid, procp->oomadj, tasksize * page_k); uid, procp->oomadj, tasksize * page_k);
} }
TRACE_KILL_END();
last_killed_pid = pid; last_killed_pid = pid;
if (r) {
ALOGE("kill(%d): errno=%d", pid, errno);
goto out;
} else {
#ifdef LMKD_LOG_STATS #ifdef LMKD_LOG_STATS
if (memory_stat_parse_result == 0) { if (memory_stat_parse_result == 0) {
stats_write_lmk_kill_occurred(log_ctx, LMK_KILL_OCCURRED, uid, taskname, stats_write_lmk_kill_occurred(log_ctx, LMK_KILL_OCCURRED, uid, taskname,
procp->oomadj, mem_st.pgfault, mem_st.pgmajfault, mem_st.rss_in_bytes, procp->oomadj, mem_st.pgfault, mem_st.pgmajfault, mem_st.rss_in_bytes,
mem_st.cache_in_bytes, mem_st.swap_in_bytes, mem_st.process_start_time_ns, mem_st.cache_in_bytes, mem_st.swap_in_bytes, mem_st.process_start_time_ns,
min_oom_score); min_oom_score);
} else if (enable_stats_log) { } else if (enable_stats_log) {
stats_write_lmk_kill_occurred(log_ctx, LMK_KILL_OCCURRED, uid, taskname, procp->oomadj, stats_write_lmk_kill_occurred(log_ctx, LMK_KILL_OCCURRED, uid, taskname, procp->oomadj,
-1, -1, tasksize * BYTES_IN_KILOBYTE, -1, -1, -1, -1, -1, tasksize * BYTES_IN_KILOBYTE, -1, -1, -1,
min_oom_score); min_oom_score);
}
#endif
result = tasksize;
} }
#endif
result = tasksize;
out: out:
/* /*