Modify LMK policy 97/271097/1
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 10 Feb 2022 10:53:45 +0000 (19:53 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Fri, 11 Feb 2022 04:56:09 +0000 (13:56 +0900)
change oom_score_adj range and
use only one LMK policy to choose victims

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

index 14488f7..5dbc000 100644 (file)
@@ -755,30 +755,6 @@ static int lowmem_check_kill_continued(struct task_info *tsk, int flags)
 
 static int compare_victims(const struct task_info *ta, const struct task_info *tb)
 {
-       /*
-        * Firstly, sort by oom_score_adj
-        * Secondly, sort by task size
-        */
-       assert(ta != NULL);
-       assert(tb != NULL);
-
-       if (ta->oom_score_lru != tb->oom_score_lru)
-               return tb->oom_score_lru - ta->oom_score_lru;
-
-       /*
-        * Get memory usage for tasks with the same oom score.
-        * Since there could be multiple tasks with the same pgid,
-        * we sum all of the tasks.
-        * Even though we calculate memory usage when we should compare it,
-        * there could be frequent cases to get memory usage of tasks that
-        * would not be selected as victim. Therefore we just use RSS + Swap,
-        * which causes much less overhead.
-        */
-       return (int)(tb->size) - (int)(ta->size);
-}
-
-static int compare_victims_point(const struct task_info *ta, const struct task_info *tb)
-{
         unsigned int pa, pb;
 
        assert(ta != NULL);
@@ -786,11 +762,9 @@ static int compare_victims_point(const struct task_info *ta, const struct task_i
        /*
         * followed by kernel badness point calculation using heuristic.
         * oom_score_adj is normalized by its unit, which varies -1000 ~ 1000.
-        * Since we only consider tasks with oom_score_adj larger than 0
-        * as victim candidates, point always has positive value.
         */
-       pa = ta->oom_score_lru * (ktotalram / 1000) + ta->size;
-       pb = tb->oom_score_lru * (ktotalram / 1000) + tb->size;
+       pa = ta->oom_score_lru * (ktotalram / 2000) + ta->size;
+       pb = tb->oom_score_lru * (ktotalram / 2000) + tb->size;
 
        return pb - pa;
 }
@@ -1007,10 +981,11 @@ static int lowmem_kill_victims(int max_victims,
        if (start_oom == OOMADJ_SU)
                lowmem_get_pids_proc(candidates);
 
-       if (start_oom <= OOMADJ_BACKGRD_LOCKED || start_oom >= OOMADJ_BACKGRD_OLD)
+       g_array_sort(candidates, (GCompareFunc)compare_victims);
+/*     if (start_oom <= OOMADJ_BACKGRD_LOCKED || start_oom >= OOMADJ_BACKGRD_OLD)
                g_array_sort(candidates, (GCompareFunc)compare_victims_point);
        else
-               g_array_sort(candidates, (GCompareFunc)compare_victims);
+               g_array_sort(candidates, (GCompareFunc)compare_victims);*/
 
        for (i = 0; i < candidates->len; i++) {
                struct task_info *tsk;