/* 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;
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" };
{
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;
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;
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();
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)
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;
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) {
_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);
}
{
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;
} 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
} 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);
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]);
_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)
/*
* 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;