lmkd: Kill cached apps when thrashing or below low watermark
With Android U removing AMS kills, lmkd has additional duty to kill cached apps which previously were killed by AMS. The former logic is not proactive enough and leads to too many cached apps contributing to memory pressure. Implement additional logic to kill cached apps (excluding previous foreground apps) when low watermark is breached or when device is thrashing. Bug: 300660611 Change-Id: I356eac1fe6d44dad292a7ea2fadee69a5be61479 Merged-In: I356eac1fe6d44dad292a7ea2fadee69a5be61479 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
499cc71e28
commit
d1968032a2
10
lmkd.cpp
10
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 = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue