Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ded4f554 authored by Jim Blackler's avatar Jim Blackler Committed by Android (Google) Code Review
Browse files

Merge "Add start time to LmkKillOccurred"

parents df5fff26 34c3cb84
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -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;
+5 −1
Original line number Diff line number Diff line
@@ -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);
}
+2 −1
Original line number Diff line number Diff line
@@ -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