lmkd: Log psi averages in killinfo reports am: 014dd7156e am: 58fa91d0cf am: 7475f87830 am: b3ffc654fd
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992291 Change-Id: Ic7fef56fc049a8bf5b19996874b14d7d8b21efca
This commit is contained in:
commit
4609284014
|
|
@ -21,6 +21,7 @@
|
||||||
# 2: int64_t
|
# 2: int64_t
|
||||||
# 3: string
|
# 3: string
|
||||||
# 4: list
|
# 4: list
|
||||||
|
# 5: float
|
||||||
#
|
#
|
||||||
# The data unit is a number taken from the following list:
|
# The data unit is a number taken from the following list:
|
||||||
# 1: Number of objects
|
# 1: Number of objects
|
||||||
|
|
@ -35,4 +36,4 @@
|
||||||
# TODO: generate ".java" and ".h" files with integer constants from this file.
|
# TODO: generate ".java" and ".h" files with integer constants from this file.
|
||||||
|
|
||||||
# for killinfo logs
|
# for killinfo logs
|
||||||
10195355 killinfo (Pid|1|5),(Uid|1|5),(OomAdj|1),(MinOomAdj|1),(TaskSize|1),(enum kill_reasons|1|5),(MemFree|1),(Cached|1),(SwapCached|1),(Buffers|1),(Shmem|1),(Unevictable|1),(SwapTotal|1),(SwapFree|1),(ActiveAnon|1),(InactiveAnon|1),(ActiveFile|1),(InactiveFile|1),(SReclaimable|1),(SUnreclaim|1),(KernelStack|1),(PageTables|1),(IonHeap|1),(IonHeapPool|1),(CmaFree|1),(MsSinceEvent|1),(MsSincePrevWakeup|1),(WakeupsSinceEvent|1),(SkippedWakeups|1),(TaskSwapSize|1),(GPU|1),(Thrashing|1),(MaxThrashing|1)
|
10195355 killinfo (Pid|1|5),(Uid|1|5),(OomAdj|1),(MinOomAdj|1),(TaskSize|1),(enum kill_reasons|1|5),(MemFree|1),(Cached|1),(SwapCached|1),(Buffers|1),(Shmem|1),(Unevictable|1),(SwapTotal|1),(SwapFree|1),(ActiveAnon|1),(InactiveAnon|1),(ActiveFile|1),(InactiveFile|1),(SReclaimable|1),(SUnreclaim|1),(KernelStack|1),(PageTables|1),(IonHeap|1),(IonHeapPool|1),(CmaFree|1),(MsSinceEvent|1),(MsSincePrevWakeup|1),(WakeupsSinceEvent|1),(SkippedWakeups|1),(TaskSwapSize|1),(GPU|1),(Thrashing|1),(MaxThrashing|1),(PsiMemSome|5),(PsiMemFull|5),(PsiIoSome|5),(PsiIoFull|5),(PsiCpuSome|5)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
#define PSI_PATH_MEMORY "/proc/pressure/memory"
|
#define PSI_PATH_MEMORY "/proc/pressure/memory"
|
||||||
|
#define PSI_PATH_IO "/proc/pressure/io"
|
||||||
|
#define PSI_PATH_CPU "/proc/pressure/cpu"
|
||||||
|
|
||||||
enum psi_stall_type {
|
enum psi_stall_type {
|
||||||
PSI_SOME,
|
PSI_SOME,
|
||||||
|
|
@ -39,6 +41,8 @@ struct psi_stats {
|
||||||
|
|
||||||
struct psi_data {
|
struct psi_data {
|
||||||
struct psi_stats mem_stats[PSI_TYPE_COUNT];
|
struct psi_stats mem_stats[PSI_TYPE_COUNT];
|
||||||
|
struct psi_stats io_stats[PSI_TYPE_COUNT];
|
||||||
|
struct psi_stats cpu_stats[PSI_TYPE_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
50
lmkd.cpp
50
lmkd.cpp
|
|
@ -1947,6 +1947,22 @@ static int psi_parse_mem(struct psi_data *psi_data) {
|
||||||
return psi_parse(&file_data, psi_data->mem_stats, true);
|
return psi_parse(&file_data, psi_data->mem_stats, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int psi_parse_io(struct psi_data *psi_data) {
|
||||||
|
static struct reread_data file_data = {
|
||||||
|
.filename = PSI_PATH_IO,
|
||||||
|
.fd = -1,
|
||||||
|
};
|
||||||
|
return psi_parse(&file_data, psi_data->io_stats, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int psi_parse_cpu(struct psi_data *psi_data) {
|
||||||
|
static struct reread_data file_data = {
|
||||||
|
.filename = PSI_PATH_CPU,
|
||||||
|
.fd = -1,
|
||||||
|
};
|
||||||
|
return psi_parse(&file_data, psi_data->cpu_stats, false);
|
||||||
|
}
|
||||||
|
|
||||||
enum wakeup_reason {
|
enum wakeup_reason {
|
||||||
Event,
|
Event,
|
||||||
Polling
|
Polling
|
||||||
|
|
@ -1991,7 +2007,7 @@ struct kill_info {
|
||||||
|
|
||||||
static void killinfo_log(struct proc* procp, int min_oom_score, int rss_kb,
|
static void killinfo_log(struct proc* procp, int min_oom_score, int rss_kb,
|
||||||
int swap_kb, struct kill_info *ki, union meminfo *mi,
|
int swap_kb, struct kill_info *ki, union meminfo *mi,
|
||||||
struct wakeup_info *wi, struct timespec *tm) {
|
struct wakeup_info *wi, struct timespec *tm, struct psi_data *pd) {
|
||||||
/* log process information */
|
/* log process information */
|
||||||
android_log_write_int32(ctx, procp->pid);
|
android_log_write_int32(ctx, procp->pid);
|
||||||
android_log_write_int32(ctx, procp->uid);
|
android_log_write_int32(ctx, procp->uid);
|
||||||
|
|
@ -2028,6 +2044,18 @@ static void killinfo_log(struct proc* procp, int min_oom_score, int rss_kb,
|
||||||
android_log_write_int32(ctx, 0);
|
android_log_write_int32(ctx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pd) {
|
||||||
|
android_log_write_float32(ctx, pd->mem_stats[PSI_SOME].avg10);
|
||||||
|
android_log_write_float32(ctx, pd->mem_stats[PSI_FULL].avg10);
|
||||||
|
android_log_write_float32(ctx, pd->io_stats[PSI_SOME].avg10);
|
||||||
|
android_log_write_float32(ctx, pd->io_stats[PSI_FULL].avg10);
|
||||||
|
android_log_write_float32(ctx, pd->cpu_stats[PSI_SOME].avg10);
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
android_log_write_float32(ctx, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
android_log_write_list(ctx, LOG_ID_EVENTS);
|
android_log_write_list(ctx, LOG_ID_EVENTS);
|
||||||
android_log_reset(ctx);
|
android_log_reset(ctx);
|
||||||
}
|
}
|
||||||
|
|
@ -2122,7 +2150,7 @@ static void watchdog_callback() {
|
||||||
|
|
||||||
if (reaper.kill({ target.pidfd, target.pid, target.uid }, true) == 0) {
|
if (reaper.kill({ target.pidfd, target.pid, target.uid }, true) == 0) {
|
||||||
ALOGW("lmkd watchdog killed process %d, oom_score_adj %d", target.pid, oom_score);
|
ALOGW("lmkd watchdog killed process %d, oom_score_adj %d", target.pid, oom_score);
|
||||||
killinfo_log(&target, 0, 0, 0, NULL, NULL, NULL, NULL);
|
killinfo_log(&target, 0, 0, 0, NULL, NULL, NULL, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prev_pid = target.pid;
|
prev_pid = target.pid;
|
||||||
|
|
@ -2244,7 +2272,8 @@ static void start_wait_for_proc_kill(int pid_or_fd) {
|
||||||
|
|
||||||
/* Kill one process specified by procp. Returns the size (in pages) of the process killed */
|
/* Kill one process specified by procp. Returns the size (in pages) of the process killed */
|
||||||
static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_info *ki,
|
static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_info *ki,
|
||||||
union meminfo *mi, struct wakeup_info *wi, struct timespec *tm) {
|
union meminfo *mi, struct wakeup_info *wi, struct timespec *tm,
|
||||||
|
struct psi_data *pd) {
|
||||||
int pid = procp->pid;
|
int pid = procp->pid;
|
||||||
int pidfd = procp->pidfd;
|
int pidfd = procp->pidfd;
|
||||||
uid_t uid = procp->uid;
|
uid_t uid = procp->uid;
|
||||||
|
|
@ -2321,7 +2350,7 @@ static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_i
|
||||||
ALOGI("Kill '%s' (%d), uid %d, oom_score_adj %d to free %" PRId64 "kB rss, %" PRId64
|
ALOGI("Kill '%s' (%d), uid %d, oom_score_adj %d to free %" PRId64 "kB rss, %" PRId64
|
||||||
"kb swap", taskname, pid, uid, procp->oomadj, rss_kb, swap_kb);
|
"kb swap", taskname, pid, uid, procp->oomadj, rss_kb, swap_kb);
|
||||||
}
|
}
|
||||||
killinfo_log(procp, min_oom_score, rss_kb, swap_kb, ki, mi, wi, tm);
|
killinfo_log(procp, min_oom_score, rss_kb, swap_kb, ki, mi, wi, tm, pd);
|
||||||
|
|
||||||
kill_st.uid = static_cast<int32_t>(uid);
|
kill_st.uid = static_cast<int32_t>(uid);
|
||||||
kill_st.taskname = taskname;
|
kill_st.taskname = taskname;
|
||||||
|
|
@ -2349,7 +2378,8 @@ out:
|
||||||
* Returns size of the killed process.
|
* Returns size of the killed process.
|
||||||
*/
|
*/
|
||||||
static int find_and_kill_process(int min_score_adj, struct kill_info *ki, union meminfo *mi,
|
static int find_and_kill_process(int min_score_adj, struct kill_info *ki, union meminfo *mi,
|
||||||
struct wakeup_info *wi, struct timespec *tm) {
|
struct wakeup_info *wi, struct timespec *tm,
|
||||||
|
struct psi_data *pd) {
|
||||||
int i;
|
int i;
|
||||||
int killed_size = 0;
|
int killed_size = 0;
|
||||||
bool lmk_state_change_start = false;
|
bool lmk_state_change_start = false;
|
||||||
|
|
@ -2373,7 +2403,7 @@ static int find_and_kill_process(int min_score_adj, struct kill_info *ki, union
|
||||||
if (!procp)
|
if (!procp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
killed_size = kill_one_process(procp, min_score_adj, ki, mi, wi, tm);
|
killed_size = kill_one_process(procp, min_score_adj, ki, mi, wi, tm, pd);
|
||||||
if (killed_size >= 0) {
|
if (killed_size >= 0) {
|
||||||
if (!lmk_state_change_start) {
|
if (!lmk_state_change_start) {
|
||||||
lmk_state_change_start = true;
|
lmk_state_change_start = true;
|
||||||
|
|
@ -2786,7 +2816,9 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
if (critical_stall) {
|
if (critical_stall) {
|
||||||
min_score_adj = 0;
|
min_score_adj = 0;
|
||||||
}
|
}
|
||||||
int pages_freed = find_and_kill_process(min_score_adj, &ki, &mi, &wi, &curr_tm);
|
psi_parse_io(&psi_data);
|
||||||
|
psi_parse_cpu(&psi_data);
|
||||||
|
int pages_freed = find_and_kill_process(min_score_adj, &ki, &mi, &wi, &curr_tm, &psi_data);
|
||||||
if (pages_freed > 0) {
|
if (pages_freed > 0) {
|
||||||
killing = true;
|
killing = true;
|
||||||
max_thrashing = 0;
|
max_thrashing = 0;
|
||||||
|
|
@ -3006,7 +3038,7 @@ static void mp_event_common(int data, uint32_t events, struct polling_params *po
|
||||||
do_kill:
|
do_kill:
|
||||||
if (low_ram_device) {
|
if (low_ram_device) {
|
||||||
/* For Go devices kill only one task */
|
/* For Go devices kill only one task */
|
||||||
if (find_and_kill_process(level_oomadj[level], NULL, &mi, &wi, &curr_tm) == 0) {
|
if (find_and_kill_process(level_oomadj[level], NULL, &mi, &wi, &curr_tm, NULL) == 0) {
|
||||||
if (debug_process_killing) {
|
if (debug_process_killing) {
|
||||||
ALOGI("Nothing to kill");
|
ALOGI("Nothing to kill");
|
||||||
}
|
}
|
||||||
|
|
@ -3029,7 +3061,7 @@ do_kill:
|
||||||
min_score_adj = level_oomadj[level];
|
min_score_adj = level_oomadj[level];
|
||||||
}
|
}
|
||||||
|
|
||||||
pages_freed = find_and_kill_process(min_score_adj, NULL, &mi, &wi, &curr_tm);
|
pages_freed = find_and_kill_process(min_score_adj, NULL, &mi, &wi, &curr_tm, NULL);
|
||||||
|
|
||||||
if (pages_freed == 0) {
|
if (pages_freed == 0) {
|
||||||
/* Rate limit kill reports when nothing was reclaimed */
|
/* Rate limit kill reports when nothing was reclaimed */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue