Rearrange optimizer configuration 72/275072/3
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 16 May 2022 08:55:05 +0000 (17:55 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 16 May 2022 09:07:34 +0000 (18:07 +0900)
modify cpu cgroup code
modify optimizer (swap, dedup, compact) code

Change-Id: I1df1842fc410ab448ad7fe21654449082885de3a
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
26 files changed:
conf/optimizer.conf
src/common/cgroup/cgroup.c
src/common/cgroup/cgroup.h
src/common/cgroup/cpu-cgroup.c
src/common/cgroup/cpu-cgroup.h
src/common/compact-common.c
src/common/config-parser.c
src/common/config-parser.h
src/common/cpu-common.c [new file with mode: 0644]
src/common/cpu-common.h [new file with mode: 0644]
src/common/cpu-sched-common.c [deleted file]
src/common/cpu-sched-common.h [deleted file]
src/common/dedup-common.c
src/common/file-helper.c
src/common/file-helper.h
src/common/proc-common.h
src/common/swap-common.c
src/common/util.c
src/common/util.h
src/process/priority/proc-priority.c
src/process/proc-main.c
src/resource-optimizer/cpu/cpu-sched.c
src/resource-optimizer/memory/compaction/compaction.c
src/resource-optimizer/memory/dedup/dedup.c
src/resource-optimizer/memory/swap/swap.c
src/resourced/init.c

index 0af613e..ca21707 100644 (file)
@@ -1,5 +1,4 @@
 [MemorySwap]
-SwapEnable=1
 ReclaimAtBoot=yes
 SwapType=zram
 VipGroupSwappiness=0
@@ -16,9 +15,8 @@ PoolRatio=40
 PoolType=z3fold
 
 [MemoryDedup]
-DedupEnable=1
 DedupAtBoot=yes
-ScanOnLowmem=true
+ScanOnLowmem=yes
 
 [MemoryKsm]
 KsmMode=oneshot
@@ -28,12 +26,11 @@ PagesToScan=100
 PagesToScanWithBoost=1000
 
 [MemoryCompaction]
-CompactionEnable=1
 FragLevel=800
 
 [CpuSched]
 #CpuSchedFeature=no_rt_runtime_share
-#CpuRTRunTime=915ms
+#CpuRTRuntime=915ms
 #CpuRTPeriod=1000ms
 
 [CpuAffinity]
index 0d780c1..3557374 100644 (file)
@@ -145,6 +145,15 @@ int cgroup_write_node_ulonglong(const char *cgroup_name,
        return fwrite_ulonglong(buf, value);
 }
 
+int cgroup_write_node_longlong(const char *cgroup_name,
+               const char *file_name, long long value)
+{
+       char buf[MAX_PATH_LENGTH];
+       snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
+       _SD("cgroup_buf %s, value %lld\n", buf, value);
+       return fwrite_longlong(buf, value);
+}
+
 int cgroup_write_node_str(const char *cgroup_name,
                        const char *file_name, const char *string)
 {
index bf7186f..03fd095 100644 (file)
@@ -120,7 +120,18 @@ int cgroup_write_node_int32(const char *cgroup_name,  const char *file_name, int
  * @param value - unsigned long data to write
  * @return negative value if error
  */
-int cgroup_write_node_ulonglong(const char *cgroup_name, const char *file_name, unsigned long long value);
+int cgroup_write_node_ulonglong(const char *cgroup_name,
+               const char *file_name, unsigned long long value);
+
+/**
+ * @desc Put long long value to cgroup,
+ * @param cgroup_name - cgroup path
+ * @param file_name - cgroup content to write
+ * @param value - unsigned long data to write
+ * @return negative value if error
+ */
+int cgroup_write_node_longlong(const char *cgroup_name,
+               const char *file_name, long long value);
 
 /**
  * @desc Put value to cgroup,
index 32e2fe3..19892af 100644 (file)
@@ -3,53 +3,6 @@
 #include "cpu-cgroup.h"
 #include "trace.h"
 
-static struct cpucg_conf *cpucg_conf = NULL;
-
-char *get_cpucg_conf_name(void)
-{
-       if (cpucg_conf)
-               return cpucg_conf->name;
-       else
-               return NULL;
-}
-
-char *get_cpucg_conf_value(void)
-{
-       if (cpucg_conf)
-               return cpucg_conf->value;
-       else
-               return NULL;
-}
-
-int set_cpucg_conf(const char *name, const char *value)
-{
-       cpucg_conf = (struct cpucg_conf *)calloc(1, sizeof (struct cpucg_conf));
-       if (!cpucg_conf) {
-               _E("Failed to alloc memory for cpu configuration");
-               return RESOURCED_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (strlen(name) + 1 > sizeof(cpucg_conf->name)) {
-               _E("Size of cpu configuration for name is not enough");
-               return RESOURCED_ERROR_OUT_OF_MEMORY;
-       }
-       strncpy(cpucg_conf->name, name, sizeof(cpucg_conf->name) - 1);
-
-       if (strlen(value) + 1 > sizeof(cpucg_conf->value)) {
-               _E("Size of cpu configuration for value is not enough");
-               return RESOURCED_ERROR_OUT_OF_MEMORY;
-       }
-       strncpy(cpucg_conf->value, value, sizeof(cpucg_conf->value) - 1);
-
-       return RESOURCED_ERROR_NONE;
-}
-
-void free_cpucg_conf(void)
-{
-       if (cpucg_conf)
-               free(cpucg_conf);
-}
-
 static int cpu_move_cgroup(pid_t pid, char *path)
 {
        return cgroup_write_pid_fullpath(path, pid);
@@ -65,10 +18,6 @@ int cpu_move_cgroup_foreach(pid_t pid, struct proc_app_info *pai, char *path)
                return RESOURCED_ERROR_INVALID_PARAMETER;
        }
 
-       /* Don't touch cpu cgroup fixed process' score */
-       if (pai && pai->app_cpucg_update_exclude)
-               return RESOURCED_ERROR_NONE;
-
        if (!pai)
                return cpu_move_cgroup(pid, path);
 
index 828ed37..dc9af02 100644 (file)
@@ -47,10 +47,6 @@ struct cpucg_conf {
        char value[64];
 };
 
-char *get_cpucg_conf_name(void);
-char *get_cpucg_conf_value(void);
-int set_cpucg_conf(const char *name, const char *value);
-void free_cpucg_conf(void);
 int cpu_move_cgroup_foreach(pid_t pid, struct proc_app_info *pai, char *path);
 int cpucg_make_full_subdir(const char* parentdir);
 
index b3f7e40..4faed44 100644 (file)
@@ -12,6 +12,10 @@ struct compact_conf *get_compact_conf(void)
                        _E("Failed to alloc memory for cpu configuration");
                        return NULL;
                }
+               else {
+                       compact_conf->enable = false;
+                       compact_conf->frag_level = 0;
+               }
        }
 
        return compact_conf;
index 0a258f9..e52da01 100644 (file)
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <assert.h>
 #include <limits.h>
+#include <ctype.h>
 
 #include "util.h"
 #include "trace.h"
@@ -30,7 +31,7 @@
 #include "swap-common.h"
 #include "dedup-common.h"
 #include "compact-common.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 
 #define MAX_SECTION            64
 
@@ -75,8 +76,8 @@ static int config_parse_cpu_sched_features(const char *value)
                        cpu_sched_flag |= CPU_SCHED_RUNTIME_SHARE;
                else if (strneq(word, NO_RT_RUNTIME_SHARE_VALUE_CONF, l))
                        cpu_sched_flag |= CPU_SCHED_NO_RUNTIME_SHARE;
-               else if (strneq(word, RT_RUNTIME_GREED_VALUE_CONF, l))
-                       cpu_sched_flag |= CPU_SCHED_RUNTIME_GREED;
+/*             else if (strneq(word, RT_RUNTIME_GREED_VALUE_CONF, l))
+                       cpu_sched_flag |= CPU_SCHED_RUNTIME_GREED;*/
                else
                        return CPU_SCHED_UNINITIALIZED;
        }
@@ -84,31 +85,62 @@ static int config_parse_cpu_sched_features(const char *value)
        return cpu_sched_flag;
 }
 
-static int config_parse_time_us(const char *value)
+static char config_parse_time_unit(const char *value)
 {
-       char size;
+       char chr;
        char *ptr = strchr(value, 's');
        if (ptr == NULL) {
                _E("[CONFIG] Cannot find 's' in the string (%s)", value);
-               return 0;
+               return 'X';
        }
 
        if (value > (ptr - 1)) {
                _E("[CONFIG] Size of string should be larger than 1");
+               return 'X';
+       }
+
+       chr = *(ptr - 1);
+       if (isdigit(chr)) {
+               *ptr = '\0';
+               return ' ';
+       }
+       else {
+               *(ptr - 1) = '\0';
+               return chr;
+       }
+}
+
+static long long config_parse_ll_time_us(const char *value)
+{
+       char unit = config_parse_time_unit(value);
+
+       if (unit == ' ') {
+               return strtoll(value, NULL, 10) * 1000 * 1000;
+       }
+       else if (unit == 'm') {
+               return strtoll(value, NULL, 10) * 1000;
+       }
+       else if (unit == 'u') {
+               return strtoll(value, NULL, 10);
+       }
+       else {
+               _E("[CONFIG] Unknown unit of time");
                return 0;
        }
+}
 
-       size = *(ptr - 1);
-       *(ptr - 1) = '\0';
+static unsigned long long config_parse_ull_time_us(const char *value)
+{
+       char unit = config_parse_time_unit(value);
 
-       if (size == ' ') {
-               return atoi(value) * 1000 * 1000;
+       if (unit == ' ') {
+               return strtoull(value, NULL, 10) * 1000 * 1000;
        }
-       else if (size == 'm') {
-               return atoi(value) * 1000;
+       else if (unit == 'm') {
+               return strtoull(value, NULL, 10) * 1000;
        }
-       else if (size == 'u') {
-               return atoi(value);
+       else if (unit == 'u') {
+               return strtoull(value, NULL, 10);
        }
        else {
                _E("[CONFIG] Unknown unit of time");
@@ -116,6 +148,49 @@ static int config_parse_time_us(const char *value)
        }
 }
 
+static bool config_parse_bool(const char *value)
+{
+       if (!strncmp(value, "yes", 4) ||
+                       !strncmp(value, "1", 2) ||
+                       !strncmp(value, "ok", 3) ||
+                       !strncmp(value, "on", 3))
+               return true;
+       else if (!strncmp(value, "no", 3) ||
+                       !strncmp(value, "0", 2) ||
+                       !strncmp(value, "off", 4))
+               return false;
+       else {
+               _E("Unknown name (%s)", value);
+               return false;
+       }
+}
+
+static int config_parse_sched_type(const char *value)
+{
+       if (!strncmp(value, CPU_SCHED_IDLE_VALUE_CONF,
+                               strlen(CPU_SCHED_IDLE_VALUE_CONF) +1))
+               return CPU_SCHED_IDLE;
+       else if (!strncmp(value, CPU_SCHED_OTHER_VALUE_CONF,
+                               strlen(CPU_SCHED_OTHER_VALUE_CONF) +1))
+               return CPU_SCHED_OTHER;
+       else if (!strncmp(value, CPU_SCHED_BATCH_VALUE_CONF,
+                               strlen(CPU_SCHED_BATCH_VALUE_CONF) +1))
+               return CPU_SCHED_BATCH;
+       else if (!strncmp(value, CPU_SCHED_FIFO_VALUE_CONF,
+                               strlen(CPU_SCHED_FIFO_VALUE_CONF) +1))
+               return CPU_SCHED_FIFO;
+       else if (!strncmp(value, CPU_SCHED_RR_VALUE_CONF,
+                               strlen(CPU_SCHED_RR_VALUE_CONF) +1))
+               return CPU_SCHED_RR;
+       else if (!strncmp(value, CPU_SCHED_DEADLINE_VALUE_CONF,
+                               strlen(CPU_SCHED_DEADLINE_VALUE_CONF) +1))
+               return CPU_SCHED_DEADLINE;
+       else {
+               _E("invalid parameter (%s)", value);
+               return CPU_SCHED_NONE;
+       }
+}
+
 static int optimizer_config(struct parse_result *result, void *user_data)
 {
        if (!result)
@@ -146,59 +221,36 @@ static int optimizer_config(struct parse_result *result, void *user_data)
        }
 
        if (!strncmp(result->section, SWAP_SECTION, strlen(SWAP_SECTION)+1)) {
-               if (!strncmp(result->name, SWAP_ENABLE_CONF, strlen(SWAP_ENABLE_CONF)+1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3))
-                               swap_conf->enable = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2))
-                               swap_conf->enable = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
-               }
-               else if (!strncmp(result->name, RECLAIM_AT_BOOT_CONF,
-                                       strlen(RECLAIM_AT_BOOT_CONF)+1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3))
-                               swap_conf->boot_reclaim_enable = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2))
-                               swap_conf->boot_reclaim_enable = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
-               }
-               else if (!strncmp(result->name, SWAP_TYPE_CONF,
-                                       strlen(SWAP_TYPE_CONF)+1)) {
+               if (!swap_conf->enable)
+                       swap_conf->enable = true;
+/*             if (!strncmp(result->name, SWAP_ENABLE_NAME_CONF, strlen(SWAP_ENABLE_NAME_CONF)+1)) {
+                               swap_conf->enable = config_parse_bool(result->value);
+               }*/
+               if (!strncmp(result->name, RECLAIM_AT_BOOT_NAME_CONF,
+                                       strlen(RECLAIM_AT_BOOT_NAME_CONF)+1)) {
+                               swap_conf->boot_reclaim_enable = config_parse_bool(result->value);
+               }
+               else if (!strncmp(result->name, SWAP_TYPE_NAME_CONF,
+                                       strlen(SWAP_TYPE_NAME_CONF)+1)) {
                        if (config_parse_swap_types(result->value, &swap_conf->swap_type) < 0) {
-                               _E("[CONFIG] Failed to parse type of swap, so use default zram type");
+                               _E("[CONFIG] Failed to parse type of swap, so use zram type");
                                swap_conf->swap_type = SWAP_TYPE_ZRAM;
                        }
-/*                     if (strlen(result->value) + 1 > sizeof(swap_conf->type)) {
-                               _E("Size of swap_conf->type is not enough");
-                               return RESOURCED_ERROR_OUT_OF_MEMORY;
-                       }
-                       strncpy(swap_conf->type, result->value, sizeof(swap_conf->type) - 1);*/
                }
-               else if (!strncmp(result->name, VIP_GROUP_SWAPPINESS_CONF,
-                                       strlen(VIP_GROUP_SWAPPINESS_CONF)+1)) {
+               else if (!strncmp(result->name, VIP_GROUP_SWAPPINESS_NAME_CONF,
+                                       strlen(VIP_GROUP_SWAPPINESS_NAME_CONF)+1)) {
                        swap_conf->swappiness[MEMCG_VIP] = atoi(result->value);
                }
-               else if (!strncmp(result->name, HIGH_GROUP_SWAPPINESS_CONF,
-                                       strlen(HIGH_GROUP_SWAPPINESS_CONF)+1)) {
+               else if (!strncmp(result->name, HIGH_GROUP_SWAPPINESS_NAME_CONF,
+                                       strlen(HIGH_GROUP_SWAPPINESS_NAME_CONF)+1)) {
                        swap_conf->swappiness[MEMCG_HIGH] = atoi(result->value);
                }
-               else if (!strncmp(result->name, MEDIUM_GROUP_SWAPPINESS_CONF,
-                                       strlen(MEDIUM_GROUP_SWAPPINESS_CONF)+1)) {
+               else if (!strncmp(result->name, MEDIUM_GROUP_SWAPPINESS_NAME_CONF,
+                                       strlen(MEDIUM_GROUP_SWAPPINESS_NAME_CONF)+1)) {
                        swap_conf->swappiness[MEMCG_MEDIUM] = atoi(result->value);
                }
-               else if (!strncmp(result->name, LOWEST_GROUP_SWAPPINESS_CONF,
-                                       strlen(LOWEST_GROUP_SWAPPINESS_CONF)+1)) {
+               else if (!strncmp(result->name, LOWEST_GROUP_SWAPPINESS_NAME_CONF,
+                                       strlen(LOWEST_GROUP_SWAPPINESS_NAME_CONF)+1)) {
                        swap_conf->swappiness[MEMCG_LOW] = atoi(result->value);
                }
                else {
@@ -207,7 +259,7 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                }
        }
        else if (!strncmp(result->section, ZRAM_SECTION, strlen(ZRAM_SECTION)+1)) {
-               if (!strncmp(result->name, COMP_ALGORITHM_CONF, strlen(COMP_ALGORITHM_CONF)+1)) {
+               if (!strncmp(result->name, COMP_ALGORITHM_NAME_CONF, strlen(COMP_ALGORITHM_NAME_CONF)+1)) {
                        if (strlen(result->value) + 1 > sizeof(swap_conf->zram.algorithm)) {
                                _E("Size of swap_conf->zram.algorithm is not enough");
                                return RESOURCED_ERROR_OUT_OF_MEMORY;
@@ -215,7 +267,7 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                        strncpy(swap_conf->zram.algorithm, result->value,
                                        sizeof(swap_conf->zram.algorithm) - 1);
                }
-               else if (!strncmp(result->name, ZRAM_RATIO_CONF, strlen(ZRAM_RATIO_CONF)+1)) {
+               else if (!strncmp(result->name, ZRAM_RATIO_NAME_CONF, strlen(ZRAM_RATIO_NAME_CONF)+1)) {
                        swap_conf->zram.ratio = atof(result->value);
                }
                else {
@@ -224,10 +276,10 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                }
        }
        else if (!strncmp(result->section, ZSWAP_SECTION, strlen(ZSWAP_SECTION)+1)) {
-               if (!strncmp(result->name, POOL_RATIO_CONF, strlen(POOL_RATIO_CONF)+1)) {
+               if (!strncmp(result->name, POOL_RATIO_NAME_CONF, strlen(POOL_RATIO_NAME_CONF)+1)) {
                        swap_conf->zswap.pool_ratio = atof(result->value);
                }
-               else if (!strncmp(result->name, POOL_TYPE_CONF, strlen(POOL_TYPE_CONF)+1)) {
+               else if (!strncmp(result->name, POOL_TYPE_NAME_CONF, strlen(POOL_TYPE_NAME_CONF)+1)) {
                        if (strlen(result->value) + 1 > sizeof(swap_conf->zswap.pool_type)) {
                                _E("Size of swap_conf->zswap.pool_type is not enough");
                                return RESOURCED_ERROR_OUT_OF_MEMORY;
@@ -241,46 +293,16 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                }
        }
        else if (!strncmp(result->section, DEDUP_SECTION, strlen(DEDUP_SECTION)+1)) {
-               if (!strncmp(result->name, DEDUP_ENABLE_CONF, strlen(DEDUP_ENABLE_CONF)+1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3))
-                               dedup_conf->enable = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2))
-                               dedup_conf->enable = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
+               if (!dedup_conf->enable)
+                       dedup_conf->enable = true;
+/*             if (!strncmp(result->name, DEDUP_ENABLE_NAME_CONF, strlen(DEDUP_ENABLE_NAME_CONF)+1)) {
+                               dedup_conf->enable = config_parse_bool(result->value);
+               }*/
+               if (!strncmp(result->name, DEDUP_AT_BOOT_NAME_CONF, strlen(DEDUP_AT_BOOT_NAME_CONF)+1)) {
+                       dedup_conf->boot_dedup_enable = config_parse_bool(result->value);
                }
-               else if (!strncmp(result->name, DEDUP_AT_BOOT_CONF, strlen(DEDUP_AT_BOOT_CONF)+1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3))
-                               dedup_conf->boot_dedup_enable = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2))
-                               dedup_conf->boot_dedup_enable = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
-               }
-               else if (!strncmp(result->name, SCAN_ON_LOWMEM_CONF, strlen(SCAN_ON_LOWMEM_CONF)+1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3) ||
-                               !strncmp(result->value, "true", 5))
-                               dedup_conf->scan_on_lowmem = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2) ||
-                               !strncmp(result->value, "false", 6))
-                               dedup_conf->scan_on_lowmem = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
+               else if (!strncmp(result->name, SCAN_ON_LOWMEM_NAME_CONF, strlen(SCAN_ON_LOWMEM_NAME_CONF)+1)) {
+                       dedup_conf->scan_on_lowmem = config_parse_bool(result->value);
                }
                else {
                        _E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
@@ -288,7 +310,7 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                }
        }
        else if (!strncmp(result->section, KSM_SECTION, strlen(KSM_SECTION)+1)) {
-               if (!strncmp(result->name, KSM_MODE_CONF, strlen(KSM_MODE_CONF)+1)) {
+               if (!strncmp(result->name, KSM_MODE_NAME_CONF, strlen(KSM_MODE_NAME_CONF)+1)) {
                        if (strlen(result->value) + 1 > sizeof(dedup_conf->ksm.mode)) {
                                _E("Size of swap_conf->type is not enough");
                                return RESOURCED_ERROR_OUT_OF_MEMORY;
@@ -296,11 +318,11 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                        strncpy(dedup_conf->ksm.mode, result->value,
                                        sizeof(dedup_conf->ksm.mode) - 1);
                }
-               else if (!strncmp(result->name, PAGES_TO_SCAN_CONF, strlen(PAGES_TO_SCAN_CONF)+1)) {
+               else if (!strncmp(result->name, PAGES_TO_SCAN_NAME_CONF, strlen(PAGES_TO_SCAN_NAME_CONF)+1)) {
                        dedup_conf->ksm.pages = atoi(result->value);
                }
-               else if (!strncmp(result->name, PAGES_TO_SCAN_WITH_BOOST_CONF,
-                                       strlen(PAGES_TO_SCAN_WITH_BOOST_CONF)+1)) {
+               else if (!strncmp(result->name, PAGES_TO_SCAN_WITH_BOOST_NAME_CONF,
+                                       strlen(PAGES_TO_SCAN_WITH_BOOST_NAME_CONF)+1)) {
                        dedup_conf->ksm.boost_pages = atoi(result->value);
                }
                else {
@@ -309,22 +331,13 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                }
        }
        else if (!strncmp(result->section, COMPACTION_SECTION, strlen(COMPACTION_SECTION)+1)) {
-               if (!strncmp(result->name, COMPACTION_ENABLE_CONF, strlen(COMPACTION_ENABLE_CONF)+1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3) ||
-                               !strncmp(result->value, "true", 5))
-                               compact_conf->enable = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2) ||
-                               !strncmp(result->value, "false", 6))
-                               compact_conf->enable = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
-               }
-               else if (!strncmp(result->name, FRAG_LEVEL_CONF, strlen(FRAG_LEVEL_CONF)+1)) {
+               if (!compact_conf->enable)
+                       compact_conf->enable = true;
+/*             if (!strncmp(result->name, COMPACTION_ENABLE_NAME_CONF,
+                                       strlen(COMPACTION_ENABLE_NAME_CONF)+1)) {
+                       compact_conf->enable = config_parse_bool(result->value);
+               }*/
+               if (!strncmp(result->name, FRAG_LEVEL_NAME_CONF, strlen(FRAG_LEVEL_NAME_CONF)+1)) {
                        compact_conf->frag_level = atoi(result->value);
                }
                else {
@@ -340,11 +353,11 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                }
                else if (!strncmp(result->name, CPU_RT_RUN_TIME_NAME_CONF,
                                        strlen(CPU_RT_RUN_TIME_NAME_CONF) + 1)) {
-                       cpu_sched_conf->rt_runtime_us = config_parse_time_us(result->value);
+                       cpu_sched_conf->cpu_cgroup_info.rt_runtime_us = config_parse_ll_time_us(result->value);
                }
                else if (!strncmp(result->name, CPU_RT_PERIOD_NAME_CONF,
                                        strlen(CPU_RT_PERIOD_NAME_CONF) + 1)) {
-                       cpu_sched_conf->rt_period_us = config_parse_time_us(result->value);
+                       cpu_sched_conf->cpu_cgroup_info.rt_period_us = config_parse_ull_time_us(result->value);
                }
                else {
                        _E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
@@ -355,9 +368,9 @@ static int optimizer_config(struct parse_result *result, void *user_data)
                                strlen(CPU_AFFINITY_SECTION)+1)) {
                int error = RESOURCED_ERROR_NONE;
 
-               if (!strncmp(result->name, FOREGROUND_APPS,
-                                       strlen(FOREGROUND_APPS) + 1)) {
-                       error = set_cpucg_conf(result->name, result->value);
+               if (!strncmp(result->name, FOREGROUND_APPS_NAME_CONF,
+                                       strlen(FOREGROUND_APPS_NAME_CONF) + 1)) {
+                       error = set_cpu_affinity_conf(result->name, result->value);
                }
                else {
                        _E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
@@ -386,6 +399,12 @@ static int limiter_config(struct parse_result *result, void *user_data)
                return RESOURCED_ERROR_FAIL;
        }
 
+       struct cpu_throttling_conf *cpu_throttling_conf = get_cpu_throttling_conf();
+       if (cpu_throttling_conf == NULL) {
+               _E("[CONFIG] cpu_throttling configuration is NULL");
+               return RESOURCED_ERROR_FAIL;
+       }
+
        if (!strncmp(result->section, MEMORY_GROUP_LIMIT_SECTION,
                                strlen(MEMORY_GROUP_LIMIT_SECTION)+1)) {
                char *ptr = strchr(result->value, '%');
@@ -396,20 +415,20 @@ static int limiter_config(struct parse_result *result, void *user_data)
                else
                        *ptr = '\0';
 
-               if (!strncmp(result->name, VIP_GROUP_LIMIT_CONF,
-                                       strlen(VIP_GROUP_LIMIT_CONF) + 1)) {
+               if (!strncmp(result->name, VIP_GROUP_LIMIT_NAME_CONF,
+                                       strlen(VIP_GROUP_LIMIT_NAME_CONF) + 1)) {
                        memcg_conf->cgroup_limit[MEMCG_VIP] = atof(result->value);
                }
-               else if (!strncmp(result->name, HIGH_GROUP_LIMIT_CONF,
-                                       strlen(HIGH_GROUP_LIMIT_CONF) + 1)) {
+               else if (!strncmp(result->name, HIGH_GROUP_LIMIT_NAME_CONF,
+                                       strlen(HIGH_GROUP_LIMIT_NAME_CONF) + 1)) {
                        memcg_conf->cgroup_limit[MEMCG_HIGH] = atof(result->value);
                }
-               else if (!strncmp(result->name, MEDIUM_GROUP_LIMIT_CONF,
-                                       strlen(MEDIUM_GROUP_LIMIT_CONF) + 1)) {
+               else if (!strncmp(result->name, MEDIUM_GROUP_LIMIT_NAME_CONF,
+                                       strlen(MEDIUM_GROUP_LIMIT_NAME_CONF) + 1)) {
                        memcg_conf->cgroup_limit[MEMCG_MEDIUM] = atof(result->value);
                }
-               else if (!strncmp(result->name, LOWEST_GROUP_LIMIT_CONF,
-                                       strlen(LOWEST_GROUP_LIMIT_CONF) + 1)) {
+               else if (!strncmp(result->name, LOWEST_GROUP_LIMIT_NAME_CONF,
+                                       strlen(LOWEST_GROUP_LIMIT_NAME_CONF) + 1)) {
                        memcg_conf->cgroup_limit[MEMCG_LOW] = atof(result->value);
                }
                else {
@@ -420,19 +439,9 @@ static int limiter_config(struct parse_result *result, void *user_data)
        else if (!strncmp(result->section, MEMORY_LEVEL_THRESHOLD_SECTION,
                                strlen(MEMORY_LEVEL_THRESHOLD_SECTION)+1)) {
 
-               if (!strncmp(result->name, OOM_POPUP_CONF,
-                                       strlen(OOM_POPUP_CONF) + 1)) {
-                       if (!strncmp(result->value, "yes", 4) ||
-                               !strncmp(result->value, "1", 2) ||
-                               !strncmp(result->value, "ok", 3))
-                               memcg_conf->oom_popup = true;
-                       else if (!strncmp(result->value, "no", 3) ||
-                               !strncmp(result->value, "0", 2))
-                               memcg_conf->oom_popup = false;
-                       else {
-                               _E("[CONFIG] Unknown value for %s", result->name);
-                               return RESOURCED_ERROR_FAIL;
-                       }
+               if (!strncmp(result->name, OOM_POPUP_NAME_CONF,
+                                       strlen(OOM_POPUP_NAME_CONF) + 1)) {
+                       memcg_conf->oom_popup = config_parse_bool(result->value);
                }
                else {
                        char temp = '\0';
@@ -460,23 +469,22 @@ static int limiter_config(struct parse_result *result, void *user_data)
                                percent = true;
                        }
 
-                       if (!strncmp(result->name, MEDIUM_LEVEL_CONF,
-                                               strlen(MEDIUM_LEVEL_CONF) + 1)) {
+                       if (!strncmp(result->name, MEDIUM_LEVEL_NAME_CONF,
+                                               strlen(MEDIUM_LEVEL_NAME_CONF) + 1)) {
                                error = set_memcg_conf_threshold(percent, temp, MEM_LEVEL_MEDIUM, result->value);
                        }
-                       else if (!strncmp(result->name, LOW_LEVEL_CONF,
-                                               strlen(LOW_LEVEL_CONF) + 1)) {
+                       else if (!strncmp(result->name, LOW_LEVEL_NAME_CONF,
+                                               strlen(LOW_LEVEL_NAME_CONF) + 1)) {
                                error = set_memcg_conf_threshold(percent, temp, MEM_LEVEL_LOW, result->value);
                        }
-                       else if (!strncmp(result->name, CRITICAL_LEVEL_CONF,
-                                               strlen(CRITICAL_LEVEL_CONF) + 1)) {
+                       else if (!strncmp(result->name, CRITICAL_LEVEL_NAME_CONF,
+                                               strlen(CRITICAL_LEVEL_NAME_CONF) + 1)) {
                                error = set_memcg_conf_threshold(percent, temp, MEM_LEVEL_CRITICAL, result->value);
                        }
-                       else if (!strncmp(result->name, OOM_LEVEL_CONF,
-                                               strlen(OOM_LEVEL_CONF) + 1)) {
+                       else if (!strncmp(result->name, OOM_LEVEL_NAME_CONF,
+                                               strlen(OOM_LEVEL_NAME_CONF) + 1)) {
                                error = set_memcg_conf_threshold(percent, temp, MEM_LEVEL_OOM, result->value);
                        }
-
                        else {
                                _E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
                                                result->name, result->value, result->section);
@@ -489,16 +497,16 @@ static int limiter_config(struct parse_result *result, void *user_data)
                                strlen(MEMORY_APP_TYPE_LIMIT_SECTION)+1)) {
                int error = RESOURCED_ERROR_NONE;
 
-               if (!strncmp(result->name, SERVICE_PER_APP_LIMIT_ACTION,
-                                       strlen(SERVICE_PER_APP_LIMIT_ACTION) + 1)) {
+               if (!strncmp(result->name, SERVICE_PER_APP_LIMIT_ACTION_NAME_CONF,
+                                       strlen(SERVICE_PER_APP_LIMIT_ACTION_NAME_CONF) + 1)) {
                        error = set_mem_action_conf(&memcg_conf->service, result->value);
                }
-               else if (!strncmp(result->name, WIDGET_PER_APP_LIMIT_ACTION,
-                                       strlen(WIDGET_PER_APP_LIMIT_ACTION) + 1)) {
+               else if (!strncmp(result->name, WIDGET_PER_APP_LIMIT_ACTION_NAME_CONF,
+                                       strlen(WIDGET_PER_APP_LIMIT_ACTION_NAME_CONF) + 1)) {
                        error = set_mem_action_conf(&memcg_conf->widget, result->value);
                }
-               else if (!strncmp(result->name, GUI_PER_APP_LIMIT_ACTION,
-                                       strlen(GUI_PER_APP_LIMIT_ACTION) + 1)) {
+               else if (!strncmp(result->name, GUI_PER_APP_LIMIT_ACTION_NAME_CONF,
+                                       strlen(GUI_PER_APP_LIMIT_ACTION_NAME_CONF) + 1)) {
                        error = set_mem_action_conf(&memcg_conf->guiapp, result->value);
                }
                else {
@@ -512,8 +520,8 @@ static int limiter_config(struct parse_result *result, void *user_data)
                                strlen(MEMORY_APP_STATUS_LIMIT_SECTION)+1)) {
                int error = RESOURCED_ERROR_NONE;
 
-               if (!strncmp(result->name, BACKGROUND_PER_APP_LIMIT_ACTION,
-                                       strlen(BACKGROUND_PER_APP_LIMIT_ACTION) + 1)) {
+               if (!strncmp(result->name, BACKGROUND_PER_APP_LIMIT_ACTION_NAME_CONF,
+                                       strlen(BACKGROUND_PER_APP_LIMIT_ACTION_NAME_CONF) + 1)) {
                        error = set_mem_action_conf(&memcg_conf->background, result->value);
                }
                else {
@@ -523,6 +531,41 @@ static int limiter_config(struct parse_result *result, void *user_data)
 
                return error;
        }
+       else if (!strncmp(result->section, CPU_THROTTLING_SECTION,
+                               strlen(CPU_THROTTLING_SECTION)+1)) {
+               if (!cpu_throttling_conf->enable)
+                       cpu_throttling_conf->enable = true;
+
+               if (!strncmp(result->name, CPU_SCHED_NAME_CONF,
+                                       strlen(CPU_SCHED_NAME_CONF)+1)) {
+                       cpu_throttling_conf->cpu_sched_info.cpu_sched_type =
+                               config_parse_sched_type(result->value);
+               }
+               else if (!strncmp(result->name, CPU_NICE_NAME_CONF,
+                                       strlen(CPU_NICE_NAME_CONF)+1)) {
+                       cpu_throttling_conf->cpu_sched_info.cpu_nice =
+                               atoi(result->value);
+               }
+               else if (!strncmp(result->name, CPU_SHARE_NAME_CONF,
+                                       strlen(CPU_SHARE_NAME_CONF)+1)) {
+                       cpu_throttling_conf->cpu_cgroup_info.cpu_share =
+                               strtoull(result->value, NULL, 10);
+               }
+               else if (!strncmp(result->name, CPU_CFS_RUN_TIME_NAME_CONF,
+                                       strlen(CPU_CFS_RUN_TIME_NAME_CONF)+1)) {
+                       cpu_throttling_conf->cpu_cgroup_info.cfs_runtime_us =
+                               config_parse_ll_time_us(result->value);
+               }
+               else if (!strncmp(result->name, CPU_CFS_PERIOD_NAME_CONF,
+                                       strlen(CPU_CFS_PERIOD_NAME_CONF)+1)) {
+                       cpu_throttling_conf->cpu_cgroup_info.cfs_period_us =
+                               config_parse_ull_time_us(result->value);
+               }
+               else {
+                       _E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
+                                       result->name, result->value, result->section);
+               }
+       }
        else {
                _E("[CONFIG] Unknown section name (%s) and value (%s) on section (%s)",
                                result->name, result->value, result->section);
@@ -646,28 +689,8 @@ static int vendor_config(struct parse_result *result, void *user_data)
                        return RESOURCED_ERROR_FAIL;
                }
 
-               if (!strncmp(result->value, CPU_SCHED_IDLE_VALUE_CONF,
-                                       strlen(CPU_SCHED_IDLE_VALUE_CONF) +1))
-                       pci->cpu_sched_info.cpu_sched_type = CPU_SCHED_IDLE;
-               else if (!strncmp(result->value, CPU_SCHED_OTHER_VALUE_CONF,
-                                       strlen(CPU_SCHED_OTHER_VALUE_CONF) +1))
-                       pci->cpu_sched_info.cpu_sched_type = CPU_SCHED_OTHER;
-               else if (!strncmp(result->value, CPU_SCHED_BATCH_VALUE_CONF,
-                                       strlen(CPU_SCHED_BATCH_VALUE_CONF) +1))
-                       pci->cpu_sched_info.cpu_sched_type = CPU_SCHED_BATCH;
-               else if (!strncmp(result->value, CPU_SCHED_FIFO_VALUE_CONF,
-                                       strlen(CPU_SCHED_FIFO_VALUE_CONF) +1))
-                       pci->cpu_sched_info.cpu_sched_type = CPU_SCHED_FIFO;
-               else if (!strncmp(result->value, CPU_SCHED_RR_VALUE_CONF,
-                                       strlen(CPU_SCHED_RR_VALUE_CONF) +1))
-                       pci->cpu_sched_info.cpu_sched_type = CPU_SCHED_RR;
-               else if (!strncmp(result->value, CPU_SCHED_DEADLINE_VALUE_CONF,
-                                       strlen(CPU_SCHED_DEADLINE_VALUE_CONF) +1))
-                       pci->cpu_sched_info.cpu_sched_type = CPU_SCHED_DEADLINE;
-               else {
-                       _E("invalid parameter (%s)", result->value);
-                       return RESOURCED_ERROR_INVALID_PARAMETER;
-               }
+               pci->cpu_sched_info.cpu_sched_type = config_parse_sched_type(result->value);
+
        }
        else if (!strncmp(result->name, CPU_NICE_NAME_CONF,
                                strlen(CPU_NICE_NAME_CONF)+1) && *config_type == OPTIMIZER_CONFIG) {
@@ -685,7 +708,7 @@ static int vendor_config(struct parse_result *result, void *user_data)
                }
                pci->cpu_sched_info.cpu_rt_priority = atoi(result->value);
        }
-       else if (!strncmp(result->name, CPU_RT_RUN_TIME_NAME_CONF,
+/*     else if (!strncmp(result->name, CPU_RT_RUN_TIME_NAME_CONF,
                                strlen(CPU_RT_RUN_TIME_NAME_CONF)+1) &&
                        *config_type == OPTIMIZER_CONFIG) {
                if (!pci) {
@@ -702,7 +725,7 @@ static int vendor_config(struct parse_result *result, void *user_data)
                        return RESOURCED_ERROR_FAIL;
                }
                pci->cpu_sched_info.rt_period_us = config_parse_time_us(result->value);
-       }
+       }*/
        else if (!strncmp(result->name, ACTION_ON_FAILURE_NAME_CONF,
                                strlen(ACTION_ON_FAILURE_NAME_CONF)+1) && *config_type == PROCESS_CONFIG) {
                if (!pci) {
index a7e7947..5b3b121 100644 (file)
@@ -30,102 +30,115 @@ extern "C" {
 
 #define CONF_FILE_SUFFIX                       ".conf"
 
-#define LIMITER_CONF_FILE           RD_CONFIG_FILE(limiter)
-#define OPTIMIZER_CONF_FILE         RD_CONFIG_FILE(optimizer)
-#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"
+#define LIMITER_CONF_FILE                   RD_CONFIG_FILE(limiter)
+#define OPTIMIZER_CONF_FILE                 RD_CONFIG_FILE(optimizer)
+#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"
 
 /* section name */
 /* limiter.conf */
-#define        PER_PROCESS_SECTION                                     "PerProcess"
-#define MEMORY_GROUP_LIMIT_SECTION                     "MemoryGroupLimit"
-#define MEMORY_LEVEL_THRESHOLD_SECTION         "MemoryLevelThreshold"
-#define MEMORY_APP_TYPE_LIMIT_SECTION          "MemoryAppTypeLimit"
-#define MEMORY_APP_STATUS_LIMIT_SECTION                "MemoryAppStatusLimit"
+#define        PER_PROCESS_SECTION                 "PerProcess"
+#define MEMORY_GROUP_LIMIT_SECTION          "MemoryGroupLimit"
+#define MEMORY_LEVEL_THRESHOLD_SECTION      "MemoryLevelThreshold"
+#define MEMORY_APP_TYPE_LIMIT_SECTION       "MemoryAppTypeLimit"
+#define MEMORY_APP_STATUS_LIMIT_SECTION     "MemoryAppStatusLimit"
+#define CPU_THROTTLING_SECTION              "CpuThrottling"
 
 /* optimizer.conf */
-#define SWAP_SECTION                                           "MemorySwap"
-#define ZRAM_SECTION                                           "MemoryZram"
-#define ZSWAP_SECTION                                          "MemoryZswap"
-#define DEDUP_SECTION                                          "MemoryDedup"
-#define KSM_SECTION                                                    "MemoryKsm"
-#define COMPACTION_SECTION                                     "MemoryCompaction"
+#define SWAP_SECTION                        "MemorySwap"
+#define ZRAM_SECTION                        "MemoryZram"
+#define ZSWAP_SECTION                       "MemoryZswap"
+#define DEDUP_SECTION                       "MemoryDedup"
+#define KSM_SECTION                         "MemoryKsm"
+#define COMPACTION_SECTION                  "MemoryCompaction"
 #define CPU_SCHED_SECTION                   "CpuSched"
-#define CPU_AFFINITY_SECTION                           "CpuAffinity"
+#define CPU_AFFINITY_SECTION                "CpuAffinity"
+#define CPU_BOOSTING_LEVEL_STRONG           "CpuBoostingLevelStrong"
+#define CPU_BOOSTING_LEVEL_MEDIUM           "CpuBoostingLevelMedium"
+#define CPU_BOOSTING_LEVEL_WEAK             "CpuBoostingLevelWeak"
 
 /* configuration name */
 /* limiter.conf */
-#define SERVICE_NAME_CONF                              "Service"
-#define APP_NAME_CONF                                  "App"
-#define CPU_CGROUP_NAME_CONF                   "CpuGroup"
-#define MEM_CGROUP_NAME_CONF                   "MemGroup"
-#define MEM_LIMIT_ACTION_NAME_CONF             "MemLimitAction"
-#define ACTION_ON_FAILURE_NAME_CONF            "ActionOnFailure"
-#define        WATCHDOG_ACTION_NAME_CONF               "WatchdogAction"
-#define VIP_GROUP_LIMIT_CONF                   "VipGroupLimit"
-#define HIGH_GROUP_LIMIT_CONF                  "HighGroupLimit"
-#define MEDIUM_GROUP_LIMIT_CONF                        "MediumGroupLimit"
-#define LOWEST_GROUP_LIMIT_CONF                        "LowestGroupLimit"
-#define MEDIUM_LEVEL_CONF                              "MediumLevel"
-#define LOW_LEVEL_CONF                                 "LowLevel"
-#define CRITICAL_LEVEL_CONF                            "CriticalLevel"
-#define OOM_LEVEL_CONF                                 "OomLevel"
-#define OOM_POPUP_CONF                                 "OomPopup"
-#define SERVICE_PER_APP_LIMIT_ACTION   "ServicePerAppLimitAction"
-#define WIDGET_PER_APP_LIMIT_ACTION            "WidgetPerAppLimitAction"
-#define GUI_PER_APP_LIMIT_ACTION               "GUIPerAppLimitAction"
-#define BACKGROUND_PER_APP_LIMIT_ACTION        "BackgroundPerAppLimitAction"
+#define SERVICE_NAME_CONF                            "Service"
+#define APP_NAME_CONF                                "App"
+//#define CPU_CGROUP_NAME_CONF                 "CpuGroup"
+#define MEM_CGROUP_NAME_CONF                         "MemGroup"
+#define MEM_LIMIT_ACTION_NAME_CONF                   "MemLimitAction"
+#define ACTION_ON_FAILURE_NAME_CONF                  "ActionOnFailure"
+#define        WATCHDOG_ACTION_NAME_CONF                    "WatchdogAction"
+#define VIP_GROUP_LIMIT_NAME_CONF                    "VipGroupLimit"
+#define HIGH_GROUP_LIMIT_NAME_CONF                   "HighGroupLimit"
+#define MEDIUM_GROUP_LIMIT_NAME_CONF                 "MediumGroupLimit"
+#define LOWEST_GROUP_LIMIT_NAME_CONF                 "LowestGroupLimit"
+#define MEDIUM_LEVEL_NAME_CONF                       "MediumLevel"
+#define LOW_LEVEL_NAME_CONF                          "LowLevel"
+#define CRITICAL_LEVEL_NAME_CONF                     "CriticalLevel"
+#define OOM_LEVEL_NAME_CONF                          "OomLevel"
+#define OOM_POPUP_NAME_CONF                          "OomPopup"
+#define SERVICE_PER_APP_LIMIT_ACTION_NAME_CONF       "ServicePerAppLimitAction"
+#define WIDGET_PER_APP_LIMIT_ACTION_NAME_CONF        "WidgetPerAppLimitAction"
+#define GUI_PER_APP_LIMIT_ACTION_NAME_CONF           "GUIPerAppLimitAction"
+#define BACKGROUND_PER_APP_LIMIT_ACTION_NAME_CONF    "BackgroundPerAppLimitAction"
+
+/* CPU specific configuration name */
+#define CPU_SCHED_NAME_CONF                          "CpuSched"
+#define CPU_NICE_NAME_CONF                           "CpuNice"
+#define CPU_SHARE_NAME_CONF                          "CpuShare"
+#define CPU_RT_PRIORITY_NAME_CONF                    "CpuRTPriority"
+#define CPU_SCHED_FEATURE_NAME_CONF                  "CpuSchedFeature"
+#define CPU_RT_RUN_TIME_NAME_CONF                    "CpuRTRuntime"
+#define CPU_RT_PERIOD_NAME_CONF                      "CpuRTPeriod"
+#define CPU_CFS_RUN_TIME_NAME_CONF                   "CpuCFSRuntime"
+#define CPU_CFS_PERIOD_NAME_CONF                     "CpuCFSPeriod"
+#define CPU_BOOSTING_LEVEL_NAME_CONF                 "CpuBoostingLevel"
+#define CPU_THROTTLING_NAME_CONF                     "CpuThrottling"
 
 /* optimizer.conf */
-#define        SWAP_ENABLE_CONF                                "SwapEnable"
-#define RECLAIM_AT_BOOT_CONF                   "ReclaimAtBoot"
-#define SWAP_TYPE_CONF                                 "SwapType"
-#define VIP_GROUP_SWAPPINESS_CONF              "VipGroupSwappiness"
-#define HIGH_GROUP_SWAPPINESS_CONF             "HighGroupSwappiness"
-#define MEDIUM_GROUP_SWAPPINESS_CONF   "MediumGroupSwappiness"
-#define LOWEST_GROUP_SWAPPINESS_CONF   "LowestGroupSwappiness"
-#define COMP_ALGORITHM_CONF                            "CompAlgorithm"
-#define ZRAM_RATIO_CONF                                        "ZramRatio"
-#define POOL_RATIO_CONF                                        "PoolRatio"
-#define POOL_TYPE_CONF                                 "PoolType"
-#define        DEDUP_ENABLE_CONF                               "DedupEnable"
-#define DEDUP_AT_BOOT_CONF                             "DedupAtBoot"
-#define        SCAN_ON_LOWMEM_CONF                             "ScanOnLowmem"
-#define KSM_MODE_CONF                                  "KsmMode"
-#define        PAGES_TO_SCAN_CONF                              "PagesToScan"
-#define PAGES_TO_SCAN_WITH_BOOST_CONF  "PagesToScanWithBoost"
-#define        COMPACTION_ENABLE_CONF                  "CompactionEnable"
-#define CPU_SCHED_FEATURE_NAME_CONF     "CpuSchedFeature"
-#define CPU_RT_RUN_TIME_NAME_CONF       "CpuRTRunTime"
-#define CPU_RT_PERIOD_NAME_CONF         "CpuRTPeriod"
-#define FRAG_LEVEL_CONF                                        "FragLevel"
-#define FOREGROUND_APPS                                        "ForegroundApps"
-/* optimizer.conf.d */
-#define CPU_SCHED_NAME_CONF             "CpuSched"
-#define CPU_RT_PRIORITY_NAME_CONF              "CpuRTPriority"
-#define CPU_NICE_NAME_CONF              "CpuNice"
+#define        SWAP_ENABLE_NAME_CONF                        "SwapEnable"
+#define RECLAIM_AT_BOOT_NAME_CONF                    "ReclaimAtBoot"
+#define SWAP_TYPE_NAME_CONF                          "SwapType"
+#define VIP_GROUP_SWAPPINESS_NAME_CONF               "VipGroupSwappiness"
+#define HIGH_GROUP_SWAPPINESS_NAME_CONF              "HighGroupSwappiness"
+#define MEDIUM_GROUP_SWAPPINESS_NAME_CONF            "MediumGroupSwappiness"
+#define LOWEST_GROUP_SWAPPINESS_NAME_CONF            "LowestGroupSwappiness"
+#define COMP_ALGORITHM_NAME_CONF                     "CompAlgorithm"
+#define ZRAM_RATIO_NAME_CONF                         "ZramRatio"
+#define POOL_RATIO_NAME_CONF                         "PoolRatio"
+#define POOL_TYPE_NAME_CONF                          "PoolType"
+#define        DEDUP_ENABLE_NAME_CONF                       "DedupEnable"
+#define DEDUP_AT_BOOT_NAME_CONF                      "DedupAtBoot"
+#define        SCAN_ON_LOWMEM_NAME_CONF                     "ScanOnLowmem"
+#define KSM_MODE_NAME_CONF                           "KsmMode"
+#define        PAGES_TO_SCAN_NAME_CONF                      "PagesToScan"
+#define PAGES_TO_SCAN_WITH_BOOST_NAME_CONF           "PagesToScanWithBoost"
+#define        COMPACTION_ENABLE_NAME_CONF                  "CompactionEnable"
+#define FRAG_LEVEL_NAME_CONF                         "FragLevel"
+#define FOREGROUND_APPS_NAME_CONF                    "ForegroundApps"
 
 /* configuration value */
-#define CGROUP_VIP_VALUE_CONF          "vip"
-#define CGROUP_HIGH_VALUE_CONF         "high"
-#define CGROUP_MEDIUM_VALUE_CONF       "medium"
-#define CGROUP_LOW_VALUE_CONF          "lowest"
-#define ACTION_BROADCAST_VALUE_CONF    "broadcast"
-#define ACTION_RECLAIM_VALUE_CONF      "reclaim"
-#define ACTION_KILL_VALUE_CONF         "kill"
-#define ACTION_REBOOT_VALUE_CONF       "reboot"
-#define ACTION_IGNORE_VALUE_CONF       "ignore"
-#define RT_RUNTIME_SHARE_VALUE_CONF            "rt_runtime_share"
-#define NO_RT_RUNTIME_SHARE_VALUE_CONF         "no_rt_runtime_share"
-#define RT_RUNTIME_GREED_VALUE_CONF            "rt_runtime_greed"
-
-#define CPU_SCHED_DEADLINE_VALUE_CONF          "deadline"
-#define CPU_SCHED_FIFO_VALUE_CONF              "fifo"
-#define CPU_SCHED_RR_VALUE_CONF                "rr"
-#define CPU_SCHED_OTHER_VALUE_CONF             "other"
-#define CPU_SCHED_IDLE_VALUE_CONF              "idle"
-#define CPU_SCHED_BATCH_VALUE_CONF             "batch"
+#define CGROUP_VIP_VALUE_CONF                        "vip"
+#define CGROUP_HIGH_VALUE_CONF                       "high"
+#define CGROUP_MEDIUM_VALUE_CONF                     "medium"
+#define CGROUP_LOW_VALUE_CONF                        "lowest"
+#define ACTION_BROADCAST_VALUE_CONF                  "broadcast"
+#define ACTION_RECLAIM_VALUE_CONF                    "reclaim"
+#define ACTION_KILL_VALUE_CONF                       "kill"
+#define ACTION_REBOOT_VALUE_CONF                     "reboot"
+#define ACTION_IGNORE_VALUE_CONF                     "ignore"
+
+/* CPU specific configuration name */
+#define RT_RUNTIME_SHARE_VALUE_CONF                  "rt_runtime_share"
+#define NO_RT_RUNTIME_SHARE_VALUE_CONF               "no_rt_runtime_share"
+#define CPU_SCHED_DEADLINE_VALUE_CONF                "deadline"
+#define CPU_SCHED_FIFO_VALUE_CONF                    "fifo"
+#define CPU_SCHED_RR_VALUE_CONF                      "rr"
+#define CPU_SCHED_OTHER_VALUE_CONF                   "other"
+#define CPU_SCHED_IDLE_VALUE_CONF                    "idle"
+#define CPU_SCHED_BATCH_VALUE_CONF                   "batch"
+#define CPU_BOOSTING_LEVEL_STRONG_VALUE_CONF         "strong"
+#define CPU_BOOSTING_LEVEL_MEDIUM_VALUE_CONF         "medium"
+#define CPU_BOOSTING_LEVEL_WEAK_VALUE_CONF           "weak"
 
 #define MATCH(a, b)    (!strncmp(a, b, strlen(a) + 1) ? 1 : 0)
 #define SET_CONF(a, b) (a = (b > 0.0 ? b : a))
diff --git a/src/common/cpu-common.c b/src/common/cpu-common.c
new file mode 100644 (file)
index 0000000..0cb4f93
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * resourced
+ *
+ * Copyright (c) 2020 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 "macro.h"
+#include "cpu-common.h"
+#include "trace.h"
+#include "resourced.h"
+
+static struct cpu_sched_conf *cpu_sched_conf = NULL;
+static struct cpu_affinity_conf *cpu_affinity_conf = NULL;
+static struct cpu_throttling_conf *cpu_throttling_conf = NULL;
+
+struct cpu_sched_conf *get_cpu_sched_conf(void)
+{
+       if (!cpu_sched_conf) {
+               cpu_sched_conf = (struct cpu_sched_conf *)calloc(1, sizeof (struct cpu_sched_conf));
+               if (!cpu_sched_conf) {
+                       _E("Failed to alloc memory for cpu configuration");
+                       return NULL;
+               }
+               else {
+                       cpu_sched_conf->cpu_sched_flag = CPU_SCHED_UNINITIALIZED;
+                       cpu_sched_conf->cpu_cgroup_info.rt_runtime_us = 0;
+                       cpu_sched_conf->cpu_cgroup_info.rt_period_us = 0;
+               }
+       }
+
+       return cpu_sched_conf;
+}
+
+void free_cpu_sched_conf(void)
+{
+       if (cpu_sched_conf)
+               free(cpu_sched_conf);
+}
+
+char *get_cpu_affinity_conf_name(void)
+{
+       if (cpu_affinity_conf)
+               return cpu_affinity_conf->cpuset_cgroup_info.name;
+       else
+               return NULL;
+}
+
+char *get_cpu_affinity_conf_value(void)
+{
+       if (cpu_affinity_conf)
+               return cpu_affinity_conf->cpuset_cgroup_info.value;
+       else
+               return NULL;
+}
+
+int set_cpu_affinity_conf(const char *name, const char *value)
+{
+       if (!cpu_affinity_conf) {
+               cpu_affinity_conf = (struct cpu_affinity_conf *)calloc(1, sizeof (struct cpu_affinity_conf));
+               if (!cpu_affinity_conf) {
+                       _E("Failed to alloc memory for cpu configuration");
+                       return RESOURCED_ERROR_OUT_OF_MEMORY;
+               }
+       }
+
+       if (strlen(name) + 1 > sizeof(cpu_affinity_conf->cpuset_cgroup_info.name)) {
+               _E("Size of cpu configuration for name is not enough");
+               return RESOURCED_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(cpu_affinity_conf->cpuset_cgroup_info.name, name, sizeof(cpu_affinity_conf->cpuset_cgroup_info.name) - 1);
+
+       if (strlen(value) + 1 > sizeof(cpu_affinity_conf->cpuset_cgroup_info.value)) {
+               _E("Size of cpu configuration for value is not enough");
+               return RESOURCED_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(cpu_affinity_conf->cpuset_cgroup_info.value, value, sizeof(cpu_affinity_conf->cpuset_cgroup_info.value) - 1);
+
+       return RESOURCED_ERROR_NONE;
+}
+
+void free_cpu_affinity_conf(void)
+{
+       if (cpu_affinity_conf)
+               free(cpu_affinity_conf);
+}
+
+struct cpu_throttling_conf *get_cpu_throttling_conf(void)
+{
+       if (!cpu_throttling_conf) {
+               cpu_throttling_conf = (struct cpu_throttling_conf *)calloc(1, sizeof (struct cpu_throttling_conf));
+               if (!cpu_throttling_conf) {
+                       _E("Failed to alloc memory for cpu configuration");
+                       return NULL;
+               }
+               else {
+                       cpu_throttling_conf->enable = false;
+                       cpu_throttling_conf->cpu_sched_info.cpu_sched_type = CPU_SCHED_NONE;
+                       cpu_throttling_conf->cpu_sched_info.cpu_nice = CPU_INIT_NICE;
+                       cpu_throttling_conf->cpu_cgroup_info.cfs_runtime_us = 0;
+                       cpu_throttling_conf->cpu_cgroup_info.cfs_period_us = 0;
+                       cpu_throttling_conf->cpu_cgroup_info.cpu_share = 0;
+               }
+       }
+
+       return cpu_throttling_conf;
+}
+
+void free_cpu_throttling_conf(void)
+{
+       if (cpu_throttling_conf)
+               free(cpu_throttling_conf);
+}
+
diff --git a/src/common/cpu-common.h b/src/common/cpu-common.h
new file mode 100644 (file)
index 0000000..64e5d26
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef __CPU_COMMON_H__
+#define __CPU_COMMON_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define CPU_INIT_NICE         100
+#define CPU_MAX_NICE          19
+#define CPU_MIN_NICE          -20
+
+#define CPU_INIT_PRIO         0
+#define CPU_MAX_PRIO          99
+#define CPU_MIN_PRIO          1
+
+#define CPU_DEFAULT_SHARE     1024
+#define CPU_THROTTLING_SHARE  64
+
+enum cpu_sched_flag {
+       CPU_SCHED_UNINITIALIZED = 0,
+       CPU_SCHED_RUNTIME_SHARE = 1,
+       CPU_SCHED_NO_RUNTIME_SHARE = 2,
+       CPU_SCHED_RUNTIME_GREED = 4,
+};
+
+enum cpu_sched_type {
+       CPU_SCHED_NONE = 0,
+       CPU_SCHED_IDLE = 1,
+       CPU_SCHED_BATCH,
+       CPU_SCHED_OTHER,
+       CPU_SCHED_FIFO,
+       CPU_SCHED_RR,
+       CPU_SCHED_DEADLINE,
+};
+
+struct cpu_sched_info {
+       enum cpu_sched_type cpu_sched_type;
+       int cpu_nice;                        /* fixed cpu nice */
+       int cpu_rt_priority;                 /* fixed cpu priority for rt schedulers */
+};
+
+struct cpuset_cgroup_info {
+       char name[64];
+       char value[64];
+};
+
+struct cpu_cgroup_info {
+       long long cfs_runtime_us;
+       long long rt_runtime_us;
+       unsigned long long cfs_period_us;
+       unsigned long long rt_period_us;
+       unsigned long long cpu_share;
+};
+
+struct cpu_sched_conf {
+       enum cpu_sched_flag cpu_sched_flag;
+       struct cpu_cgroup_info cpu_cgroup_info;
+};
+
+struct cpu_affinity_conf {
+       struct cpuset_cgroup_info cpuset_cgroup_info;
+};
+
+struct cpu_throttling_conf {
+       bool enable;
+       struct cpu_sched_info cpu_sched_info;
+       struct cpu_cgroup_info cpu_cgroup_info;
+};
+
+struct cpu_sched_conf *get_cpu_sched_conf(void);
+void free_cpu_sched_conf(void);
+
+char *get_cpu_affinity_conf_name(void);
+char *get_cpu_affinity_conf_value(void);
+int set_cpu_affinity_conf(const char *name, const char *value);
+void free_cpu_affinity_conf(void);
+
+struct cpu_throttling_conf *get_cpu_throttling_conf(void);
+void free_cpu_throttling_conf(void);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CPU_COMMON_H__ */
diff --git a/src/common/cpu-sched-common.c b/src/common/cpu-sched-common.c
deleted file mode 100644 (file)
index afebe6a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * resourced
- *
- * Copyright (c) 2020 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 "macro.h"
-#include "cpu-sched-common.h"
-#include "trace.h"
-
-static struct cpu_sched_conf *cpu_sched_conf = NULL;
-
-struct cpu_sched_conf *get_cpu_sched_conf(void)
-{
-       if (!cpu_sched_conf) {
-               cpu_sched_conf = (struct cpu_sched_conf *)calloc(1, sizeof (struct cpu_sched_conf));
-               if (!cpu_sched_conf) {
-                       _E("Failed to alloc memory for cpu configuration");
-                       return NULL;
-               }
-       }
-
-       return cpu_sched_conf;
-}
-
-void free_cpu_sched_conf(void)
-{
-       if (cpu_sched_conf)
-               free(cpu_sched_conf);
-}
diff --git a/src/common/cpu-sched-common.h b/src/common/cpu-sched-common.h
deleted file mode 100644 (file)
index e2fcd41..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __CPU_SCHED_COMMON_H__
-#define __CPU_SCHED_COMMON_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#define CPU_INIT_NICE  100
-#define CPU_MAX_NICE   19
-#define CPU_MIN_NICE   -20
-
-#define CPU_INIT_PRIO  0
-#define CPU_MAX_PRIO   99
-#define CPU_MIN_PRIO   1
-
-enum cpu_sched_flag {
-       CPU_SCHED_UNINITIALIZED = 0,
-       CPU_SCHED_RUNTIME_SHARE = 1,
-       CPU_SCHED_NO_RUNTIME_SHARE = 2,
-       CPU_SCHED_RUNTIME_GREED = 4,
-};
-
-enum cpu_sched_type {
-       CPU_SCHED_NONE = 0,
-       CPU_SCHED_IDLE = 1,
-       CPU_SCHED_BATCH,
-       CPU_SCHED_OTHER,
-       CPU_SCHED_FIFO,
-       CPU_SCHED_RR,
-       CPU_SCHED_DEADLINE,
-};
-
-struct cpu_sched_info {
-       enum cpu_sched_type cpu_sched_type;
-       int cpu_nice;                        /* fixed cpu nice */
-       int cpu_rt_priority;                 /* fixed cpu priority for rt schedulers */
-       int rt_period_us;                    /* fixed cpu period */
-       int rt_runtime_us;                   /* fixed cpu runtime during period */
-};
-
-struct cpu_sched_conf {
-       int rt_period_us;
-       int rt_runtime_us;
-       enum cpu_sched_flag cpu_sched_flag;
-};
-
-struct cpu_sched_conf *get_cpu_sched_conf(void);
-void free_cpu_sched_conf(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CPU_SCHED_COMMON_H__ */
index 0269921..dbaa927 100644 (file)
@@ -33,6 +33,11 @@ struct dedup_conf *get_dedup_conf(void)
                        return NULL;
                }
        }
+       else {
+               dedup_conf->enable = false;
+               dedup_conf->boot_dedup_enable = false;
+               dedup_conf->scan_on_lowmem = false;
+       }
 
        return dedup_conf;
 }
index 0d9e0bd..28ffff9 100644 (file)
@@ -102,6 +102,18 @@ int fwrite_ulonglong(const char *path, const unsigned long long number)
        return fwrite_str(path, digit_buf);
 }
 
+int fwrite_longlong(const char *path, const long long number)
+{
+       _cleanup_free_ char *digit_buf = NULL;
+       int ret;
+
+       ret = asprintf(&digit_buf, "%lld", number);
+       ret_value_errno_msg_if(ret < 0, -ENOMEM,
+                              "sprintf failed\n");
+
+       return fwrite_str(path, digit_buf);
+}
+
 int fread_str(const char *path, char **str)
 {
        _cleanup_fclose_ FILE *f = NULL;
index 36a7b48..c524a86 100644 (file)
@@ -45,6 +45,7 @@ int fwrite_uint(const char *path, const u_int32_t number);
 
 int fwrite_ulong(const char *path, const unsigned long number);
 int fwrite_ulonglong(const char *path, const unsigned long long number);
+int fwrite_longlong(const char *path, const long long number);
 
 int fread_str(const char *path, char **str);
 
index 24b2b10..eb15854 100644 (file)
@@ -32,7 +32,7 @@
 #include "resourced.h"
 #include "const.h"
 #include "memory-cgroup.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -209,7 +209,6 @@ struct proc_app_info {
        pid_list childs;
        bool app_watchdog_exclude;
        bool app_memcg_update_exclude;
-       bool app_cpucg_update_exclude;
        bool app_cpu_nice_update_exclude;
        int runtime_exclude;
        int flags;
index 3bc3e44..57f8fab 100644 (file)
@@ -32,6 +32,11 @@ struct swap_conf *get_swap_conf(void)
                        _E("Failed to alloc memory for cpu configuration");
                        return NULL;
                }
+               else {
+                       swap_conf->enable = false;
+                       swap_conf->boot_reclaim_enable = false;
+                       swap_conf->swap_type = SWAP_TYPE_NONE;
+               }
        }
 
        return swap_conf;
index 79240f7..5d84a9b 100644 (file)
 #include <assert.h>
 #include <stdlib.h>
 #include <sched.h>
+#include <ctype.h>
 
 #include "util.h"
 #include "trace.h"
 #include "resourced.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 
 #define GIGA_SHIFT 30
 #define MEGA_SHIFT 20
 # define SYS_sched_getattr _NR_sched_getattr
 #endif
 
-int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags)
+static int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags)
 {
        int error;
 
-       _I("[CPU-SCHED] policy = %s", attr->sched_policy == SCHED_IDLE ? "SCHED_IDLE" :
-                                         attr->sched_policy == SCHED_BATCH ? "SCHED_BATCH" :
-                                                                 attr->sched_policy == SCHED_OTHER ? "SCHED_OTHER" :
-                                                                 attr->sched_policy == SCHED_FIFO ? "SCHED_FIFO" :
-                                                                 attr->sched_policy == SCHED_RR ? "SCHED_RR" :
-                                                                 attr->sched_policy == SCHED_DEADLINE ? "SCHED_DEADLINE" : "UNKNOWN");
-
        switch (attr->sched_policy) {
                case SCHED_IDLE:
                        if (attr->sched_priority != 0) {
@@ -82,7 +76,7 @@ int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags)
                        }
 
 #ifndef SYS_sched_setattr
-                       setpriority(PRIO_PROCESS, pid, attr->sched_nice);
+                       setpriority(PRIO_PGRP, pid, attr->sched_nice);
 #endif
                        break;
                case SCHED_FIFO:
@@ -118,6 +112,50 @@ int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags)
        return RESOURCED_ERROR_NONE;
 }
 
+int sched_setattr_of_all_tasks(pid_t pid, struct sched_attr *attr, unsigned int flag)
+{
+       int r;
+       pid_t tid;
+       _cleanup_free_ char *buf = NULL;
+       DIR *dir;
+       struct dirent *dirent;
+
+       r = asprintf(&buf, "/proc/%d/task", pid);
+       if (r < 0)
+               return -ENOMEM;
+
+       dir = opendir(buf);
+       if (!dir)
+               return -ENOTDIR;
+
+       _D("[CPU-SCHED] policy = %s", attr->sched_policy == SCHED_IDLE ? "SCHED_IDLE" :
+                                         attr->sched_policy == SCHED_BATCH ? "SCHED_BATCH" :
+                                                                 attr->sched_policy == SCHED_OTHER ? "SCHED_OTHER" :
+                                                                 attr->sched_policy == SCHED_FIFO ? "SCHED_FIFO" :
+                                                                 attr->sched_policy == SCHED_RR ? "SCHED_RR" :
+                                                                 attr->sched_policy == SCHED_DEADLINE ? "SCHED_DEADLINE" : "UNKNOWN");
+
+       while ((dirent = readdir(dir))) {
+               const char *id = dirent->d_name;
+               if(!isdigit(*id))
+                       continue;
+
+               tid = atoi(id);
+               if (tid > 0) {
+                       r = sched_setattr(tid, attr, flag);
+                       if (r < 0) {
+                               _E("Failed to change scheduler of tid (%d)", tid);
+                       }
+               }
+               else {
+                       _E("Thread id (%d) should be larger than 0", tid);
+               }
+       }
+
+       closedir(dir);
+       return 0;
+}
+
 int sched_getattr(pid_t pid, struct sched_attr *attr, unsigned int flags)
 {
 #ifdef SYS_sched_getattr
index 456d6af..2e44dc6 100644 (file)
@@ -165,7 +165,7 @@ void strv_free_full(char ***strv);
 
 int resourced_restarted(void);
 
-int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags);
+int sched_setattr_of_all_tasks(pid_t pid, struct sched_attr *attr, unsigned int flag);
 int sched_getattr(pid_t pid, struct sched_attr *attr, unsigned int flags);
 
 int str_name_cpy(char *dst, const char *src, int dst_size, int src_length);
index cd913be..ac085d6 100644 (file)
@@ -37,7 +37,7 @@
 #include "procfs.h"
 #include "resourced.h"
 #include "trace.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 
 static GHashTable *fixed_app_list;
 static GHashTable *fixed_service_list;
index 401dee5..03b659b 100644 (file)
@@ -56,7 +56,7 @@
 #include "config-parser.h"
 #include "fd-handler.h"
 #include "cpu-cgroup.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 
 #ifndef gettid
 #include <sys/syscall.h>
@@ -828,11 +828,6 @@ __attribute__((weak)) struct proc_app_info *proc_create_app_info(const char *app
                                        pai->app_memcg_update_exclude = true;
                                }
 
-/*                             if (pci->cpu_type != CGROUP_TOP) {
-                                       cpu_move_cgroup_foreach(pid, pai, CPU_CGROUP_PATH(pci->cpu_type));
-                                       pai->app_cpucg_update_exclude = true;
-                               }*/
-
                                memset(&attr, 0, sizeof(struct sched_attr));
                                attr.size = sizeof(struct sched_attr);
                                if (pci->cpu_sched_info.cpu_nice >= CPU_MIN_NICE &&
@@ -856,70 +851,68 @@ __attribute__((weak)) struct proc_app_info *proc_create_app_info(const char *app
                                        case CPU_SCHED_NONE:
                                        case CPU_SCHED_OTHER:
                                                attr.sched_policy = SCHED_OTHER;
-                                               sched_setattr(pid, &attr, 0);
-                                               error = sched_getattr(pid, &attr, 0);
+/*                                             error = sched_getattr(pid, &attr, 0);
                                                if (error)
                                                        _E("[PROCESS] Failed to get sched attributes");
 
                                                if (attr.sched_policy != SCHED_OTHER)
                                                        _E("[PROCESS] current policy (%d) is different from %d",
-                                                                       attr.sched_policy, SCHED_OTHER);
+                                                                       attr.sched_policy, SCHED_OTHER);*/
                                                break;
                                        case CPU_SCHED_IDLE:
                                                attr.sched_policy = SCHED_IDLE;
-                                               sched_setattr(pid, &attr, 0);
-                                               error = sched_getattr(pid, &attr, 0);
+/*                                             error = sched_getattr(pid, &attr, 0);
                                                if (error)
                                                        _E("[PROCESS] Failed to get sched attributes");
 
                                                if (attr.sched_policy != SCHED_IDLE)
                                                        _E("[PROCESS] current policy (%d) is different from %d",
-                                                                       attr.sched_policy, SCHED_IDLE);
+                                                                       attr.sched_policy, SCHED_IDLE);*/
                                                break;
                                        case CPU_SCHED_BATCH:
                                                attr.sched_policy = SCHED_BATCH;
-                                               sched_setattr(pid, &attr, 0);
-                                               error = sched_getattr(pid, &attr, 0);
+/*                                             error = sched_getattr(pid, &attr, 0);
                                                if (error)
                                                        _E("[PROCESS] Failed to get sched attributes");
 
                                                if (attr.sched_policy != SCHED_BATCH)
                                                        _E("[PROCESS] current policy (%d) is different from %d",
-                                                                       attr.sched_policy, SCHED_BATCH);
+                                                                       attr.sched_policy, SCHED_BATCH);*/
                                                break;
                                        case CPU_SCHED_FIFO:
                                                attr.sched_policy = SCHED_FIFO;
-                                               sched_setattr(pid, &attr, 0);
-                                               error = sched_getattr(pid, &attr, 0);
+/*                                             error = sched_getattr(pid, &attr, 0);
                                                if (error)
                                                        _E("[PROCESS] Failed to get sched attributes");
 
                                                if (attr.sched_policy != SCHED_FIFO)
                                                        _E("[PROCESS] current policy (%d) is different from %d",
-                                                                       attr.sched_policy, SCHED_FIFO);
+                                                                       attr.sched_policy, SCHED_FIFO);*/
                                                break;
                                        case CPU_SCHED_RR:
                                                attr.sched_policy = SCHED_RR;
-                                               sched_setattr(pid, &attr, 0);
-                                               error = sched_getattr(pid, &attr, 0);
+/*                                             error = sched_getattr(pid, &attr, 0);
                                                if (error)
                                                        _E("[PROCESS] Failed to get sched attributes");
 
                                                if (attr.sched_policy != SCHED_RR)
                                                        _E("[PROCESS] current policy (%d) is different from %d",
-                                                                       attr.sched_policy, SCHED_RR);
+                                                                       attr.sched_policy, SCHED_RR);*/
                                                break;
                                        case CPU_SCHED_DEADLINE:
                                                attr.sched_policy = SCHED_DEADLINE;
-                                               sched_setattr(pid, &attr, 0);
-                                               error = sched_getattr(pid, &attr, 0);
+/*                                             error = sched_getattr(pid, &attr, 0);
                                                if (error)
-                                                       _E("[PROCESS] Failed to get sched attributes");
+                                                       _E("[PROCESS] Failed to get sched attributes");*/
                                                break;
                                        default:
                                                _E("[PROCESS] Unknown CPU sched type");
                                }
 
+                               error = sched_setattr_of_all_tasks(pid, &attr, 0);
+                               if (error)
+                                       _E("[PROCESS] Failed to set sched attributes");
+
                                _I("[PROCESS] policy = %s", attr.sched_policy == SCHED_IDLE ? "SCHED_IDLE" :
                                                                                  attr.sched_policy == SCHED_BATCH ? "SCHED_BATCH" :
                                                                                  attr.sched_policy == SCHED_OTHER ? "SCHED_OTHER" :
@@ -933,7 +926,7 @@ __attribute__((weak)) struct proc_app_info *proc_create_app_info(const char *app
                                        pai->app_watchdog_exclude = true;
 
                                /* register RT throttling */
-                               if (pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_FIFO ||
+/*                             if (pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_FIFO ||
                                        pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_RR ||
                                        pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_DEADLINE) {
                                        if (pci->cpu_sched_info.rt_period_us > 0 &&
@@ -945,7 +938,7 @@ __attribute__((weak)) struct proc_app_info *proc_create_app_info(const char *app
                                                ps.pci = pci;
                                                resourced_notify(RESOURCED_NOTIFIER_RT_SCHEDULER, &ps);
                                        }
-                               }
+                               }*/
 
                                if (pci->mem_action.memory_bytes && pci->mem_action.action) {
                                        struct proc_limit_status pls = {0, };
index c957e72..4072321 100644 (file)
@@ -10,7 +10,7 @@
 #include "proc-common.h"
 #include "file-helper.h"
 #include "cpu-cgroup.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 #include "util.h"
 
 #define MOUNTS_PATH                    "/proc/mounts"
@@ -242,11 +242,11 @@ static int load_cpu_affinity_config(struct cpu_sched *data)
 
        assert(data);
 
-       if (!get_cpucg_conf_name())
+       if (!get_cpu_affinity_conf_name())
                return RESOURCED_ERROR_NONE;
 
-       name = strdup(get_cpucg_conf_name());
-       is_fg = !strcmp(name, FOREGROUND_APPS);
+       name = strdup(get_cpu_affinity_conf_name());
+       is_fg = !strcmp(name, FOREGROUND_APPS_NAME_CONF);
 
        struct coreset *c = (struct coreset *)calloc(1, sizeof *c);
        if (c == NULL) {
@@ -256,7 +256,7 @@ static int load_cpu_affinity_config(struct cpu_sched *data)
 
        c->name = name;
 
-       if (cpu_sched_parse_cpuset(c, get_cpucg_conf_value()) < 0) {
+       if (cpu_sched_parse_cpuset(c, get_cpu_affinity_conf_value()) < 0) {
                return RESOURCED_ERROR_FAIL;
        }
 
@@ -265,7 +265,7 @@ static int load_cpu_affinity_config(struct cpu_sched *data)
        else
                data->apps = g_slist_append(data->apps, c);
 
-       free_cpucg_conf();
+       free_cpu_affinity_conf();
        return RESOURCED_ERROR_NONE;
 }
 
@@ -277,11 +277,12 @@ static int load_cpu_sched_config(void)
                return RESOURCED_ERROR_FAIL;
        }
 
-       if (cpu_sched_conf->rt_period_us > 0 &&
-           cpu_sched_conf->rt_runtime_us > 0 &&
-               cpu_sched_conf->rt_period_us > cpu_sched_conf->rt_runtime_us) {
-               fwrite_int(GLOBAL_RT_PERIOD_US_PATH, cpu_sched_conf->rt_period_us);
-               fwrite_int(GLOBAL_RT_RUNTIME_US_PATH, cpu_sched_conf->rt_runtime_us);
+       if (cpu_sched_conf->cpu_cgroup_info.rt_period_us > 0 &&
+           cpu_sched_conf->cpu_cgroup_info.rt_runtime_us > 0 &&
+               cpu_sched_conf->cpu_cgroup_info.rt_period_us >
+               cpu_sched_conf->cpu_cgroup_info.rt_runtime_us) {
+               fwrite_ulonglong(GLOBAL_RT_PERIOD_US_PATH, cpu_sched_conf->cpu_cgroup_info.rt_period_us);
+               fwrite_longlong(GLOBAL_RT_RUNTIME_US_PATH, cpu_sched_conf->cpu_cgroup_info.rt_runtime_us);
        }
 
        if (cpu_sched_conf->cpu_sched_flag) {
@@ -297,13 +298,13 @@ static int load_cpu_sched_config(void)
                                fwrite_str(CPU_SCHED_FEATURE_PATH, "NO_RT_RUNTIME_SHARE");
 
                        /* RT_RUNTIME_GREED */
-                       if (CHECK_BIT(cpu_sched_conf->cpu_sched_flag, CPU_SCHED_RUNTIME_GREED))
-                               fwrite_str(CPU_SCHED_FEATURE_PATH, "RT_RUNTIME_GREED");
+/*                     if (CHECK_BIT(cpu_sched_conf->cpu_sched_flag, CPU_SCHED_RUNTIME_GREED))
+                               fwrite_str(CPU_SCHED_FEATURE_PATH, "RT_RUNTIME_GREED");*/
                }
        }
 
-       _I("[CPU-SCHED] rt_period_us = %d", cpu_sched_conf->rt_period_us);
-       _I("[CPU-SCHED] rt_runtime_us = %d", cpu_sched_conf->rt_runtime_us);
+       _I("[CPU-SCHED] rt_period_us = %llu", cpu_sched_conf->cpu_cgroup_info.rt_period_us);
+       _I("[CPU-SCHED] rt_runtime_us = %lld", cpu_sched_conf->cpu_cgroup_info.rt_runtime_us);
        _I("[CPU-SCHED] cpu_sched_feature = %d", cpu_sched_conf->cpu_sched_flag);
 
        free_cpu_sched_conf();
@@ -532,7 +533,7 @@ static int cpu_sched_app_launch(void *data)
        return cpu_sched_add_pid_to_cpuset(c, ps->pid);
 }
 
-static int cpu_sched_rt_scheduler(void *data)
+/*static int cpu_sched_rt_scheduler(void *data)
 {
        _cleanup_free_ char *path = NULL;
        int result;
@@ -568,7 +569,7 @@ static int cpu_sched_rt_scheduler(void *data)
        cgroup_write_pid_fullpath(path, ps->pid);
 
        return RESOURCED_ERROR_NONE;
-}
+}*/
 
 static void register_notifiers()
 {
@@ -583,7 +584,7 @@ static void register_notifiers()
                register_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_background);
        }
 
-       register_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
+//     register_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
 
        register_notifier(RESOURCED_NOTIFIER_CPU_ON, cpu_sched_cpu_on);
        register_notifier(RESOURCED_NOTIFIER_CPU_OFF, cpu_sched_cpu_off);
@@ -605,7 +606,7 @@ static void unregister_notifiers()
                unregister_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_background);
        }
 
-       unregister_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
+//     unregister_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
 
        unregister_notifier(RESOURCED_NOTIFIER_CPU_ON, cpu_sched_cpu_on);
        unregister_notifier(RESOURCED_NOTIFIER_CPU_OFF, cpu_sched_cpu_off);
index 932d6d2..cde73aa 100644 (file)
@@ -577,20 +577,24 @@ static int compact_parse_config_file(struct compact_control *compact)
                _E("Compact configuration should not be NULL");
                return RESOURCED_ERROR_FAIL;
        }
+
        if (!compact_conf->enable) {
                (void) pthread_mutex_lock(&compact->lock);
                compact->status |= COMPACT_SKIP;
                (void) pthread_mutex_unlock(&compact->lock);
+
+               goto free_compact_conf;
        }
 
        if (compact_conf->frag_level > 0)
                compact->frag_level = compact_conf->frag_level;
 
-       free_compact_conf();
-
        _I("[COMPACTION] compact status: %d", compact->status);
        _I("[COMPACTION] compact frag_level: %d", compact->frag_level);
 
+free_compact_conf:
+       free_compact_conf();
+
        return RESOURCED_ERROR_NONE;
 }
 
index 68a34a2..4286b86 100644 (file)
@@ -112,8 +112,8 @@ enum ksm_param {
 };
 
 static int ksm_param_ranges[KSM_PARAM_MAX][2] = {
-       {0, 10000}, /* KSM_PARAM_PAGES_TO_SCAN */
-       {0, 1000}, /* KSM_PARAM_SLEEP_MSECS */
+       {0, 10000},   /* KSM_PARAM_PAGES_TO_SCAN */
+       {0, 1000},    /* KSM_PARAM_SLEEP_MSECS */
        {0, INT_MAX}, /* KSM_PARAM_FULL_SCAN_INTERVAL_MSECS */
        {100, 10000}, /* KSM_PARAM_SCAN_BOOST */
 };
@@ -458,13 +458,20 @@ static int dedup_parse_config_file(void)
        }
 
        dedup_enable = dedup_conf->enable;
-       dedup_at_boot_enable = dedup_conf->boot_dedup_enable;
-       dedup_on_lowmem = dedup_conf->scan_on_lowmem;
+       if (!dedup_enable)
+               goto free_dedup_conf;
 
        if (!strncmp(dedup_conf->ksm.mode, "oneshot", 8))
                dedup_mode = DEDUP_MODE_ONESHOT;
        else if(!strncmp(dedup_conf->ksm.mode, "periodic", 9))
                dedup_mode = DEDUP_MODE_PERIODIC;
+       else {
+               dedup_enable =  false;
+               goto free_dedup_conf;
+       }
+
+       dedup_at_boot_enable = dedup_conf->boot_dedup_enable;
+       dedup_on_lowmem = dedup_conf->scan_on_lowmem;
 
        if (dedup_conf->ksm.pages > ksm_param_ranges[KSM_PARAM_PAGES_TO_SCAN][0] &&
                dedup_conf->ksm.pages <= ksm_param_ranges[KSM_PARAM_PAGES_TO_SCAN][1])
@@ -494,6 +501,7 @@ static int dedup_parse_config_file(void)
        _I("[DEDUP] ksm full scan interval: %d ms", ksm_params[KSM_PARAM_FULL_SCAN_INTERVAL_MSECS]);
        _I("[DEDUP] ksm scan boost: %d", ksm_params[KSM_PARAM_SCAN_BOOST]);
 
+free_dedup_conf:
        free_dedup_conf();
 
        return RESOURCED_ERROR_NONE;
index 087cda7..7a053c7 100644 (file)
@@ -844,7 +844,7 @@ static int swap_parse_config_file(void)
        struct swap_module_ops *swaps;
        struct swap_conf *swap_conf = get_swap_conf();
        if (!swap_conf) {
-               _E("Swap configuration should not be NULL");
+               _E("[SWAP] Swap configuration should not be NULL");
                return RESOURCED_ERROR_FAIL;
        }
 
@@ -852,8 +852,13 @@ static int swap_parse_config_file(void)
        if (arg_swap_enable == false)
                goto free_swap_conf;
 
-       arg_swap_at_boot = swap_conf->boot_reclaim_enable;
        arg_swap_type = swap_conf->swap_type;
+       if (arg_swap_type == SWAP_TYPE_NONE) {
+               arg_swap_enable = false;
+               goto free_swap_conf;
+       }
+
+       arg_swap_at_boot = swap_conf->boot_reclaim_enable;
 
        for(int cgroup = MEMCG_VIP; cgroup < MEMCG_END; cgroup++) {
                if (swap_conf->swappiness[cgroup] >= 0 &&
@@ -868,17 +873,21 @@ static int swap_parse_config_file(void)
                if (!swaps->conf)
                        continue;
 
-               if (!strncmp(swaps->name, "ZRAM", 5))
+               if (!strncmp(swaps->name, "ZRAM", 5) && (arg_swap_type & SWAP_TYPE_ZRAM))
                        r = swaps->conf(&swap_conf->zram);
-               else if (!strncmp(swaps->name, "ZSWAP", 6))
+               else if (!strncmp(swaps->name, "ZSWAP", 6) && (arg_swap_type & SWAP_TYPE_ZSWAP))
                        r = swaps->conf(&swap_conf->zswap);
-               else if (!strncmp(swaps->name, "FILESWAP", 9))
+               else if (!strncmp(swaps->name, "FILESWAP", 9) && (arg_swap_type & SWAP_TYPE_FILE))
                        r = swaps->conf(NULL);
+
+               if (r) {
+                       _E("[SWAP] %s swap configuration init fail", swaps->name);
+               }
        }
+       print_swap_conf();
 
 free_swap_conf:
        free_swap_conf();
-       print_swap_conf();
 
        return r;
 }
index 0319400..d3248db 100644 (file)
@@ -42,7 +42,7 @@
 #include "fd-handler.h"
 #include "lowmem-handler.h"
 #include "notifier.h"
-#include "cpu-sched-common.h"
+#include "cpu-common.h"
 
 #include <dirent.h>
 #include <dlfcn.h>
@@ -256,11 +256,6 @@ int fixed_service_list_init(void *data)
                        proc_set_oom_score_adj(pid, cgroup_get_lowest_oom_score_adj(pci->mem_type), NULL);
                }
 
-               /* fixed cpu cgroup */
-/*             if (pci->cpu_type != CGROUP_TOP) {
-                       cpu_move_cgroup_foreach(pid, NULL, CPU_CGROUP_PATH(pci->cpu_type));
-               }*/
-
                memset(&attr, 0, sizeof(struct sched_attr));
                attr.size = sizeof(struct sched_attr);
                if (pci->cpu_sched_info.cpu_nice >= CPU_MIN_NICE &&
@@ -281,71 +276,72 @@ int fixed_service_list_init(void *data)
 
                switch (pci->cpu_sched_info.cpu_sched_type) {
                        case CPU_SCHED_NONE:
+                               if (attr.sched_nice == CPU_INIT_NICE)
+                                       goto skip_scheduler_update;
+
+                               /* else go through */
                        case CPU_SCHED_OTHER:
                                attr.sched_policy = SCHED_OTHER;
-                               sched_setattr(pid, &attr, 0);
-                               error = sched_getattr(pid, &attr, 0);
+/*                             error = sched_getattr(pid, &attr, 0);
                                if (error)
                                        _E("[CPU-SCHED] Failed to get sched attributes");
 
                                if (attr.sched_policy != SCHED_OTHER)
                                        _E("[CPU-SCHED] current policy (%d) is different from %d",
-                                       attr.sched_policy, SCHED_OTHER);
+                                       attr.sched_policy, SCHED_OTHER);*/
                                break;
                        case CPU_SCHED_IDLE:
                                attr.sched_policy = SCHED_IDLE;
-                               sched_setattr(pid, &attr, 0);
-                               error = sched_getattr(pid, &attr, 0);
+/*                             error = sched_getattr(pid, &attr, 0);
                                if (error)
                                        _E("[CPU-SCHED] Failed to get sched attributes");
 
                                if (attr.sched_policy != SCHED_IDLE)
                                        _E("[CPU-SCHED] current policy (%d) is different from %d",
-                                       attr.sched_policy, SCHED_IDLE);
+                                       attr.sched_policy, SCHED_IDLE);*/
                                break;
                        case CPU_SCHED_BATCH:
                                attr.sched_policy = SCHED_BATCH;
-                               sched_setattr(pid, &attr, 0);
-                               error = sched_getattr(pid, &attr, 0);
+/*                             error = sched_getattr(pid, &attr, 0);
                                if (error)
                                        _E("[CPU-SCHED] Failed to get sched attributes");
 
                                if (attr.sched_policy != SCHED_BATCH)
                                        _E("[CPU-SCHED] current policy (%d) is different from %d",
-                                       attr.sched_policy, SCHED_BATCH);
+                                       attr.sched_policy, SCHED_BATCH);*/
                                break;
                        case CPU_SCHED_FIFO:
                                attr.sched_policy = SCHED_FIFO;
-                               sched_setattr(pid, &attr, 0);
-                               error = sched_getattr(pid, &attr, 0);
+/*                             error = sched_getattr(pid, &attr, 0);
                                if (error)
                                        _E("[CPU-SCHED] Failed to get sched attributes");
 
                                if (attr.sched_policy != SCHED_FIFO)
                                        _E("[CPU-SCHED] current policy (%d) is different from %d",
-                                       attr.sched_policy, SCHED_FIFO);
+                                       attr.sched_policy, SCHED_FIFO);*/
                                break;
                        case CPU_SCHED_RR:
                                attr.sched_policy = SCHED_RR;
-                               sched_setattr(pid, &attr, 0);
-                               error = sched_getattr(pid, &attr, 0);
+/*                             error = sched_getattr(pid, &attr, 0);
                                if (error)
                                        _E("[CPU-SCHED] Failed to get sched attributes");
 
                                if (attr.sched_policy != SCHED_RR)
                                        _E("[CPU-SCHED] current policy (%d) is different from %d",
-                                       attr.sched_policy, SCHED_RR);
+                                       attr.sched_policy, SCHED_RR);*/
                                break;
                        case CPU_SCHED_DEADLINE:
                                attr.sched_policy = SCHED_DEADLINE;
-                               sched_setattr(pid, &attr, 0);
-                               error = sched_getattr(pid, &attr, 0);
+/*                             error = sched_getattr(pid, &attr, 0);
                                if (error)
-                                       _E("[CPU-SCHED] Failed to get sched attributes");
+                                       _E("[CPU-SCHED] Failed to get sched attributes");*/
                                break;
                        default:
                                _E("[CPU-SCHED] Unknown CPU sched type");
                }
+               error = sched_setattr_of_all_tasks(pid, &attr, 0);
+               if (error)
+                       _E("[CPU-SCHED] Failed to set sched attributes");
 
                _I("[CPU-SCHED] %s's (pid = %d) policy = %s", pci->name, pid, attr.sched_policy == SCHED_IDLE ? "SCHED_IDLE" :
                                          attr.sched_policy == SCHED_BATCH ? "SCHED_BATCH" :
@@ -356,6 +352,7 @@ int fixed_service_list_init(void *data)
                _I("[CPU-SCHED] %s's nice = %d", pci->name, attr.sched_nice);
                _I("[CPU-SCHED] %s's priority = %d", pci->name, attr.sched_priority);
 
+skip_scheduler_update:
                /* register a notification when this service is released */
                switch (pci->fail_action) {
                        case PROC_ACTION_REBOOT:
@@ -367,8 +364,14 @@ int fixed_service_list_init(void *data)
                                _W("[WATCHDOG] Currently we support only REBOOT when a service is released");
                }
 
-               /* register RT throttling */
-               if (pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_FIFO ||
+               /* Put a system service into throttling group */
+/*             if (pci->cpu_throttling_enable) {
+                       struct proc_status ps = {0, };
+                       ps.pid = pid;
+                       ps.pai = NULL;
+                       resourced_notify(RESOURCED_NOTIFIER_THROTTLING_SYSTEM_SERVICE, &ps);
+               }*/
+/*             if (pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_FIFO ||
                    pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_RR ||
                        pci->cpu_sched_info.cpu_sched_type == CPU_SCHED_DEADLINE) {
                        if (pci->cpu_sched_info.rt_period_us > 0 &&
@@ -380,7 +383,7 @@ int fixed_service_list_init(void *data)
                                ps.pci = pci;
                                resourced_notify(RESOURCED_NOTIFIER_RT_SCHEDULER, &ps);
                        }
-               }
+               }*/
 
                /* register a notification when this service memory is over a threshold */
                if (pci->mem_action.memory_bytes && pci->mem_action.action) {