Add start time to LmkKillOccurred
This is to measure an application's behavior with respect to being LMKed (the longer an app lives before being LMKed, the better). Bug: 119854389 Test: Manual Change-Id: I4ef6433391c8758626334731d2b5de038e4468ae Merged-In: I4ef6433391c8758626334731d2b5de038e4468ae (cherry picked from I4ef6433391c8758626334731d2b5de038e4468ae)
This commit is contained in:
parent
1476931e02
commit
1417cdbddb
3 changed files with 14 additions and 8 deletions
13
lmkd/lmkd.c
13
lmkd/lmkd.c
|
|
@ -1018,19 +1018,20 @@ static int memory_stat_from_procfs(struct memory_stat* mem_st, int pid) {
|
||||||
|
|
||||||
// field 10 is pgfault
|
// field 10 is pgfault
|
||||||
// field 12 is pgmajfault
|
// field 12 is pgmajfault
|
||||||
|
// field 22 is starttime
|
||||||
// field 24 is rss_in_pages
|
// field 24 is rss_in_pages
|
||||||
int64_t pgfault = 0, pgmajfault = 0, rss_in_pages = 0;
|
int64_t pgfault = 0, pgmajfault = 0, starttime = 0, rss_in_pages = 0;
|
||||||
if (sscanf(buffer,
|
if (sscanf(buffer,
|
||||||
"%*u %*s %*s %*d %*d %*d %*d %*d %*d %" SCNd64 " %*d "
|
"%*u %*s %*s %*d %*d %*d %*d %*d %*d %" SCNd64 " %*d "
|
||||||
"%" SCNd64 " %*d %*u %*u %*d %*d %*d %*d %*d %*d "
|
"%" SCNd64 " %*d %*u %*u %*d %*d %*d %*d %*d %*d "
|
||||||
"%*d %*d %" SCNd64 "",
|
"%" SCNd64 " %*d %" SCNd64 "",
|
||||||
&pgfault, &pgmajfault, &rss_in_pages) != 3) {
|
&pgfault, &pgmajfault, &starttime, &rss_in_pages) != 4) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mem_st->pgfault = pgfault;
|
mem_st->pgfault = pgfault;
|
||||||
mem_st->pgmajfault = pgmajfault;
|
mem_st->pgmajfault = pgmajfault;
|
||||||
mem_st->rss_in_bytes = (rss_in_pages * PAGE_SIZE);
|
mem_st->rss_in_bytes = (rss_in_pages * PAGE_SIZE);
|
||||||
|
mem_st->process_start_time_ns = starttime * (NS_PER_SEC / sysconf(_SC_CLK_TCK));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1316,10 +1317,10 @@ 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.cache_in_bytes, mem_st.swap_in_bytes, mem_st.process_start_time_ns);
|
||||||
} 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, tasksize * BYTES_IN_KILOBYTE, -1, -1, -1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
result = tasksize;
|
result = tasksize;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ 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 swap_in_bytes, int64_t process_start_time_ns) {
|
||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
|
|
@ -113,5 +113,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_int64(ctx, process_start_time_ns)) < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return write_to_logger(ctx, LOG_ID_STATS);
|
return write_to_logger(ctx, LOG_ID_STATS);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ struct memory_stat {
|
||||||
int64_t rss_in_bytes;
|
int64_t rss_in_bytes;
|
||||||
int64_t cache_in_bytes;
|
int64_t cache_in_bytes;
|
||||||
int64_t swap_in_bytes;
|
int64_t swap_in_bytes;
|
||||||
|
int64_t process_start_time_ns;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MEMCG_PROCESS_MEMORY_STAT_PATH "/dev/memcg/apps/uid_%u/pid_%u/memory.stat"
|
#define MEMCG_PROCESS_MEMORY_STAT_PATH "/dev/memcg/apps/uid_%u/pid_%u/memory.stat"
|
||||||
|
|
@ -87,7 +88,7 @@ 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 swap_in_bytes, int64_t process_start_time_ns);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue