Delete the case where error(warn) logs are called 88/276288/3 accepted/tizen/unified/20220614.134540 submit/tizen/20220614.062403
authorUnsung Lee <unsung.lee@samsung.com>
Tue, 14 Jun 2022 05:17:38 +0000 (14:17 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 14 Jun 2022 06:14:18 +0000 (15:14 +0900)
Change-Id: Iaad90b42ca761534221984b0bec7345f793c8067
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/cgroup/memory-cgroup.c
src/common/cgroup/memory-cgroup.h
src/common/config-parser.c
src/common/module.c
src/process/block/block-monitor.c
src/process/block/block.c
src/resource-limiter/freezer/freezer.c
src/resource-limiter/memory/lowmem-limit.c
src/resource-monitor/heart.c
src/resource-optimizer/memory/dedup/dedup.c
src/resource-optimizer/memory/swap/swap.c

index 9be1f3a..5ec6d1d 100644 (file)
@@ -72,6 +72,23 @@ static struct memcg_info gmemcg_info[MEMCG_END] = {
        {MEMCG_THROTTLING_PATH,},
 };
 
+/* Check whether memsw exists or not */
+bool memcg_memsw_is_supported(void)
+{
+       static bool is_cached = false;
+       static bool is_supported = false;
+
+       if (is_cached)
+               return is_supported;
+
+       if (access(MEMCG_PATH "/" MEMCG_SWAP_USAGE, F_OK) == 0)
+               is_supported = true;
+
+       is_cached = true;
+
+       return is_supported;
+}
+
 int cgroup_get_type(int oom_score_adj)
 {
        if (oom_score_adj >= OOMADJ_BACKGRD_UNLOCKED + OOMADJ_APP_INCREASE &&
@@ -302,10 +319,12 @@ static void set_limit_in_bytes(const char *dir, unsigned long long limit_bytes)
 
        if (prev_bytes > limit_bytes) {
                cgroup_write_node_ulonglong(dir, MEMCG_LIMIT_BYTE, limit_bytes);
-               cgroup_write_node_ulonglong(dir, MEMCG_SWAP_LIMIT_BYTE, limit_bytes);
+               if (memcg_memsw_is_supported())
+                       cgroup_write_node_ulonglong(dir, MEMCG_SWAP_LIMIT_BYTE, limit_bytes);
        }
        else {
-               cgroup_write_node_ulonglong(dir, MEMCG_SWAP_LIMIT_BYTE, limit_bytes);
+               if (memcg_memsw_is_supported())
+                       cgroup_write_node_ulonglong(dir, MEMCG_SWAP_LIMIT_BYTE, limit_bytes);
                cgroup_write_node_ulonglong(dir, MEMCG_LIMIT_BYTE, limit_bytes);
        }
 }
index eb4275d..295449e 100644 (file)
@@ -195,6 +195,8 @@ struct cgroup_memory_stat {
        long long value[CGROUP_MEMORY_STAT_MAX];
 };
 
+bool memcg_memsw_is_supported(void);
+
 void register_totalram_bytes(unsigned long long ram_bytes);
 int set_mem_action_conf(struct mem_action *mem_action, const char *value);
 int set_memcg_conf_threshold(bool percent, char size, int lvl, const char *value);
index 3e8f162..1894931 100644 (file)
@@ -743,7 +743,7 @@ static void load_per_vendor_configs(const char *dir, int func(struct parse_resul
        struct dirent **namelist;
 
        if ((count = scandir(dir, &namelist, NULL, alphasort)) == -1) {
-               _W("failed to opendir (%s)", dir);
+               _I("(%s) conf dir does not exist", dir);
                return;
        }
 
index 1ac2a68..32f32f8 100644 (file)
@@ -76,7 +76,7 @@ void modules_check_runtime_support(void UNUSED *data)
 
                ret = module->check_runtime_support((void *)module);
                if (ret != RESOURCED_ERROR_NONE) {
-                       _E("%s module check failed", module->name);
+                       _I("%s module is not supported in this environment", module->name);
                        remove_module(module);
                        continue;
                }
@@ -107,7 +107,7 @@ static void module_initcall_level(void *data, int priority)
                /* Module disabled on runtime or just failed to start. */
                if (ret < 0) {
                        module->initalized = MODULE_DROPPED;
-                       _E("Fail to initialize [%s] module, dropped.", module->name);
+                       _I("Fail to initialize [%s] module, dropped.", module->name);
                        continue;
                }
 
index 44a86b1..ec84551 100644 (file)
@@ -261,9 +261,10 @@ int register_fanotify(struct block_monitor_info *bmi)
        bmi->mfd = fanotify_init(FAN_CLOEXEC|FAN_NONBLOCK | FAN_CLASS_CONTENT,
                            O_RDONLY | O_LARGEFILE | O_CLOEXEC | O_NOATIME);
        if (bmi->mfd < 0) {
-               _E("Failed to create fanotify fd");
+               _I("Fanotify fd creation is not supported");
                goto error;
        }
+
        if (!check_mount_dest(bmi->path)) {
                ret = mount(bmi->path, bmi->path, 0, MS_BIND, 0);
                if (ret) {
index c5dae3c..858f2a2 100644 (file)
@@ -154,7 +154,7 @@ static int block_prelaunch_state(void *data)
 
                g_hash_table_insert(bmi->block_include_proc, g_strndup(pai->ai->pkgname, strlen(pai->ai->pkgname)),
                            GINT_TO_POINTER(1));
-               _E("insert data %s, table num : %d", pai->ai->pkgname, g_hash_table_size(bmi->block_include_proc));
+               _I("insert data %s, table num : %d", pai->ai->pkgname, g_hash_table_size(bmi->block_include_proc));
        }
        return RESOURCED_ERROR_NONE;
 }
index c40d86e..fc1de23 100644 (file)
@@ -336,7 +336,7 @@ static bool freezer_is_present(void)
 
        /* Check if libfreezer.so is present or not */
        if (stat(FREEZER_MODULE_PATH, &buf)) {
-               _E("Freezer library is not present @ %s", FREEZER_MODULE_PATH);
+               _I("Freezer library is not present @ %s", FREEZER_MODULE_PATH);
                return false;
        }
 
@@ -422,7 +422,7 @@ static int resourced_freezer_init(void *data)
 
        is_present = freezer_is_present();
        if (!is_present) {
-               _E("Freezer library not present. Not enabling freezer");
+               _I("Freezer library not present. Not enabling freezer");
                return RESOURCED_ERROR_FAIL;
        }
        ret_code = freezer_load_symbols();
index cdf03ec..7b14731 100644 (file)
@@ -199,13 +199,14 @@ static bool memory_action_cb(int fd, void *data)
                goto remove_mle;
        }
 
-       result = cgroup_read_node_ulonglong(cg_dir, MEMCG_SWAP_USAGE, &usage_bytes);
-       if (result < 0) {
+       if (memcg_memsw_is_supported())
+               result = cgroup_read_node_ulonglong(cg_dir, MEMCG_SWAP_USAGE, &usage_bytes);
+       else
                result = cgroup_read_node_ulonglong(cg_dir, MEMCG_USAGE, &usage_bytes);
-               if (result < 0) {
-                       _D("[MEMORY-LIMIT] there is no (%s) cgroup any longer, removed it", cg_dir);
-                       goto remove_mle;
-               }
+
+       if (result < 0) {
+               _D("[MEMORY-LIMIT] there is no (%s) cgroup any longer, removed it", cg_dir);
+               goto remove_mle;
        }
 
        if (usage_bytes < mle->threshold_bytes) {
@@ -616,11 +617,7 @@ void lowmem_action_init(int service_action, int widget_action,
 
 void lowmem_limit_init(void)
 {
-       int result;
-       unsigned long long usage_bytes;
-
-       result = cgroup_read_node_ulonglong(MEMCG_PATH, MEMCG_SWAP_USAGE, &usage_bytes);
-       if (result == RESOURCED_ERROR_NONE)
+       if (memcg_memsw_is_supported())
                registerpath = MEMCG_SWAP_USAGE;
        else
                registerpath = MEMCG_USAGE;
index 99217f7..c0a64b3 100644 (file)
@@ -126,7 +126,7 @@ static int resourced_heart_init(void *data)
        config_parse(HEART_CONF_FILE_PATH, heart_load_config, &module_num);
 
        if (!module_num) {
-               _E("all heart modules have been disabled");
+               _I("all heart modules have been disabled");
                return RESOURCED_ERROR_NONE;
        }
 
index 4286b86..fba82c5 100644 (file)
@@ -547,11 +547,11 @@ static int resourced_dedup_check_runtime_support(void *data)
         * Check whether CONFIG_LKSM is enabled in kernel.
         */
        if (access("/sys/kernel/mm/ksm/run", R_OK) != 0) {
-               _W("the kernel don't support KSM, please check kernel configuration");
+               _I("the kernel doesn't support KSM, please check kernel configuration");
                return -ENOENT;
        }
        if (access("/sys/kernel/mm/ksm/one_shot_scanning", R_OK) != 0) {
-               _W("the kernel support KSM but not LKSM, please check kernel configuration");
+               _I("the kernel support KSM but not LKSM, please check kernel configuration");
                return -ENOENT;
        }
 
index 8087c12..7486b1d 100644 (file)
@@ -240,7 +240,8 @@ static int swap_use_hard_limit(char *memcg)
                ret = check_oom_and_set_limit(memcg, memcg_limit_bytes);
        else {
                /* If the group is empty don't set the limit to enable adding processes. */
-               ret = cgroup_write_node_int32(memcg, MEMCG_SWAP_LIMIT_BYTE, -1);
+               if (memcg_memsw_is_supported())
+                       ret = cgroup_write_node_int32(memcg, MEMCG_SWAP_LIMIT_BYTE, -1);
                ret = cgroup_write_node_int32(memcg, MEMCG_LIMIT_BYTE, -1);
        }
 
@@ -530,28 +531,35 @@ static void swap_early_reclaim_memcg(void)
                int try = arg_swap_at_boot_maxtry;
                unsigned long long usage_bytes, prev_usage_bytes = 0;
 
-               r = cgroup_read_node_ulonglong(MEMCG_PATH,
-                               MEMCG_SWAP_USAGE, &prev_usage_bytes);
-               if (r) {
+
+               if (memcg_memsw_is_supported()) {
+                       r = cgroup_read_node_ulonglong(MEMCG_PATH,
+                                       MEMCG_SWAP_USAGE, &prev_usage_bytes);
+               }
+               else {
                        r = cgroup_read_node_ulonglong(MEMCG_PATH,
                                        MEMCG_USAGE, &prev_usage_bytes);
-                       if (r)
-                               prev_usage_bytes = ULONG_MAX;
                }
 
+               if (r)
+                       prev_usage_bytes = ULONG_MAX;
+
                for (;;) {
                        try--;
                        swap_start_reclaim(MEMCG_PATH);
 
-                       r = cgroup_read_node_ulonglong(MEMCG_PATH,
-                                       MEMCG_SWAP_USAGE, &usage_bytes);
-                       if (r) {
+                       if (memcg_memsw_is_supported()) {
+                               r = cgroup_read_node_ulonglong(MEMCG_PATH,
+                                               MEMCG_SWAP_USAGE, &usage_bytes);
+                       }
+                       else {
                                r = cgroup_read_node_ulonglong(MEMCG_PATH,
                                                MEMCG_USAGE, &usage_bytes);
-                               if (r) {
-                                       _E("[SWAP] Early reclaim is aborted");
-                                       break;
-                               }
+                       }
+
+                       if (r) {
+                               _E("[SWAP] Early reclaim is aborted");
+                               break;
                        }
 
                        /*
@@ -808,7 +816,8 @@ static int swap_cgroup_reset_limit(void *data)
                return RESOURCED_ERROR_NONE;
 
        if (mi->limit_ratio == MEMCG_NO_LIMIT) {
-               ret = cgroup_write_node_int32(mi->name, MEMCG_SWAP_LIMIT_BYTE, -1);
+               if (memcg_memsw_is_supported())
+                       ret = cgroup_write_node_int32(mi->name, MEMCG_SWAP_LIMIT_BYTE, -1);
                ret = cgroup_write_node_int32(mi->name, MEMCG_LIMIT_BYTE, -1);
        }
        else
@@ -1003,7 +1012,6 @@ static int swap_check_node(char *path)
 
        fp = fopen(path, "w");
        if (fp == NULL) {
-               _E("[SWAP] %s open failed", path);
                return RESOURCED_ERROR_NO_DATA;
        }
        return RESOURCED_ERROR_NONE;