proc: Check whether window is enabled or not 17/296617/3 accepted/tizen/unified/20230803.174805
authorUnsung Lee <unsung.lee@samsung.com>
Wed, 2 Aug 2023 07:48:51 +0000 (16:48 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Wed, 2 Aug 2023 10:04:50 +0000 (19:04 +0900)
Check the option which indicates whether window is enabled or not.
If the corresponding option is turned off, then do not execute
window related code in proc and lowmem modules.

If the option is turned on,
   - Update window stack each time
   - Active 'ForegroundAppList' config
   - Consider window information during LMK

Change-Id: Id976634628ca9bdd49e8e508ebc70739c410f7e3
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/proc-common.c [new file with mode: 0644]
src/common/proc-common.h
src/process/proc-monitor.c
src/resource-limiter/memory/lowmem.c

diff --git a/src/common/proc-common.c b/src/common/proc-common.c
new file mode 100644 (file)
index 0000000..dd20d48
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * resourced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "proc-common.h"
+
+static bool foreground_app_list_status_enabled = false;
+
+void proc_enable_foreground_app_list_status(void)
+{
+       foreground_app_list_status_enabled = true;
+}
+
+bool proc_is_enabled_of_foreground_app_list_status(void)
+{
+       return foreground_app_list_status_enabled;
+}
index 833e2eb..41d61e7 100644 (file)
@@ -315,6 +315,9 @@ 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);
 
+void proc_enable_foreground_app_list_status(void);
+bool proc_is_enabled_of_foreground_app_list_status(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index ffe5978..d45dfc7 100644 (file)
@@ -189,6 +189,9 @@ static int dbus_update_window_stack(pid_t pid, bool has_focus)
        int z = 0;
        int ret;
 
+       if (!proc_is_enabled_of_foreground_app_list_status())
+               return RESOURCED_ERROR_NONE;
+
        ret = d_bus_call_method_sync_gvariant_with_reply(WINDOW_SYSTEM_BUS_NAME,
                        WINDOW_SYSTEM_OBJECT_PATH, WINDOW_SYSTEM_INTERFACE_NAME,
                        GET_VISIBLE_WINDOW_INFO_V2, NULL, &reply);
index 7f33541..c520f57 100644 (file)
@@ -510,6 +510,9 @@ static int is_app(pid_t pid)
 static bool is_foreground_app(int oom_score_adj,
                int foreground_oom_score_adj)
 {
+       if (!proc_is_enabled_of_foreground_app_list_status())
+               return false;
+
        if (oom_score_adj != OOMADJ_FOREGRD_LOCKED &&
                oom_score_adj != OOMADJ_FOREGRD_UNLOCKED)
                return false;
@@ -724,6 +727,22 @@ static int lowmem_kill_victims(int max_victims,
        GArray *task_info_app_array = NULL;
        GArray *task_info_proc_array = NULL;
 
+       if (!proc_is_enabled_of_foreground_app_list_status()) {
+               switch (oom_level) {
+                       case OOM_LEVEL_BACKGROUND_LEAST_RECENTLY_USED:
+                       case OOM_LEVEL_BACKGROUND_MOST_RECENTLY_USED:
+                       case OOM_LEVEL_FOREGROUND_AND_PROC:
+                       case OOM_LEVEL_ALL:
+                               break;
+                       case OOM_LEVEL_FOREGROUND:
+                               status = LOWMEM_RECLAIM_NEXT_TYPE;
+                               goto leave;
+                       default:
+                               _E("oom level is out of range");
+                               assert(0);
+               }
+       }
+
        task_info_app_array = lowmem_get_task_info_app(flags, start_oom, end_oom);
        /**
         * If start_oom == OOMADJ_SU, processes in /proc will be