Config file consists of two parts: section names and key-value pairs.
Section name should be located between '[' and ']'. (ex: [MemoryLevelThreshold])
The range of a section is: From the first appearance of section name to the EOF or the line before the next section starts
-Example: [MemoryThrottling]
- ThrottlingLimit=80%
+Example: [MemoryBackgroundLru]
+ BackgroundLruLimit=80%
Lines beginning with '#' are ignored.
Value Format
1. limiter.conf
===============
-1.1 Section: MemoryThrottling
+1.1 Section: MemoryBackgroundLru
=============================
-Key: ThrottlingLimit
+Key: BackgroundLruLimit
Value: <limit ratio in percentage>%
-Comment: Specify the throttling limit ratio in percentage.
-Example: ThrottlingLimit=80%
+Comment: Specify the memory cgroup BackgroundLru limit ratio in percentage.
+Example: BackgroundLruLimit=80%
1.2 Section: MemoryLevelThreshold
=================================
or
SwapType=zram+file
-Key: ThrottlingSwappiness=80
+Key: BackgroundLruSwappiness=80
Value: <swappiness>
Comment: Specify memory swappiness value.
<swappiness> is an decimal integer value.
(But 0 does not mean no swapping)
If <swappiness> > 60, the tendency of the kernel of swapping process memory will be increased.
If <swappiness> > 100, then the kernel can swap out a part of the pages in the address space in this cgroup.
-Example: ThrottlingSwappiness=80
+Example: BackgroundLruSwappiness=80
2.2 Section: MemoryZram
=======================
<action> can be: broadcast, reclaim, kill, ignore
Example: MemLimitAction=4096KB,kill
-Key: MemoryThrottling
+Key: MemoryBackgroundLru
Value: (yes|1|ok|on|no|0|off)
-Comment: Specify whether the memory throttling is enabled.
- If (yes|1|ok|on), enable memory throttling.
- If (no|0|off), disable memory throttling.
-Example: MemoryThrottling=yes
+Comment: Specify whether put the process or service in BackgroundLru memory cgroup.
+ If (yes|1|ok|on), put the process or service in BackgroundLru.
+ If (no|0|off), do not put the process or service in BackgroundLru.
+Example: MemoryBackgroundLru=yes
Key: CpuThrottling
Value: (yes|1|ok|on|no|0|off)
[MemoryAppStatusLimit]
#BackgroundPerAppLimitAction=768MB,kill
-[MemoryThrottling]
-ThrottlingLimit= 80%
+[MemoryBackgroundLru]
+BackgroundLruLimit= 80%
[MemoryLMKGovernor]
ForegroundAppListPostGovernor=no
[MemorySwap]
ReclaimAtBoot=yes
SwapType=zram
-ThrottlingSwappiness=80
+BackgroundLruSwappiness=80
[MemoryZram]
CompAlgorithm=zstd
**/
static struct cgroup cgroup_tree[MEMCG_END] = {
{"/", MEMCG_TOP, CGROUP_DEFAULT_USE_HIERARCHY, NULL},
- {MEMCG_THROTTLING_NAME, MEMCG_ROOT, CGROUP_DEFAULT_USE_HIERARCHY, NULL},
+ {MEMCG_BACKGROUND_LRU_NAME, MEMCG_ROOT, CGROUP_DEFAULT_USE_HIERARCHY, NULL},
};
static struct memcg_info gmemcg_info[MEMCG_END] = {
{MEMCG_PATH,},
- {MEMCG_THROTTLING_PATH,},
+ {MEMCG_BACKGROUND_LRU_PATH,},
};
/* Check whether memsw exists or not */
int memcg_get_lowest_oom_score_adj(enum cgroup_type cgroup_type, int *oom_score_adj)
{
switch (cgroup_type) {
- case MEMCG_THROTTLING:
+ case MEMCG_BACKGROUND_LRU:
*oom_score_adj = OOMADJ_BACKGRD_UNLOCKED + OOMADJ_APP_INCREASE;
break;
case MEMCG_ROOT:
{
if (oom_score_adj >= OOMADJ_BACKGRD_UNLOCKED + OOMADJ_APP_INCREASE &&
oom_score_adj <= OOMADJ_APP_MAX)
- return MEMCG_THROTTLING;
+ return MEMCG_BACKGROUND_LRU;
else
return MEMCG_ROOT;
}
unsigned int i;
unsigned long long lower_group_limit_bytes = 0;
- for (i = MEMCG_THROTTLING; i > MEMCG_ROOT; i--) {
+ for (i = MEMCG_BACKGROUND_LRU; i > MEMCG_ROOT; i--) {
struct memcg_info *mi = get_memcg_info(i);
if (mi->limit_bytes < lower_group_limit_bytes)
{
unsigned int i;
- for (i = MEMCG_THROTTLING; i < MEMCG_END; i++) {
+ for (i = MEMCG_BACKGROUND_LRU; i < MEMCG_END; i++) {
struct memcg_info *mi = get_memcg_info(i);
memcg_write_optimizer_info(mi);
}
{
int result;
- result = cgroup_make_subdir(parentdir, MEMCG_MAKE_NAME(THROTTLING), NULL);
+ result = cgroup_make_subdir(parentdir, MEMCG_MAKE_NAME(BACKGROUND_LRU), NULL);
ret_value_msg_if(result < 0, result, "%s/%s init failed\n",
- parentdir, MEMCG_MAKE_NAME(THROTTLING));
+ parentdir, MEMCG_MAKE_NAME(BACKGROUND_LRU));
result = cgroup_make_subdir(parentdir, MEMCG_MAKE_NAME(PRIVATE), NULL);
ret_value_msg_if(result < 0, result, "%s/%s init failed\n",
parentdir, MEMCG_MAKE_NAME(PRIVATE));
/* number of memory cgroups */
#define MEMCG_DEFAULT_EVENT_LEVEL "low"
-#define MEMCG_THROTTLING_NAME "Throttling"
+#define MEMCG_BACKGROUND_LRU_NAME "BackgroundLru"
#define MEMCG_PRIVATE_NAME "Private"
#define MEMCG_NAME "memory"
#define MEMCG_PATH CGROUP_PATH "/" MEMCG_NAME
-#define MEMCG_THROTTLING_PATH MEMCG_PATH "/" MEMCG_THROTTLING_NAME
+#define MEMCG_BACKGROUND_LRU_PATH MEMCG_PATH "/" MEMCG_BACKGROUND_LRU_NAME
#define MEMCG_PRIVATE_PATH MEMCG_PATH "/" MEMCG_PRIVATE_NAME
#define MEMCG_OOM_CONTROL "memory.oom_control"
/*
* [memory cgroup information]
* MEMCG_ROOT : memory cgroup for root dir
- * MEMCG_THROTTLING : memory cgroup for throttling
+ * MEMCG_BackgroundLru : memory cgroup for least recently used background app
*
* [memory cgroup hierarchy]
* (normal mode)
* root
- * └─Throttling
+ * └─BackgroundLru
* └─system.slice/user.slice
*/
enum cgroup_type {
MEMCG_TOP = -1,
MEMCG_ROOT,
- MEMCG_THROTTLING,
+ MEMCG_BACKGROUND_LRU,
MEMCG_END,
};
swap_conf->swap_type = SWAP_TYPE_ZRAM;
}
}
- else if (!strncmp(result->name, THROTTLING_SWAPPINESS_NAME_CONF,
- strlen(THROTTLING_SWAPPINESS_NAME_CONF)+1)) {
- swap_conf->swappiness[MEMCG_THROTTLING] = atoi(result->value);
+ else if (!strncmp(result->name, BACKGROUND_LRU_SWAPPINESS_NAME_CONF,
+ strlen(BACKGROUND_LRU_SWAPPINESS_NAME_CONF)+1)) {
+ swap_conf->swappiness[MEMCG_BACKGROUND_LRU] = atoi(result->value);
}
else {
_E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
return RESOURCED_ERROR_FAIL;
}
- if (!strncmp(result->section, MEMORY_THROTTLING_SECTION,
- strlen(MEMORY_THROTTLING_SECTION)+1)) {
+ if (!strncmp(result->section, MEMORY_BACKGROUND_LRU_SECTION,
+ strlen(MEMORY_BACKGROUND_LRU_SECTION)+1)) {
char *ptr = strchr(result->value, '%');
if (ptr == NULL) {
_E("[CONFIG] Cannot find '%%' in the string (%s)", result->value);
else
*ptr = '\0';
- if (!strncmp(result->name, THROTTLING_LIMIT_NAME_CONF,
- strlen(THROTTLING_LIMIT_NAME_CONF) + 1)) {
- memcg_conf->cgroup_limit[MEMCG_THROTTLING] = atof(result->value);
+ if (!strncmp(result->name, BACKGROUND_LRU_LIMIT_NAME_CONF,
+ strlen(BACKGROUND_LRU_LIMIT_NAME_CONF) + 1)) {
+ memcg_conf->cgroup_limit[MEMCG_BACKGROUND_LRU] = atof(result->value);
}
else {
_E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)",
error = set_mem_action_conf(&pci->mem_action, result->value);
return error;
}
- else if (!strncmp(result->name, MEMORY_THROTTLING_NAME_CONF,
- strlen(MEMORY_THROTTLING_NAME_CONF)+1) && *config_type == LIMITER_CONFIG) {
+ else if (!strncmp(result->name, MEMORY_BACKGROUND_LRU_NAME_CONF,
+ strlen(MEMORY_BACKGROUND_LRU_NAME_CONF)+1) && *config_type == LIMITER_CONFIG) {
if (!pci) {
_E("process configuration information pointer should not be NULL");
return RESOURCED_ERROR_FAIL;
}
- /* Enable throttling of a service */
- pci->memory_throttling_enable = config_parse_bool(result->value);
+ pci->is_in_memory_background_lru = config_parse_bool(result->value);
}
else if (!strncmp(result->name, CPU_THROTTLING_NAME_CONF,
strlen(CPU_THROTTLING_NAME_CONF)+1) && *config_type == LIMITER_CONFIG) {
#define MEMORY_LEVEL_THRESHOLD_SECTION "MemoryLevelThreshold"
#define MEMORY_APP_TYPE_LIMIT_SECTION "MemoryAppTypeLimit"
#define MEMORY_APP_STATUS_LIMIT_SECTION "MemoryAppStatusLimit"
-#define MEMORY_THROTTLING_SECTION "MemoryThrottling"
#define MEMORY_LMK_GOVERNOR_SECTION "MemoryLMKGovernor"
+#define MEMORY_BACKGROUND_LRU_SECTION "MemoryBackgroundLru"
#define CPU_THROTTLING_SECTION "CpuThrottling"
#define OLD_VIP_GROUP_SECTION "VIP_GROUP"
#define WATCHDOG_ACTION_NAME_CONF "WatchdogAction"
#define OOM_SCORE_NAME_CONF "OomScore"
#define FOREGROUND_OOM_SCORE_NAME_CONF "ForegroundOomScore"
-#define THROTTLING_LIMIT_NAME_CONF "ThrottlingLimit"
+#define BACKGROUND_LRU_LIMIT_NAME_CONF "BackgroundLruLimit"
#define MEDIUM_LEVEL_NAME_CONF "MediumLevel"
#define LOW_LEVEL_NAME_CONF "LowLevel"
#define CRITICAL_LEVEL_NAME_CONF "CriticalLevel"
#define CPU_CFS_RUN_TIME_NAME_CONF "CpuCFSRuntime"
#define CPU_CFS_PERIOD_NAME_CONF "CpuCFSPeriod"
#define CPU_BOOSTING_LEVEL_NAME_CONF "CpuBoostingLevel"
-#define MEMORY_THROTTLING_NAME_CONF "MemoryThrottling"
+#define MEMORY_BACKGROUND_LRU_NAME_CONF "MemoryBackgroundLru"
#define CPU_THROTTLING_NAME_CONF "CpuThrottling"
/* optimizer.conf */
#define SWAP_ENABLE_NAME_CONF "SwapEnable"
#define RECLAIM_AT_BOOT_NAME_CONF "ReclaimAtBoot"
#define SWAP_TYPE_NAME_CONF "SwapType"
-#define THROTTLING_SWAPPINESS_NAME_CONF "ThrottlingSwappiness"
+#define BACKGROUND_LRU_SWAPPINESS_NAME_CONF "BackgroundLruSwappiness"
#define COMP_ALGORITHM_NAME_CONF "CompAlgorithm"
#define ZRAM_RATIO_NAME_CONF "ZramRatio"
#define POOL_RATIO_NAME_CONF "PoolRatio"
swap_conf->enable = false;
swap_conf->boot_reclaim_enable = false;
swap_conf->swap_type = SWAP_TYPE_NONE;
- swap_conf->swappiness[MEMCG_THROTTLING] = MEMORY_INIT_SWAPPINESS;
+ swap_conf->swappiness[MEMCG_BACKGROUND_LRU] = MEMORY_INIT_SWAPPINESS;
}
}
struct cpuset_info cpuset_info;
int oom_score;
bool is_app_in_foreground_app_list;
- bool memory_throttling_enable;
+ bool is_in_memory_background_lru;
bool cpu_throttling_enable;
cpu_boosting_level_e cpu_boosting_level;
pid_t pid;
lowmem_convert_cgroup_type_to_str(next_memcg_idx));
cgroup_write_pid_fullpath(mi->name, pid);
- if (next_memcg_idx == MEMCG_THROTTLING)
- lowmem_swap_memory(get_memcg_info(MEMCG_THROTTLING)->name);
+ if (next_memcg_idx == MEMCG_BACKGROUND_LRU)
+ lowmem_swap_memory(get_memcg_info(MEMCG_BACKGROUND_LRU)->name);
} else {
/* child pid */
if (pai->memory.use_mem_limit)
lowmem_change_lowmem_state(MEM_LEVEL_HIGH);
if (swap_get_state() == SWAP_ON && lowmem_get_memcg_swap_status()) {
- resourced_notify(RESOURCED_NOTIFIER_SWAP_UNSET_LIMIT, get_memcg_info(MEMCG_THROTTLING));
+ resourced_notify(RESOURCED_NOTIFIER_SWAP_UNSET_LIMIT,
+ get_memcg_info(MEMCG_BACKGROUND_LRU));
lowmem_set_memcg_swap_status(false);
}
if (proc_get_freezer_status() == CGROUP_FREEZER_PAUSED)
g_variant_get(params, gtype, &pid);
ret_unless(pid > 0);
- lowmem_trigger_swap(pid, get_memcg_info(MEMCG_THROTTLING)->name, true);
+ lowmem_trigger_swap(pid, get_memcg_info(MEMCG_BACKGROUND_LRU)->name, true);
}
static void lowmem_dbus_set_memlimit(GVariant *params)
const char *lowmem_convert_cgroup_type_to_str(int type)
{
static const char *type_table[] =
- {"/", "Throttling"};
- if (type >= MEMCG_ROOT && type <= MEMCG_THROTTLING)
+ {"/", MEMCG_BACKGROUND_LRU_NAME};
+ if (type >= MEMCG_ROOT && type <= MEMCG_BACKGROUND_LRU)
return type_table[type];
else
return "Error";
return;
}
- /* In this case, corresponding process will be moved to memory MEMCG_THROTTLING.
+ /* In this case, corresponding process will be moved to memory MEMCG_BACKGROUND_LRU.
*/
if (move) {
error = proc_get_oom_score_adj(pid, &oom_score_adj);
}
/* Correponding process is already managed per app or service.
- * In addition, if some process is already located in the MEMCG_THROTTLING, then just do swap
+ * In addition, if some process is already located in
+ * the MEMCG_BACKGROUND_LRU, then just do swap.
*/
resourced_notify(RESOURCED_NOTIFIER_SWAP_START, path);
}
struct reclaim_conf *reclaim_conf = config_get_reclaim_conf();
/* set MemoryGroupLimit section */
- for (int cgroup = MEMCG_THROTTLING; cgroup < MEMCG_END; cgroup++) {
+ for (int cgroup = MEMCG_BACKGROUND_LRU; cgroup < MEMCG_END; cgroup++) {
if (memcg_conf->cgroup_limit[cgroup] > 0.0)
memcg_info_set_limit(get_memcg_info(cgroup),
memcg_conf->cgroup_limit[cgroup]/100.0, totalram_bytes);
static void print_mem_configs(void)
{
/* print info of Memory section */
- for (int cgroup = MEMCG_THROTTLING; cgroup < MEMCG_END; cgroup++) {
+ for (int cgroup = MEMCG_BACKGROUND_LRU; cgroup < MEMCG_END; cgroup++) {
_I("[MEMORY-CGROUP] set memory for cgroup '%s' to %llu bytes",
lowmem_convert_cgroup_type_to_str(cgroup), get_memcg_info(cgroup)->limit_bytes);
}
return;
}
- cgroup_swap = get_cgroup_tree(MEMCG_THROTTLING);
+ cgroup_swap = get_cgroup_tree(MEMCG_BACKGROUND_LRU);
if (!cgroup_swap)
return;
- swap_move_to_cgroup_by_pid(MEMCG_THROTTLING, pid);
+ swap_move_to_cgroup_by_pid(MEMCG_BACKGROUND_LRU, pid);
swap_start_handler(cgroup_swap->memcg_info->name);
_I("[SWAP] swap cgroup entered : pid : %d", (int)pid);
}
arg_swap_at_boot = swap_conf->boot_reclaim_enable;
- if (swap_conf->swappiness[MEMCG_THROTTLING] >= 0 &&
- swap_conf->swappiness[MEMCG_THROTTLING] <= 100) {
- memcg_info_set_swappiness(get_memcg_info(MEMCG_THROTTLING),
- swap_conf->swappiness[MEMCG_THROTTLING]);
+ if (swap_conf->swappiness[MEMCG_BACKGROUND_LRU] >= 0 &&
+ swap_conf->swappiness[MEMCG_BACKGROUND_LRU] <= 100) {
+ memcg_info_set_swappiness(get_memcg_info(MEMCG_BACKGROUND_LRU),
+ swap_conf->swappiness[MEMCG_BACKGROUND_LRU]);
memcg_write_optimizer_params();
- _I("[SWAP] cgroup (%s) swapiness = %d", "Throttling", get_memcg_info(MEMCG_THROTTLING)->swappiness);
+ _I("[SWAP] cgroup (%s) swapiness = %d", MEMCG_BACKGROUND_LRU_NAME,
+ get_memcg_info(MEMCG_BACKGROUND_LRU)->swappiness);
}
gslist_for_each_item(iter, swap_module) {
_D("[SWAP] resourced swap init start");
- resourced_swap_change_memcg_settings(MEMCG_THROTTLING);
+ resourced_swap_change_memcg_settings(MEMCG_BACKGROUND_LRU);
swap_set_state(SWAP_OFF);
ret = swap_init();
if (!swap_total_bytes)
swap_total_bytes = KBYTE_TO_BYTE(proc_get_swap_total());
- r = memcg_get_swap_usage(MEMCG_THROTTLING_PATH, &swap_usage_bytes);
+ r = memcg_get_swap_usage(MEMCG_BACKGROUND_LRU_PATH, &swap_usage_bytes);
if (r)
return r;
swapcg_usage_ratio = (float)(swap_usage_bytes / (swap_total_bytes - swap_available_bytes) *100);
_W("[WATCHDOG] Currently we support only REBOOT when a service is released");
}
- /* Put a system service or process into (memory) throttling group */
- if (pci->memory_throttling_enable)
- cgroup_write_pid_fullpath(MEMCG_THROTTLING_PATH, pid);
+ /* Put a system service or process into (memory) BackgroundLru group */
+ if (pci->is_in_memory_background_lru)
+ cgroup_write_pid_fullpath(MEMCG_BACKGROUND_LRU_PATH, pid);
/* register a notification when this service or process memory is over a threshold */
if (pci->mem_action.memory_bytes && pci->mem_action.action) {