conf: Parse 'ForegroundAppList' property of process.conf 58/294658/18
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 22 Jun 2023 09:06:17 +0000 (18:06 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 31 Jul 2023 02:35:06 +0000 (11:35 +0900)
Parse configuration for foreground status app(s)
which want to have low oom_socre_adj

This configuration supports recording low oom_score_adj
for foreground app. oom_score_adj is an important indicator
to choose victim when available memory is too low.
Therefore, with this configuration, specific foreground app(s) have low
probability to be choosen as victim of LMK.

A new configuration called 'App' in section 'ForegroundAppList'
is added in process.conf

Change-Id: Ia25c4a966ad7351e0bf67b55d8fb925417f1cc8c
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
conf/README
src/common/conf/config-parser.c
src/common/conf/config-parser.h
src/common/proc-common.h

index 95443db8d12c2d2d724e983062ceb33e5a1be22d..c8a770e3337ca3470a3e07d7e087961a4f2ef0c3 100644 (file)
@@ -461,6 +461,18 @@ Comment: Specify logging type.
          If DLOG and DB type, then <type> is 5 (0x01 | 0x04).
 Example: logging=5
 
+4.3 ForegroundAppList
+=====================
+Key: App
+Value: <app name>
+Comment: Specify a target app name to fix foreground status oom score.
+         Predefined value cannot be used. Please reference 'OomScore' in section 7.1.
+         Keep in mind If both 'OomScore' in Section 7.1 and this configuration are set,
+         then resourced ignores 'OomScore' configuration.
+Example: App=org.tizen.setting
+         App=com.samsung.browser
+         App=ise-default
+
 5. limiter.conf.d/*.conf
 ========================
 
index a26e0f6028276e25246730c84b82a7d99ba375cc..e65dd9d615114a9f13781678e407b3079222d55c 100644 (file)
@@ -327,6 +327,7 @@ static int init_proc_conf_info(struct proc_conf_info *pci, const char *name)
        pci->fail_action = PROC_ACTION_IGNORE;
        pci->cpu_boosting_level = CPU_BOOSTING_LEVEL_NONE;
        pci->oom_score = OOMADJ_APP_MAX + 10;
+       pci->is_app_in_foreground_app_list = false;
        strncpy(pci->name, name, sizeof(pci->name)-1);
 
        return RESOURCED_ERROR_NONE;
@@ -350,6 +351,43 @@ static int register_proc_conf_info(struct proc_conf_info *pci,
        return RESOURCED_ERROR_NONE;
 }
 
+static int process_config(struct parse_result *result, void *user_data)
+{
+       int ret;
+       struct proc_conf_info *pci;
+
+       if (!result)
+               return RESOURCED_ERROR_INVALID_PARAMETER;
+
+       if (strncmp(result->section, FOREGROUND_APP_LIST_SECTION,
+                               strlen(FOREGROUND_APP_LIST_SECTION) + 1))
+               return RESOURCED_ERROR_NONE;
+
+       if (strncmp(result->name, APP_NAME_CONF,
+                               strlen(APP_NAME_CONF) + 1)) {
+               _W("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
+                               result->name, result->value, result->section);
+               return RESOURCED_ERROR_NONE;
+       }
+
+       pci = fixed_app_and_service_exist_check(result->value, APP_TYPE);
+       if (pci == NULL) {
+               pci = (struct proc_conf_info *)calloc(1, sizeof(struct proc_conf_info));
+               if (pci == NULL) {
+                       _E("Failed to allocate memory during parsing configurations");
+                       return RESOURCED_ERROR_OUT_OF_MEMORY;
+               }
+
+               ret = register_proc_conf_info(pci, result->value, APP_TYPE);
+               if (ret < 0)
+                       return ret;
+       }
+
+       pci->is_app_in_foreground_app_list = true;
+
+       return RESOURCED_ERROR_NONE;
+}
+
 static int optimizer_config(struct parse_result *result, void *user_data)
 {
        if (!result)
@@ -1107,7 +1145,12 @@ void resourced_parse_vendor_configs(void)
        config_type = OPTIMIZER_CONFIG;
        load_per_vendor_configs(OPTIMIZER_CONF_DIR, vendor_config, &config_type);
 
-       /* Load configuration in process.conf */
+       /* Load configuration in process.conf.d or process.conf */
+       if (access(PACKAGE_CUSTOM_CONF_FILE(process), F_OK) == 0)
+               config_parse(PACKAGE_CUSTOM_CONF_FILE(process), process_config, NULL);
+       else
+               config_parse(PROCESS_CONF_FILE, process_config, NULL);
+
        config_type = PROCESS_CONFIG;
        load_per_vendor_configs(PROC_CONF_DIR, vendor_config, &config_type);
 
index e774635679eae7595296b57f5aeb2b006128a59f..3c40c0d2962ba330d9adf0b6465faea9ba419a57 100644 (file)
@@ -32,12 +32,16 @@ extern "C" {
 
 #define LIMITER_CONF_FILE                   RD_CONFIG_FILE(limiter)
 #define OPTIMIZER_CONF_FILE                 RD_CONFIG_FILE(optimizer)
+#define PROCESS_CONF_FILE                   RD_CONFIG_FILE(process)
 #define LIMITER_CONF_DIR                    RD_CONFIG_PATH"/limiter.conf.d"
 #define OPTIMIZER_CONF_DIR                  RD_CONFIG_PATH"/optimizer.conf.d"
 #define PROC_CONF_DIR                       RD_CONFIG_PATH"/process.conf.d"
 /* old style */
 #define VIP_CONF_DIR                        RD_CONFIG_PATH"/vip-process.d"
 
+#define PACKAGE_CUSTOM_CONF_FILE(name) \
+       RD_CONFIG_PATH"/"#name".conf.d/"#name".conf"
+
 /* section name */
 /* limiter.conf */
 #define        PRIVATE_SECTION                     "Private"
@@ -61,6 +65,9 @@ extern "C" {
 #define CPU_BOOSTING_LEVEL_MEDIUM_SECTION   "CpuBoostingLevelMedium"
 #define CPU_BOOSTING_LEVEL_WEAK_SECTION     "CpuBoostingLevelWeak"
 
+/* process.conf */
+#define FOREGROUND_APP_LIST_SECTION         "ForegroundAppList"
+
 /* configuration name */
 /* limiter.conf */
 #define APP_NAME_CONF                                "App"
@@ -74,6 +81,7 @@ extern "C" {
 #define OLD_ACTION_ON_FAILURE_NAME_CONF              "ACTION_ON_FAILURE"
 #define        WATCHDOG_ACTION_NAME_CONF                    "WatchdogAction"
 #define OOM_SCORE_NAME_CONF                          "OomScore"
+#define FOREGROUND_OOM_SCORE_NAME_CONF               "ForegroundOomScore"
 #define THROTTLING_LIMIT_NAME_CONF                   "ThrottlingLimit"
 #define MEDIUM_LEVEL_NAME_CONF                       "MediumLevel"
 #define LOW_LEVEL_NAME_CONF                          "LowLevel"
index ba103656571a6e9eebd8eccb71d530d2bf3dd70d..8880c76f5e24f279a7a1a6bf03d88d94a425f0cd 100644 (file)
@@ -69,6 +69,7 @@ struct proc_conf_info {
        struct cpu_sched_info cpu_sched_info;
        struct cpuset_info cpuset_info;
        int oom_score;
+       bool is_app_in_foreground_app_list;
        bool memory_throttling_enable;
        bool cpu_throttling_enable;
        cpu_boosting_level_e cpu_boosting_level;