From 686abc4e2b31c4f3c8378848af732f47ca10c20f Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Mon, 10 Jun 2024 18:59:40 +0000 Subject: [PATCH] lmkd: change default lowmem_min_oom_score for low-RAM devices Experiments on low-RAM devices indicate regressions due to the new low memory kill reason which cause LMKD to kill too many processes. Change ro.lmk.lowmem_min_oom_score to disable kills for this reason by default. Bug: 341257415 Change-Id: Id7137c4c8d888061353b253dc6906d2854e31b1d Signed-off-by: Suren Baghdasaryan --- README.md | 5 +++-- lmkd.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b5748d4..4f08488 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,9 @@ properties: to kill when memory is critically low. Setting it to 1001 will prevent any kills for this reason. Min acceptable value is 201 (apps up to perceptible). - Default = 701 (all cached apps excluding the last - active one). + Default for low-RAM devices = 1001 (disabled), for + high-end devices = 701 (all cached apps excluding + the last active one). lmkd will set the following Android properties according to current system configurations: diff --git a/lmkd.cpp b/lmkd.cpp index 2a0f69b..a698c6d 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -169,6 +169,7 @@ static inline void trace_kill_end() {} /* ro.lmk.swap_compression_ratio property defaults */ #define DEF_SWAP_COMP_RATIO 1 /* ro.lmk.lowmem_min_oom_score defaults */ +#define DEF_LOWMEM_MIN_SCORE_LOWRAM (OOM_SCORE_ADJ_MAX + 1) #define DEF_LOWMEM_MIN_SCORE (PREVIOUS_APP_ADJ + 1) #define LMKD_REINIT_PROP "lmkd.reinit" @@ -4230,9 +4231,10 @@ static bool update_props() { GET_LMK_PROPERTY(int64, "direct_reclaim_threshold_ms", DEF_DIRECT_RECL_THRESH_MS); swap_compression_ratio = GET_LMK_PROPERTY(int64, "swap_compression_ratio", DEF_SWAP_COMP_RATIO); - lowmem_min_oom_score = - std::max(PERCEPTIBLE_APP_ADJ + 1, - GET_LMK_PROPERTY(int32, "lowmem_min_oom_score", DEF_LOWMEM_MIN_SCORE)); + lowmem_min_oom_score = std::max( + PERCEPTIBLE_APP_ADJ + 1, + GET_LMK_PROPERTY(int32, "lowmem_min_oom_score", + low_ram_device ? DEF_LOWMEM_MIN_SCORE_LOWRAM : DEF_LOWMEM_MIN_SCORE)); reaper.enable_debug(debug_process_killing);