lowmem: Initalize task window info using app window info 48/295748/10
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 13 Jul 2023 01:38:52 +0000 (10:38 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 31 Jul 2023 02:35:06 +0000 (11:35 +0900)
When LMK is triggered by low memory, task window information is
needed to be initalize using app window information

LMK governor needs to know window information to make an order of
vicitim candidates. Currently, resourced app information includes
itself window information. Therefore, app window information needs
to be passed to task info.

Change-Id: If54217a1a4738d3a01945e8c375d6c3d2144895e
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/resource-limiter/memory/lowmem.c

index e3c9c30..ef48f63 100644 (file)
@@ -518,6 +518,25 @@ static bool is_foreground_app(int oom_score_adj,
        return true;
 }
 
+static void init_task_window_info(struct task_info *task, struct proc_app_window_info window)
+{
+       assert(task);
+
+       task->window_pid = window.pid;
+       task->x = window.x;
+       task->y = window.y;
+       task->z = window.z;
+       task->w = window.w;
+       task->h = window.h;
+       task->layer = window.layer;
+       task->opaque = window.opaque;
+       task->visibility = window.visibility;
+       task->is_transformed = window.is_transformed;
+       task->alpha = window.alpha;
+       task->is_focused = window.is_focused;
+       task->is_mapped = window.is_mapped;
+}
+
 static GArray *lowmem_get_task_info_app(int killer_flags, int start_oom, int end_oom)
 {
        GSList *iter = NULL;
@@ -545,6 +564,8 @@ static GArray *lowmem_get_task_info_app(int killer_flags, int start_oom, int end
                        continue;
                }
 
+               memset(&task, 0, sizeof(struct task_info));
+
                task.pid = pai->main_pid;
                if (pai->childs) {
                        task.pids = g_array_new(false, false, sizeof(pid_t));
@@ -579,6 +600,7 @@ static GArray *lowmem_get_task_info_app(int killer_flags, int start_oom, int end
                        task.oom_score_lru = pai->memory.oom_score_adj;
                }
 
+               init_task_window_info(&task, pai->window);
                g_array_append_val(lowmem_task_info_app_array, task);
        }
 
@@ -634,6 +656,8 @@ static GArray *lowmem_get_task_info_proc()
                if (oom_score_adj > OOMADJ_SU && oom_score_adj <= OOMADJ_APP_MAX)
                        continue;
 
+               memset(&task, 0, sizeof(struct task_info));
+
                /**
                 * Currently, for tasks in the memory cgroup,
                 * do not consider multiple tasks with one pgid.