diff options
author | Jim Blackler <jimblackler@google.com> | 2018-11-21 16:22:36 +0000 |
---|---|---|
committer | Jim Blackler <jimblackler@google.com> | 2019-01-04 11:36:54 +0000 |
commit | 1417cdbddbb2f0f290b4ad06231482a14c999edd (patch) | |
tree | 287dc3013670c090d3ecd4296038d471e4fd06b3 /lmkd | |
parent | 1476931e02877a99ae3e87274afcf4525ff2c5e6 (diff) | |
download | system_core-1417cdbddbb2f0f290b4ad06231482a14c999edd.tar.gz system_core-1417cdbddbb2f0f290b4ad06231482a14c999edd.tar.bz2 system_core-1417cdbddbb2f0f290b4ad06231482a14c999edd.zip |
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)
Diffstat (limited to 'lmkd')
-rw-r--r-- | lmkd/lmkd.c | 13 | ||||
-rw-r--r-- | lmkd/statslog.c | 6 | ||||
-rw-r--r-- | lmkd/statslog.h | 3 |
3 files changed, 14 insertions, 8 deletions
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index c9c9e8e51..7794f81fa 100644 --- a/lmkd/lmkd.c +++ b/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 12 is pgmajfault + // field 22 is starttime // 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, "%*u %*s %*s %*d %*d %*d %*d %*d %*d %" SCNd64 " %*d " "%" SCNd64 " %*d %*u %*u %*d %*d %*d %*d %*d %*d " - "%*d %*d %" SCNd64 "", - &pgfault, &pgmajfault, &rss_in_pages) != 3) { + "%" SCNd64 " %*d %" SCNd64 "", + &pgfault, &pgmajfault, &starttime, &rss_in_pages) != 4) { return -1; } mem_st->pgfault = pgfault; mem_st->pgmajfault = pgmajfault; 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; } #endif @@ -1316,10 +1317,10 @@ static int kill_one_process(struct proc* procp) { if (memory_stat_parse_result == 0) { 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, - 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) { 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 result = tasksize; diff --git a/lmkd/statslog.c b/lmkd/statslog.c index 66d11647b..689e8aebe 100644 --- a/lmkd/statslog.c +++ b/lmkd/statslog.c @@ -65,7 +65,7 @@ int 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, 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); int ret = -EINVAL; if (!ctx) { @@ -113,5 +113,9 @@ stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid return ret; } + if ((ret = android_log_write_int64(ctx, process_start_time_ns)) < 0) { + return ret; + } + return write_to_logger(ctx, LOG_ID_STATS); } diff --git a/lmkd/statslog.h b/lmkd/statslog.h index 84584805d..f3abe1103 100644 --- a/lmkd/statslog.h +++ b/lmkd/statslog.h @@ -64,6 +64,7 @@ struct memory_stat { int64_t rss_in_bytes; int64_t cache_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" @@ -87,7 +88,7 @@ int 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, 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 |