Merge "Add min_score_adj into LmkKillOccurred event"
This commit is contained in:
commit
a953ae0546
3 changed files with 17 additions and 6 deletions
13
lmkd/lmkd.c
13
lmkd/lmkd.c
|
|
@ -1329,7 +1329,7 @@ static void set_process_group_and_prio(int pid, SchedPolicy sp, int prio) {
|
||||||
static int last_killed_pid = -1;
|
static int last_killed_pid = -1;
|
||||||
|
|
||||||
/* Kill one process specified by procp. Returns the size of the process killed */
|
/* Kill one process specified by procp. Returns the size of the process killed */
|
||||||
static int kill_one_process(struct proc* procp) {
|
static int kill_one_process(struct proc* procp, int min_oom_score) {
|
||||||
int pid = procp->pid;
|
int pid = procp->pid;
|
||||||
uid_t uid = procp->uid;
|
uid_t uid = procp->uid;
|
||||||
char *taskname;
|
char *taskname;
|
||||||
|
|
@ -1340,6 +1340,9 @@ static int kill_one_process(struct proc* procp) {
|
||||||
#ifdef LMKD_LOG_STATS
|
#ifdef LMKD_LOG_STATS
|
||||||
struct memory_stat mem_st = {};
|
struct memory_stat mem_st = {};
|
||||||
int memory_stat_parse_result = -1;
|
int memory_stat_parse_result = -1;
|
||||||
|
#else
|
||||||
|
/* To prevent unused parameter warning */
|
||||||
|
(void)(min_oom_score);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
taskname = proc_get_name(pid);
|
taskname = proc_get_name(pid);
|
||||||
|
|
@ -1385,10 +1388,12 @@ static int kill_one_process(struct proc* procp) {
|
||||||
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);
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
result = tasksize;
|
result = tasksize;
|
||||||
|
|
@ -1425,7 +1430,7 @@ static int find_and_kill_process(int min_score_adj) {
|
||||||
if (!procp)
|
if (!procp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
killed_size = kill_one_process(procp);
|
killed_size = kill_one_process(procp, min_score_adj);
|
||||||
if (killed_size >= 0) {
|
if (killed_size >= 0) {
|
||||||
#ifdef LMKD_LOG_STATS
|
#ifdef LMKD_LOG_STATS
|
||||||
if (enable_stats_log && !lmk_state_change_start) {
|
if (enable_stats_log && !lmk_state_change_start) {
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ int
|
||||||
stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid,
|
stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid,
|
||||||
char const* process_name, int32_t oom_score, int64_t pgfault,
|
char const* process_name, int32_t oom_score, int64_t pgfault,
|
||||||
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
|
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
|
||||||
int64_t swap_in_bytes, int64_t process_start_time_ns) {
|
int64_t swap_in_bytes, int64_t process_start_time_ns,
|
||||||
|
int32_t min_oom_score) {
|
||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
|
|
@ -117,5 +118,9 @@ stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((ret = android_log_write_int32(ctx, min_oom_score)) < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return write_to_logger(ctx, LOG_ID_STATS);
|
return write_to_logger(ctx, LOG_ID_STATS);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,8 @@ int
|
||||||
stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid,
|
stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid,
|
||||||
char const* process_name, int32_t oom_score, int64_t pgfault,
|
char const* process_name, int32_t oom_score, int64_t pgfault,
|
||||||
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
|
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
|
||||||
int64_t swap_in_bytes, int64_t process_start_time_ns);
|
int64_t swap_in_bytes, int64_t process_start_time_ns,
|
||||||
|
int32_t min_oom_score);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue