resourced-memory-lmk: Change policy to put focused app in the last 17/296717/1 accepted/tizen_unified_riscv accepted/tizen/unified/20230809.071914 accepted/tizen/unified/riscv/20230809.013255
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 3 Aug 2023 09:26:29 +0000 (18:26 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Thu, 3 Aug 2023 09:28:56 +0000 (18:28 +0900)
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 <unsung.lee@samsung.com>
src/resourced-memory-lmk/resourced-memory-lmk.c

index a7202ffc26a49e79adcae5a60fa66401ebf87e29..f43f6d21fd3e91896493a03192785be0b7513a3f 100644 (file)
@@ -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,