process: update oom_score_adj back to itself 87/265987/6
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 3 Nov 2021 08:27:07 +0000 (17:27 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 8 Nov 2021 04:07:41 +0000 (13:07 +0900)
In initializing service app, it initializes /proc/pid/oom_score_adj,
but cannot initialize the data structure itself within its subroutine.
Therefore manually update the oom_score_adj.

Change-Id: Ifc2a13a020dcd570d318c79e7e67d5f04ed41fc0
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/process/proc-main.c

index 997dcce..1845a26 100644 (file)
@@ -501,19 +501,30 @@ resourced_ret_c proc_set_runtime_exclude_list(const int pid, int type)
 static void proc_set_default_svc_oomscore
            (struct proc_program_info *ppi, struct proc_app_info *svc)
 {
-       struct proc_app_info *pai =
-                   (struct proc_app_info *)g_slist_nth_data(ppi->app_list, 0);
-       int oom_score_adj = 0, ret ;
+       struct proc_app_info *pai = (struct proc_app_info *)g_slist_nth_data(ppi->app_list, 0);
+       int retval;
+       int oom_score_adj = 0;
+
        if (pai) {
                if (CHECK_BIT(pai->flags, PROC_VIP_ATTRIBUTE))
                        oom_score_adj = OOMADJ_SU;
                else {
-                       ret = proc_get_oom_score_adj(pai->main_pid, &oom_score_adj);
-                       if (ret)
+                       retval = proc_get_oom_score_adj(pai->main_pid, &oom_score_adj);
+                       if (retval != RESOURCED_ERROR_NONE)
                                oom_score_adj = 0;
                }
        }
+
        proc_set_service_oomscore(svc->main_pid, oom_score_adj);
+
+       /* The svc->memory.oom_score_adj should have been updated by the
+        * subroutine of proc_set_service_oomscore(). But at this stage,
+        * the proc_app_info of service app is not added to the app list. As a
+        * result the subroutine cannot update proc_app_info of a service app.
+        * Therefore, manually update oom_score_adj of service app. */
+       retval = proc_get_oom_score_adj(svc->main_pid, &oom_score_adj);
+       if (retval == RESOURCED_ERROR_NONE)
+               svc->memory.oom_score_adj = oom_score_adj;
 }
 
 static struct proc_program_info *proc_add_program_list(const int type,