diff --git a/lmkd.cpp b/lmkd.cpp index fcb06fe..f47982c 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -94,6 +94,7 @@ static inline void trace_kill_end() {} #define LINE_MAX 128 #define PERCEPTIBLE_APP_ADJ 200 +#define PREVIOUS_APP_ADJ 700 /* Android Logger event logtags (see event.logtags) */ #define KILLINFO_LOG_TAG 10195355 @@ -2844,6 +2845,15 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_ } } + /* Check if a cached app should be killed */ + if (kill_reason == NONE && wmark < WMARK_HIGH) { + /* TODO: introduce a new kill reason */ + kill_reason = LOW_MEM_AND_SWAP; + snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached", + wmark < WMARK_LOW ? "min" : "low"); + min_score_adj = PREVIOUS_APP_ADJ + 1; + } + /* Kill a process if necessary */ if (kill_reason != NONE) { struct kill_info ki = {