Snap for 7269201 from e68bfe9a73 to rvc-qpr3-release

Change-Id: I4121184ff7bb28e9ee2d7e029d6d875833c46504
This commit is contained in:
android-build-team Robot 2021-04-08 22:07:02 +00:00
commit 547707cc2e
1 changed files with 25 additions and 9 deletions

View File

@ -203,6 +203,7 @@ static int psi_partial_stall_ms;
static int psi_complete_stall_ms; static int psi_complete_stall_ms;
static int thrashing_limit_pct; static int thrashing_limit_pct;
static int thrashing_limit_decay_pct; static int thrashing_limit_decay_pct;
static int thrashing_critical_pct;
static bool use_psi_monitors = false; static bool use_psi_monitors = false;
static int kpoll_fd; static int kpoll_fd;
static struct psi_threshold psi_thresholds[VMPRESS_LEVEL_COUNT] = { static struct psi_threshold psi_thresholds[VMPRESS_LEVEL_COUNT] = {
@ -2153,12 +2154,21 @@ static int find_and_kill_process(int min_score_adj, enum kill_reasons kill_reaso
int i; int i;
int killed_size = 0; int killed_size = 0;
bool lmk_state_change_start = false; bool lmk_state_change_start = false;
bool choose_heaviest_task = kill_heaviest_task;
for (i = OOM_SCORE_ADJ_MAX; i >= min_score_adj; i--) { for (i = OOM_SCORE_ADJ_MAX; i >= min_score_adj; i--) {
struct proc *procp; struct proc *procp;
if (!choose_heaviest_task && i <= PERCEPTIBLE_APP_ADJ) {
/*
* If we have to choose a perceptible process, choose the heaviest one to
* hopefully minimize the number of victims.
*/
choose_heaviest_task = true;
}
while (true) { while (true) {
procp = kill_heaviest_task ? procp = choose_heaviest_task ?
proc_get_heaviest(i) : proc_adj_lru(i); proc_get_heaviest(i) : proc_adj_lru(i);
if (!procp) if (!procp)
@ -2479,8 +2489,8 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
snprintf(kill_desc, sizeof(kill_desc), "device is low on swap (%" PRId64 snprintf(kill_desc, sizeof(kill_desc), "device is low on swap (%" PRId64
"kB < %" PRId64 "kB) and thrashing (%" PRId64 "%%)", "kB < %" PRId64 "kB) and thrashing (%" PRId64 "%%)",
mi.field.free_swap * page_k, swap_low_threshold * page_k, thrashing); mi.field.free_swap * page_k, swap_low_threshold * page_k, thrashing);
/* Do not kill perceptible apps unless below min watermark */ /* Do not kill perceptible apps unless below min watermark or heavily thrashing */
if (wmark > WMARK_MIN) { if (wmark > WMARK_MIN && thrashing < thrashing_critical_pct) {
min_score_adj = PERCEPTIBLE_APP_ADJ + 1; min_score_adj = PERCEPTIBLE_APP_ADJ + 1;
} }
} else if (swap_is_low && wmark < WMARK_HIGH) { } else if (swap_is_low && wmark < WMARK_HIGH) {
@ -2489,8 +2499,8 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and swap is low (%" snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and swap is low (%"
PRId64 "kB < %" PRId64 "kB)", wmark > WMARK_LOW ? "min" : "low", PRId64 "kB < %" PRId64 "kB)", wmark > WMARK_LOW ? "min" : "low",
mi.field.free_swap * page_k, swap_low_threshold * page_k); mi.field.free_swap * page_k, swap_low_threshold * page_k);
/* Do not kill perceptible apps unless below min watermark */ /* Do not kill perceptible apps unless below min watermark or heavily thrashing */
if (wmark > WMARK_MIN) { if (wmark > WMARK_MIN && thrashing < thrashing_critical_pct) {
min_score_adj = PERCEPTIBLE_APP_ADJ + 1; min_score_adj = PERCEPTIBLE_APP_ADJ + 1;
} }
} else if (wmark < WMARK_HIGH && thrashing > thrashing_limit) { } else if (wmark < WMARK_HIGH && thrashing > thrashing_limit) {
@ -2499,17 +2509,21 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and thrashing (%" snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and thrashing (%"
PRId64 "%%)", wmark > WMARK_LOW ? "min" : "low", thrashing); PRId64 "%%)", wmark > WMARK_LOW ? "min" : "low", thrashing);
cut_thrashing_limit = true; cut_thrashing_limit = true;
/* Do not kill perceptible apps because of thrashing */ /* Do not kill perceptible apps unless thrashing at critical levels */
if (thrashing < thrashing_critical_pct) {
min_score_adj = PERCEPTIBLE_APP_ADJ + 1; min_score_adj = PERCEPTIBLE_APP_ADJ + 1;
}
} else if (reclaim == DIRECT_RECLAIM && thrashing > thrashing_limit) { } else if (reclaim == DIRECT_RECLAIM && thrashing > thrashing_limit) {
/* Page cache is thrashing while in direct reclaim (mostly happens on lowram devices) */ /* Page cache is thrashing while in direct reclaim (mostly happens on lowram devices) */
kill_reason = DIRECT_RECL_AND_THRASHING; kill_reason = DIRECT_RECL_AND_THRASHING;
snprintf(kill_desc, sizeof(kill_desc), "device is in direct reclaim and thrashing (%" snprintf(kill_desc, sizeof(kill_desc), "device is in direct reclaim and thrashing (%"
PRId64 "%%)", thrashing); PRId64 "%%)", thrashing);
cut_thrashing_limit = true; cut_thrashing_limit = true;
/* Do not kill perceptible apps because of thrashing */ /* Do not kill perceptible apps unless thrashing at critical levels */
if (thrashing < thrashing_critical_pct) {
min_score_adj = PERCEPTIBLE_APP_ADJ + 1; min_score_adj = PERCEPTIBLE_APP_ADJ + 1;
} }
}
/* Kill a process if necessary */ /* Kill a process if necessary */
if (kill_reason != NONE) { if (kill_reason != NONE) {
@ -3306,6 +3320,8 @@ static void update_props() {
low_ram_device ? DEF_THRASHING_LOWRAM : DEF_THRASHING)); low_ram_device ? DEF_THRASHING_LOWRAM : DEF_THRASHING));
thrashing_limit_decay_pct = clamp(0, 100, property_get_int32("ro.lmk.thrashing_limit_decay", thrashing_limit_decay_pct = clamp(0, 100, property_get_int32("ro.lmk.thrashing_limit_decay",
low_ram_device ? DEF_THRASHING_DECAY_LOWRAM : DEF_THRASHING_DECAY)); low_ram_device ? DEF_THRASHING_DECAY_LOWRAM : DEF_THRASHING_DECAY));
thrashing_critical_pct = max(0, property_get_int32("ro.lmk.thrashing_limit_critical",
thrashing_limit_pct * 2));
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {