memory : remove dynamic oom threshold 48/126848/6
authorKichan Kwon <k_c.kwon@samsung.com>
Tue, 25 Apr 2017 06:51:50 +0000 (15:51 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Fri, 19 May 2017 01:38:22 +0000 (10:38 +0900)
- It is introduced to prevent killing foreground app frequently
- But now, it isn't handled; this value is always fixed.
- What's more, resourced has been improved that it doesn't kill
 foreground app frequently

Change-Id: I8d1affb409030cb1a1d4f07ac2a8abceb32dc123
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/memory/memory.conf
src/memory/vmpressure-lowmem-handler.c

index 62143a1..285bd79 100644 (file)
@@ -58,9 +58,6 @@ ProactiveThreshold=80         # MB
 # Leave Threshold for proactive memory killer
 ProactiveLeave=100             # MB
 
-# Threshold for dynamic memory killer
-DynamicThreshold=30            # MB
-
 # Number of max victims
 NumMaxVictims=5
 
@@ -83,9 +80,6 @@ ProactiveThreshold=80         # MB
 # Leave Threshold for proactive memory killer
 ProactiveLeave=100             # MB
 
-# Threshold for dynamic memory killer
-DynamicThreshold=30            # MB
-
 # Number of max victims
 NumMaxVictims=5
 
@@ -108,9 +102,6 @@ ProactiveThreshold=100              # MB
 # Leave Threshold for proactive memory killer
 ProactiveLeave=130             # MB
 
-# Threshold for dynamic memory killer
-DynamicThreshold=40            # MB
-
 # Number of max victims
 NumMaxVictims=5
 
@@ -133,9 +124,6 @@ ProactiveThreshold=150              # MB
 # Leave Threshold for proactive memory killer
 ProactiveLeave=230             # MB
 
-# Threshold for dynamic memory killer
-DynamicThreshold=50            # MB
-
 # Number of max victims
 NumMaxVictims=5
 
index 3c75f84..c19f9a4 100644 (file)
@@ -96,7 +96,6 @@
 /* thresholds for 64M RAM*/
 #define PROACTIVE_64_THRES                     10 /* MB */
 #define PROACTIVE_64_LEAVE                     30 /* MB */
-#define DYNAMIC_64_THRES                       5 /* MB */
 #define MEMCG_MEMORY_64_THRES_SWAP             15 /* MB */
 #define MEMCG_MEMORY_64_THRES_LOW              8  /* MB */
 #define MEMCG_MEMORY_64_THRES_MEDIUM           5  /* MB */
 /* thresholds for 256M RAM */
 #define PROACTIVE_256_THRES                    50 /* MB */
 #define PROACTIVE_256_LEAVE                    80 /* MB */
-#define DYNAMIC_256_THRES                      10 /* MB */
 #define MEMCG_MEMORY_256_THRES_SWAP            40 /* MB */
 #define MEMCG_MEMORY_256_THRES_LOW             20 /* MB */
 #define MEMCG_MEMORY_256_THRES_MEDIUM          10 /* MB */
 /* threshold for 448M RAM */
 #define PROACTIVE_448_THRES                    80 /* MB */
 #define PROACTIVE_448_LEAVE                    100 /* MB */
-#define DYNAMIC_448_THRES                      40 /* MB */
 #define MEMCG_MEMORY_448_THRES_SWAP            100 /* MB */
 #define MEMCG_MEMORY_448_THRES_LOW             50  /* MB */
 #define MEMCG_MEMORY_448_THRES_MEDIUM          40  /* MB */
 /* threshold for 512M RAM */
 #define PROACTIVE_512_THRES                    80 /* MB */
 #define PROACTIVE_512_LEAVE                    100 /* MB */
-#define DYNAMIC_512_THRES                      40 /* MB */
 #define MEMCG_MEMORY_512_THRES_SWAP            100 /* MB */
 #define MEMCG_MEMORY_512_THRES_LOW             50  /* MB */
 #define MEMCG_MEMORY_512_THRES_MEDIUM          40  /* MB */
 /* threshold for 768 RAM */
 #define PROACTIVE_768_THRES                    100 /* MB */
 #define PROACTIVE_768_LEAVE                    120 /* MB */
-#define DYNAMIC_768_THRES                      50 /* MB */
 #define MEMCG_MEMORY_768_THRES_SWAP            150 /* MB */
 #define MEMCG_MEMORY_768_THRES_LOW             100  /* MB */
 #define MEMCG_MEMORY_768_THRES_MEDIUM          60  /* MB */
 /* threshold for more than 1024M RAM */
 #define PROACTIVE_1024_THRES                   150 /* MB */
 #define PROACTIVE_1024_LEAVE                   300 /* MB */
-#define DYNAMIC_1024_THRES                     100 /* MB */
 #define MEMCG_MEMORY_1024_THRES_SWAP           300 /* MB */
 #define MEMCG_MEMORY_1024_THRES_LOW            200 /* MB */
 #define MEMCG_MEMORY_1024_THRES_MEDIUM         100 /* MB */
 /* threshold for more than 2048M RAM */
 #define PROACTIVE_2048_THRES                   200 /* MB */
 #define PROACTIVE_2048_LEAVE                   500 /* MB */
-#define DYNAMIC_2048_THRES                     160 /* MB */
 #define MEMCG_MEMORY_2048_THRES_SWAP           300 /* MB */
 #define MEMCG_MEMORY_2048_THRES_LOW            200 /* MB */
 #define MEMCG_MEMORY_2048_THRES_MEDIUM         160 /* MB */
 
 static unsigned proactive_threshold;
 static unsigned proactive_leave;
-static unsigned dynamic_threshold_min;
-static unsigned dynamic_threshold_adj_gap;
-static unsigned dynamic_oom_threshold;
+static unsigned lmk_start_threshold;
 
 static char *event_level = MEMCG_DEFAULT_EVENT_LEVEL;
 
@@ -322,47 +313,6 @@ static const char *convert_memstate_to_str(int mem_state)
        return "";
 }
 
-static void adjust_dynamic_threshold(enum lmk_type lmk_type)
-{
-       unsigned prev_dynamic_threshold = dynamic_oom_threshold;
-       unsigned available;
-
-       switch (cur_mem_state) {
-       case LOWMEM_NORMAL:
-               available = proc_get_mem_available();
-               if (available > memcg_root->threshold[LOWMEM_MEDIUM])
-                       dynamic_oom_threshold = memcg_root->threshold[LOWMEM_MEDIUM];
-               break;
-       case LOWMEM_SWAP:
-       case LOWMEM_LOW:
-               if (lmk_type < LMK_INACTIVE) {
-                       dynamic_oom_threshold -= dynamic_threshold_adj_gap;
-                       break;
-               }
-
-               dynamic_oom_threshold += dynamic_threshold_adj_gap;
-
-               if (dynamic_oom_threshold >=
-                   memcg_root->threshold[LOWMEM_MEDIUM])
-                       dynamic_oom_threshold = memcg_root->threshold[LOWMEM_MEDIUM];
-               break;
-       case LOWMEM_MEDIUM:
-               if (lmk_type < LMK_INACTIVE)
-                       dynamic_oom_threshold -= dynamic_threshold_adj_gap;
-
-               if (dynamic_oom_threshold < dynamic_threshold_min)
-                       dynamic_oom_threshold = dynamic_threshold_min;
-               break;
-       default:
-               break;
-       }
-
-       _I("dynamic_threshold is changed from %u to %u, cur_mem_state = %s, lmk_type = %d",
-               prev_dynamic_threshold, dynamic_oom_threshold,
-               convert_memstate_to_str(cur_mem_state),
-               lmk_type);
-}
-
 static int lowmem_launch_oompopup(void)
 {
        char *args[2] = { "_SYSPOPUP_CONTENT_", "lowmemory_oom" };
@@ -577,10 +527,6 @@ static int lowmem_check_kill_continued(struct task_info *tsk, int flags)
 {
        unsigned int available;
 
-       /*
-        * Processes with the priority higher than perceptible are killed
-        * only when the available memory is less than dynamic oom threshold.
-        */
        if (tsk->oom_score_adj > OOMADJ_BACKGRD_PERCEPTIBLE)
                return LOWMEM_RECLAIM_CONT;
 
@@ -590,9 +536,9 @@ static int lowmem_check_kill_continued(struct task_info *tsk, int flags)
                return LOWMEM_RECLAIM_DROP;
        }
        available = proc_get_mem_available();
-       if (available > dynamic_oom_threshold) {
+       if (available > lmk_start_threshold) {
                _I("available: %d MB, larger than %u MB, do not kill foreground",
-                       available, dynamic_oom_threshold);
+                       available, lmk_start_threshold);
                return LOWMEM_RECLAIM_WAIT;
        }
        return LOWMEM_RECLAIM_CONT;
@@ -650,11 +596,6 @@ static void lowmem_free_task_info_array(GArray *array)
        g_array_free(array, true);
 }
 
-static inline int is_dynamic_process_killer(int flags)
-{
-       return (flags & OOM_FORCE) && !(flags & OOM_NOMEMORY_CHECK);
-}
-
 static unsigned int is_memory_recovered(unsigned int *avail, unsigned int *thres)
 {
        unsigned int available = proc_get_mem_available();
@@ -772,7 +713,7 @@ static int lowmem_kill_victims_from_proc(int flags, int *completed, int threshol
 
                tsk = &g_array_index(candidates, struct task_info, i);
 
-               if (available  + total_size > dynamic_oom_threshold)
+               if (available  + total_size > lmk_start_threshold)
                        break;
                ret = lowmem_kill_victim(tsk, flags, &victim_size);
                if (ret != RESOURCED_ERROR_NONE)
@@ -781,7 +722,7 @@ static int lowmem_kill_victims_from_proc(int flags, int *completed, int threshol
                total_size += KBYTE_TO_MBYTE(victim_size);
        }
 
-       if (available + total_size  > dynamic_oom_threshold) {
+       if (available + total_size  > lmk_start_threshold) {
                _I("Reached the threshold margin: available mem: %d MB\n",
                        available);
                *completed = LOWMEM_RECLAIM_DONE;
@@ -970,7 +911,7 @@ static void lowmem_handle_request(struct lowmem_control *ctl)
 retry:
        /* Prepare LMK to start doing it's job. Check preconditions. */
        calualate_range_of_oom(lmk_type, &start_oom, &end_oom);
-       adjust_dynamic_threshold(lmk_type);
+       lmk_start_threshold = memcg_root->threshold[LOWMEM_MEDIUM];
        shortfall = is_memory_recovered(&available, &leave_threshold);
 
        if (!shortfall || !reclaim_size) {
@@ -1110,8 +1051,8 @@ static void change_lowmem_state(unsigned int mem_state)
        _I("[LOW MEM STATE] %s ==> %s", convert_memstate_to_str(cur_mem_state),
                convert_memstate_to_str(mem_state));
        cur_mem_state = mem_state;
+       lmk_start_threshold = memcg_root->threshold[LOWMEM_MEDIUM];
 
-       adjust_dynamic_threshold(LMK_INACTIVE);
        resourced_notify(RESOURCED_NOTIFIER_MEM_STATE_CHANGED,
                (void *)cur_mem_state);
 }
@@ -1357,12 +1298,10 @@ static unsigned int check_mem_state(unsigned int available)
 {
        int mem_state;
        for (mem_state = LOWMEM_MAX_LEVEL - 1; mem_state > LOWMEM_NORMAL; mem_state--) {
-               if (mem_state != LOWMEM_MEDIUM &&
-                   available <= memcg_root->threshold[mem_state])
-                               break;
-               else if (mem_state == LOWMEM_MEDIUM &&
-                   available <= dynamic_oom_threshold)
-                               break;
+               if (mem_state != LOWMEM_MEDIUM && available <= memcg_root->threshold[mem_state])
+                       break;
+               else if (mem_state == LOWMEM_MEDIUM && available <= lmk_start_threshold)
+                       break;
        }
 
        return mem_state;
@@ -1445,9 +1384,6 @@ static int set_memory_config(const char *section_name, const struct parse_result
        } else if (!strncmp(result->name, "ProactiveLeave", strlen("ProactiveLeave")+1)) {
                int value = atoi(result->value);
                proactive_leave = value;
-       } else if (!strncmp(result->name, "DynamicThreshold", strlen("DynamicThreshold")+1)) {
-               int value = atoi(result->value);
-               dynamic_threshold_min = value;
        } else if (!strncmp(result->name, "EventLevel", strlen("EventLevel")+1)) {
                if (strncmp(event_level, result->value, strlen(event_level)))
                        event_level = strdup(result->value);
@@ -1503,7 +1439,6 @@ static void setup_memcg_params(void)
                /* set thresholds for ram size 64M */
                proactive_threshold = PROACTIVE_64_THRES;
                proactive_leave = PROACTIVE_64_LEAVE;
-               dynamic_threshold_min = DYNAMIC_64_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_64_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_64_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_64_THRES_MEDIUM);
@@ -1513,7 +1448,6 @@ static void setup_memcg_params(void)
                /* set thresholds for ram size 256M */
                proactive_threshold = PROACTIVE_256_THRES;
                proactive_leave = PROACTIVE_256_LEAVE;
-               dynamic_threshold_min = DYNAMIC_256_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_256_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_256_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_256_THRES_MEDIUM);
@@ -1523,7 +1457,6 @@ static void setup_memcg_params(void)
                /* set thresholds for ram size 448M */
                proactive_threshold = PROACTIVE_448_THRES;
                proactive_leave = PROACTIVE_448_LEAVE;
-               dynamic_threshold_min = DYNAMIC_448_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_448_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_448_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_448_THRES_MEDIUM);
@@ -1533,7 +1466,6 @@ static void setup_memcg_params(void)
                /* set thresholds for ram size 512M */
                proactive_threshold = PROACTIVE_512_THRES;
                proactive_leave = PROACTIVE_512_LEAVE;
-               dynamic_threshold_min = DYNAMIC_512_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_512_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_512_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_512_THRES_MEDIUM);
@@ -1543,7 +1475,6 @@ static void setup_memcg_params(void)
                /* set thresholds for ram size 512M */
                proactive_threshold = PROACTIVE_768_THRES;
                proactive_leave = PROACTIVE_768_LEAVE;
-               dynamic_threshold_min = DYNAMIC_768_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_768_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_768_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_768_THRES_MEDIUM);
@@ -1553,7 +1484,6 @@ static void setup_memcg_params(void)
                /* set thresholds for ram size more than 1G */
                proactive_threshold = PROACTIVE_1024_THRES;
                proactive_leave = PROACTIVE_1024_LEAVE;
-               dynamic_threshold_min = DYNAMIC_1024_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_1024_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_1024_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_1024_THRES_MEDIUM);
@@ -1562,7 +1492,6 @@ static void setup_memcg_params(void)
        } else {
                proactive_threshold = PROACTIVE_2048_THRES;
                proactive_leave = PROACTIVE_2048_LEAVE;
-               dynamic_threshold_min = DYNAMIC_2048_THRES;
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, MEMCG_MEMORY_2048_THRES_SWAP);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, MEMCG_MEMORY_2048_THRES_LOW);
                lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, MEMCG_MEMORY_2048_THRES_MEDIUM);
@@ -1570,12 +1499,6 @@ static void setup_memcg_params(void)
                config_parse(MEM_CONF_FILE, memory_load_2048_config, NULL);
        }
 
-       if (memcg_root->threshold[LOWMEM_MEDIUM] - dynamic_threshold_min > 0)
-               dynamic_threshold_adj_gap =
-                       (memcg_root->threshold[LOWMEM_MEDIUM] -
-                       dynamic_threshold_min) >> 2;
-       dynamic_oom_threshold = memcg_root->threshold[LOWMEM_MEDIUM];
-
        for (i = 0; i < LOWMEM_MAX_LEVEL; i++)
                _I("set threshold for state '%s' to %u MB", convert_memstate_to_str(i), memcg_root->threshold[i]);
 
@@ -1583,10 +1506,6 @@ static void setup_memcg_params(void)
        _I("set threshold leave to %u MB", memcg_root->threshold_leave);
        _I("set proactive threshold to %u MB", proactive_threshold);
        _I("set proactive low memory killer leave to %u MB", proactive_leave);
-       _I("set dynamic_oom_threshold = %u MB, dynamic_threshold_gap = %u MB,"
-               " dynamic threshold min to %u MB",
-               dynamic_oom_threshold, dynamic_threshold_adj_gap,
-               dynamic_threshold_min);
 }
 
 static void init_memcg_params(void)
@@ -1975,14 +1894,14 @@ static void lowmem_proactive_oom_killer(int flags, char *appid)
 
        /*
         * When there is no history data for the launching app but it is
-        * indicated as PROC_LARGEMEMORY, run oom killer based on dynamic
+        * indicated as PROC_LARGEMEMORY, run oom killer based on proactive
         * threshold.
         */
        if (!(flags & PROC_LARGEMEMORY))
                return;
        /*
         * run proactive oom killer only when available is larger than
-        * dynamic process threshold
+        * proactive threshold
         */
        if (!proactive_threshold || before >= proactive_threshold)
                return;