Fix bugs of "Modify configurations" 77/270877/4
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 10 Feb 2022 10:44:46 +0000 (19:44 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Fri, 11 Feb 2022 04:42:54 +0000 (13:42 +0900)
merge get_total_memory() and setup_memcg_params()
free vip_apps after printing logs

Change-Id: I8a63dfe4a84cd0a8eb050daff26e725016101795
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/resource-limiter/memory/vmpressure-lowmem-handler.c

index 8dd0ef7..14488f7 100644 (file)
@@ -1793,7 +1793,10 @@ static int set_memory_config(struct parse_result *result, void *user_data)
 /* setup memcg parameters depending on total ram size. */
 static void setup_memcg_params(void)
 {
-       unsigned long long total_ramsize = BYTE_TO_MBYTE(totalram);
+       unsigned long long total_ramsize;
+
+       get_total_memory();
+       total_ramsize = BYTE_TO_MBYTE(totalram);
 
        _D("Total: %llu MB", total_ramsize);
        if (total_ramsize <= MEM_SIZE_64) {
@@ -2478,6 +2481,9 @@ static void print_mem_configs(void)
        _I("[DEBUG] prefix of memlimit memps is %s", memlog_prefix[MEMLOG_MEMPS_MEMLIMIT]);
 
        /* print info of VIP_PROCESS section */
+       if (!vip_apps)
+               return;
+
        _I("[DEBUG] vip app list is");
        for (int vip_index = 0; vip_index < vip_apps->len; vip_index++) {
                char *vip_name = g_ptr_array_index(vip_apps, vip_index);
@@ -2496,9 +2502,8 @@ static int lowmem_init(void)
        ret = cgroup_make_full_subdir(MEMCG_PATH);
        ret_value_msg_if(ret < 0, ret, "memory cgroup init failed\n");
        memcg_params_init();
-       setup_memcg_params();
 
-       get_total_memory();
+       setup_memcg_params();
 
        /* allocate vip list memory */
        if (allocate_vip_app_list() != RESOURCED_ERROR_NONE)
@@ -2508,27 +2513,27 @@ static int lowmem_init(void)
        load_configs(MEM_CONF_FILE);
        /* parse /etc/resourced/limiter.conf.d/xxx configurations*/
        load_per_vendor_configs();
-       print_mem_configs();
 
        /* vip_list is only needed at the set_vip_list */
        if (set_vip_list() != RESOURCED_ERROR_NONE)
                _E("set_vip_list FAIL");
-       free_vip_app_list();
 
        /* this function should be called after parsing configurations */
        memcg_write_params();
+       print_mem_configs();
+       free_vip_app_list();
 
        /* make a worker thread called low memory killer */
        ret = lowmem_activate_worker();
        if (ret) {
-               _E("oom thread create failed\n");
+               _E("[DEBUG] oom thread create failed\n");
                return ret;
        }
 
        /* register threshold and event fd */
        ret = lowmem_press_setup_eventfd();
        if (ret) {
-               _E("eventfd setup failed");
+               _E("[DEBUG] eventfd setup failed");
                return ret;
        }