memory-cgroup: Set oom score range between cgroup 06/303606/1
authorUnsung Lee <unsung.lee@samsung.com>
Wed, 29 Nov 2023 11:52:11 +0000 (20:52 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 2 Jan 2024 08:46:33 +0000 (17:46 +0900)
Set oom score range between cgroup. In this case,
only perceptible and favorite apps can be moved between memory cgroups
when the memory limit is set.

Change-Id: I5cc350c3c18350c9f8c047c8fd6e0043bdfdc642
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/cgroup/memory-cgroup.c

index b104aa7..abb90b5 100644 (file)
@@ -111,10 +111,15 @@ int memcg_get_lowest_oom_score_adj(enum cgroup_type cgroup_type, int *oom_score_
 
 int cgroup_get_type(int oom_score_adj)
 {
-       if (oom_score_adj >= OOMADJ_BACKGRD_PERCEPTIBLE &&
-                       oom_score_adj < OOMADJ_BACKGRD_UNLOCKED + OOMADJ_APP_INCREASE)
+       /**
+        * Only perceptible app and favorite app will be moved between cgroup
+        * when app memory limit is set.
+        */
+       if (oom_score_adj == OOMADJ_BACKGRD_PERCEPTIBLE)
+               return MEMCG_BACKGROUND_MRU;
+       else if(oom_score_adj >= OOMADJ_FAVORITE && oom_score_adj <= OOMADJ_FAVORITE_APP_MAX)
                return MEMCG_BACKGROUND_MRU;
-       else if (oom_score_adj >= OOMADJ_BACKGRD_UNLOCKED + OOMADJ_APP_INCREASE &&
+       else if (oom_score_adj >= OOMADJ_BACKGRD_UNLOCKED &&
                    oom_score_adj <= OOMADJ_APP_MAX)
                return MEMCG_BACKGROUND_LRU;
        else