lowmem: process: Remove direct access from lowmem to process 78/320478/5
authorUnsung Lee <unsung.lee@samsung.com>
Sun, 10 Nov 2024 06:16:54 +0000 (15:16 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 25 Nov 2024 02:33:51 +0000 (11:33 +0900)
Remove direct header include and function call from lowmem and lowmem-controller modlue to process module.
This is problem because lowmem and lowmem-controller can access and call all functions in defined proc-main.h.
It means that there is strong dependency between them.
It is essential procedure to remove dependency between different modules.

Change-Id: Iad02d8fe3b54bc32b90f11e0ebe122e01463e8c7
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/proc-common.h
src/process/proc-main.c
src/resource-limiter/memory/lowmem-controller.c
src/resource-limiter/memory/lowmem.c

index 7fcbc29d116b1611e0fdd0ade0d94fa55a7e40f9..8fa549d74914733c71bf4ed30be2742fc2b1e1ee 100644 (file)
@@ -314,6 +314,8 @@ GHashTable * fixed_process_list_get(void);
 struct proc_conf_info* fixed_app_and_service_exist_check(const char *name, enum proc_type proc_type);
 enum proc_action fixed_app_and_service_watchdog_action(const char *name, enum proc_type proc_type);
 
+int proc_common_request_process_termination(pid_t pid, char *app_name, char *pkg_name, int app_type);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 83f7f296765afeda65b777ed222bf611993efffd..347549b1e741977c32856f7faaab99764f116320 100644 (file)
@@ -1619,6 +1619,26 @@ enum proc_state proc_check_suspend_state(struct proc_app_info *pai)
        return PROC_STATE_DEFAULT;
 }
 
+int proc_common_request_process_termination(pid_t pid, char *app_name, char *pkg_name, int app_type)
+{
+       switch(app_type) {
+       case PROC_TYPE_NONE:
+       case PROC_TYPE_READY:
+       case PROC_TYPE_GUI:
+       case PROC_TYPE_SERVICE:
+       case PROC_TYPE_GROUP:
+       case PROC_TYPE_WATCH:
+       case PROC_TYPE_WIDGET:
+               break;
+       default:
+               _E("Failed to ask terminate request: invalid app_type (%d)", app_type);
+               return RESOURCED_ERROR_INVALID_PARAMETER;
+       }
+
+       return resourced_proc_status_change(PROC_CGROUP_SET_TERMINATE_REQUEST,
+                       pid, app_name, pkg_name, app_type);
+}
+
 int resourced_proc_status_change(int status, pid_t pid, char *app_name, char *pkg_name, int apptype)
 {
        int ret = 0, oom_score_adj = 0;
index d79d14bca8d56997a656cadda81ec600fc4148f9..6225e809f8187401cde0948a3954ed9a8edb1d38 100644 (file)
@@ -31,7 +31,6 @@
 #include "lowmem.h"
 #include "lowmem-limit.h"
 #include "proc-common.h"
-#include "proc-main.h"
 #include "resourced.h"
 #include "procfs.h"
 #include "trace.h"
@@ -77,8 +76,7 @@ static int lowmem_kill_victim(const struct task_info *tsk, int flags,
         * else proc_app_info_oom_killed is NULL.
         */
        if (tsk->proc_app_info_oom_killed != NULL) {
-               resourced_proc_status_change(PROC_CGROUP_SET_TERMINATE_REQUEST,
-                       pid, NULL, NULL, PROC_TYPE_NONE);
+               proc_common_request_process_termination(pid, NULL, NULL, PROC_TYPE_NONE);
 
                if (tsk->oom_score_lru <= OOMADJ_BACKGRD_LOCKED) {
                        sigterm = 1;
index cd04220cd22927ba609140684c913d747967914e..525fe81526fc067a3ded5b238db328fa4a5b2567 100644 (file)
@@ -62,7 +62,6 @@
 #include "cgroup.h"
 #include "memory-cgroup.h"
 #include "heart-common.h"
-#include "proc-main.h"
 #include "dbus-handler.h"
 #include "util.h"
 #include "fd-handler.h"