resourced-memory-lmk: Modify governor function
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 6 Mar 2023 08:29:38 +0000 (17:29 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Fri, 21 Apr 2023 08:17:42 +0000 (17:17 +0900)
The governor function named "get_kill_candidates" was modified since its
usage of resourced was changed.

Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/resourced-memory-lmk/resourced-memory-lmk.c

index 24af6257309dfd700e4e2109f518cc4f08e645a4..361d25ad7a31876cdc36745d9c8f1c0735254882 100644 (file)
@@ -49,49 +49,41 @@ static int compare_victims(const struct task_info **ta,
        return pb - pa;
 }
 
-static GArray *get_kill_candidates(GArray *task_info_app_array,
+int get_kill_candidates(GArray *candidates,
+                                       GArray *task_info_app_array,
                                        GArray *task_info_proc_array,
-                                       int start_oom, int end_oom,
-                                       unsigned long totalram_kibi_bytes)
+                                       unsigned long totalram_kb)
 {
-       GArray *candidates =
-               g_array_new(false, false, sizeof(struct task_info *));
+       if (!candidates)
+               return -1;
 
        for (int i = 0; i < task_info_app_array->len; ++i) {
                struct task_info *task = &g_array_index(task_info_app_array,
                                                        struct task_info, i);
-
                if (!task->pid)
                        continue;
-
-               if (task->oom_score_adj > end_oom
-                       || task->oom_score_adj < start_oom)
-                       continue;
-
                g_array_append_val(candidates, task);
        }
 
-       _D("Apps candidate ratio=%d/%d",
-               candidates->len, task_info_app_array->len);
+       _D("[LMK] Apps candidates ratio=%d/%d", candidates->len, task_info_app_array->len);
 
-       if (!candidates->len) {
-               return candidates;
-       }
+       if (!candidates->len)
+               return 0;
 
        if (task_info_proc_array) {
                for (int i = 0; i < task_info_proc_array->len; ++i) {
-                       struct task_info *task =
-                               &g_array_index(task_info_proc_array,
+                       struct task_info *task = &g_array_index(
+                                               task_info_proc_array,
                                                struct task_info, i);
                        g_array_append_val(candidates, task);
                }
-               _D("%d processes were added to candidate", task_info_proc_array->len);
+               _D("[LMK] %d processes were added to candidates", task_info_proc_array->len);
        }
 
        g_array_sort_with_data(candidates, (GCompareDataFunc)compare_victims,
-                                                       &totalram_kibi_bytes);
+                                                       &totalram_kb);
 
-       return candidates;
+       return candidates->len;
 }
 
 static int resourced_memory_lmk_init(void **data)