From c5017f4fd552b9b72ee82d6ec10e688e3f8c14c5 Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Thu, 3 Aug 2023 18:26:29 +0900 Subject: [PATCH] resourced-memory-lmk: Change policy to put focused app in the last Change policy of get_kill_candidates_post_with_foreground function to put focused app in the last of candidates list. This is because focused app is the most important foreground app. Change-Id: I43f55553a213215c059d1f56dd044b43efa4f790 Signed-off-by: Unsung Lee --- .../resourced-memory-lmk.c | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/resourced-memory-lmk/resourced-memory-lmk.c b/src/resourced-memory-lmk/resourced-memory-lmk.c index a7202ff..f43f6d2 100644 --- a/src/resourced-memory-lmk/resourced-memory-lmk.c +++ b/src/resourced-memory-lmk/resourced-memory-lmk.c @@ -176,18 +176,22 @@ static int get_kill_candidates_post_with_foreground(GArray *candidates, if (z_max < task->z) z_max = task->z; - if (task->oom_score_lru == OOMADJ_APP_IN_FOREGROUND_APP_LIST) + if (task->oom_score_lru == OOMADJ_APP_IN_FOREGROUND_APP_LIST) { + if (task->is_focused) + return -EINVAL; + foreground_app_count++; + } z_candidates[task->z] = task; } - foreground_app_index = candidates->len - foreground_app_count; - if (foreground_app_index < 0) + focused_app_index = candidates->len - 1; + if (focused_app_index < 0) return -EINVAL; - focused_app_index = foreground_app_index - 1; - if (focused_app_index < 0) + foreground_app_index = focused_app_index - foreground_app_count; + if (foreground_app_index < 0) return -EINVAL; z_index = 0; @@ -205,15 +209,15 @@ static int get_kill_candidates_post_with_foreground(GArray *candidates, * Reorder foreground app candidates according to policy. * * 1. Basically, sorting candidates from high value of z to low one. - * 2. If window information's is_focus is equal to 1, - * put it before foreground app list. - * 3. If task_info's oom_score_lru is OOMADJ_APP_IN_FOREGROUND_APP_LIST, - * put it to end of candidates. + * 2. If task_info's oom_score_lru is OOMADJ_APP_IN_FOREGROUND_APP_LIST, + * put it before focused app. + * 3. If window information's is_focus is equal to 1, + * put it to the end of candidates list. * 4. App memory size is out of interest * * candidates will be sorted like below: * - * |(high z) --> (low z)|(is_focused = 1)|(OOMADJ_APP_IN_FOREGROUND_APP_LIST)| + * |(high z) --> (low z)|(OOMADJ_APP_IN_FOREGROUND_APP_LIST)|(is_focused == 1)| */ if (z_task->oom_score_lru == OOMADJ_APP_IN_FOREGROUND_APP_LIST) { task_ptr = &g_array_index(candidates, -- 2.34.1