diff options
author | Unsung Lee <unsung.lee@samsung.com> | 2023-11-17 15:28:21 +0900 |
---|---|---|
committer | Unsung Lee <unsung.lee@samsung.com> | 2024-01-02 17:45:35 +0900 |
commit | 5def86bd71078cf2f0794195ca85caf4c0d558e6 (patch) | |
tree | c697d03faa28b7fe354c620aaa6a1a89d954987e | |
parent | c0f612e303442d2b4bcbb78822040d44911281c3 (diff) | |
download | resourced-5def86bd71078cf2f0794195ca85caf4c0d558e6.tar.gz resourced-5def86bd71078cf2f0794195ca85caf4c0d558e6.tar.bz2 resourced-5def86bd71078cf2f0794195ca85caf4c0d558e6.zip |
conf: Add LmkThresholdLeave to set stop condition of LMK
Add LmkThresholdLeave to set stop condition of LMK.
It is restoration of 'ThresholdLeave' in tizen 6.0.
Change-Id: I0fb27492d8aae4ae0807fd65e98560c025e6c057
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
-rw-r--r-- | conf/README | 7 | ||||
-rw-r--r-- | conf/limiter.conf | 1 | ||||
-rw-r--r-- | src/common/cgroup/memory-cgroup.c | 38 | ||||
-rw-r--r-- | src/common/cgroup/memory-cgroup.h | 2 | ||||
-rw-r--r-- | src/common/conf/config-parser.c | 4 | ||||
-rw-r--r-- | src/common/conf/config-parser.h | 1 | ||||
-rw-r--r-- | src/resource-limiter/memory/lowmem.c | 14 |
7 files changed, 50 insertions, 17 deletions
diff --git a/conf/README b/conf/README index c11e0503..cf12bd2e 100644 --- a/conf/README +++ b/conf/README @@ -74,6 +74,13 @@ Value: <threshold>[GMK]B Comment: Specify the threshold or ratio for memory level oom(out of memory). Example: OomLevel=160MB +Key: LmkThresholdLeave +Value: <threshold>[GMK]B + or + <ratio>% +Comment: Specify the threshold or ratio for LMK stop. +Example: LmkThresholdLeave=160MB + 1.3 Section: MemoryAppTypeLimit =============================== Key: ServicePerAppLimitAction diff --git a/conf/limiter.conf b/conf/limiter.conf index 96a603c3..b0dfe1d6 100644 --- a/conf/limiter.conf +++ b/conf/limiter.conf @@ -3,6 +3,7 @@ MediumLevel= 25% LowLevel= 15% CriticalLevel= 10% OomLevel= 7% +LmkThresholdLeave= 14% OomPopup= no [MemoryAppTypeLimit] diff --git a/src/common/cgroup/memory-cgroup.c b/src/common/cgroup/memory-cgroup.c index 51aeb53e..e5973a01 100644 --- a/src/common/cgroup/memory-cgroup.c +++ b/src/common/cgroup/memory-cgroup.c @@ -246,31 +246,43 @@ int set_mem_action_conf(struct mem_action *mem_action, const char *value) return RESOURCED_ERROR_NONE; } -int set_memcg_conf_threshold(bool percent, char size, int lvl, const char *value) +static int get_threshold_size(bool percent, char size, const char *value) { if (!percent) { - if (size == 'G') { - memcg_conf->threshold[lvl].threshold = - GBYTE_TO_MBYTE(atoi(value)); - } + if (size == 'G') + return GBYTE_TO_MBYTE(atoi(value)); else if (size == 'M') { - memcg_conf->threshold[lvl].threshold = - atoi(value); + return atoi(value); } else if (size == 'K') { - memcg_conf->threshold[lvl].threshold = - KBYTE_TO_MBYTE(atoi(value)); + return KBYTE_TO_MBYTE(atoi(value)); } else { _E("Memory size unit should be GB or MB or KB"); - return RESOURCED_ERROR_FAIL; + return -1; } } - else { - memcg_conf->threshold[lvl].threshold = atoi(value); - } + return atoi(value); +} + +int set_memcg_conf_threshold(bool percent, char size, int lvl, const char *value) +{ memcg_conf->threshold[lvl].percent = percent; + memcg_conf->threshold[lvl].threshold = get_threshold_size(percent, size, value); + if (memcg_conf->threshold[lvl].threshold < 0) + return RESOURCED_ERROR_FAIL; + + return RESOURCED_ERROR_NONE; +} + +int memcg_set_conf_threshold_leave(bool percent, char size, const char *value) +{ + memcg_conf->threshold_leave.percent = percent; + memcg_conf->threshold_leave.threshold = get_threshold_size(percent, size, value); + if (memcg_conf->threshold_leave.threshold < 0) + return RESOURCED_ERROR_FAIL; + return RESOURCED_ERROR_NONE; } diff --git a/src/common/cgroup/memory-cgroup.h b/src/common/cgroup/memory-cgroup.h index 6a64274e..f28afbb4 100644 --- a/src/common/cgroup/memory-cgroup.h +++ b/src/common/cgroup/memory-cgroup.h @@ -175,6 +175,7 @@ struct memcg_conf { float cgroup_limit[MEMCG_END]; /* % */ bool oom_popup; enum memcg_limit_trigger limit_trigger; + struct mem_threshold threshold_leave; }; struct memcg_info { @@ -206,6 +207,7 @@ 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); +int memcg_set_conf_threshold_leave(bool percent, char size, const char *value); struct memcg_conf *get_memcg_conf(void); void free_memcg_conf(void); diff --git a/src/common/conf/config-parser.c b/src/common/conf/config-parser.c index bd93f231..a4fe1df0 100644 --- a/src/common/conf/config-parser.c +++ b/src/common/conf/config-parser.c @@ -794,6 +794,10 @@ static int limiter_config(struct parse_result *result, void *user_data) strlen(OOM_LEVEL_NAME_CONF) + 1)) { error = set_memcg_conf_threshold(percent, temp, MEM_LEVEL_OOM, result->value); } + else if (!strncmp(result->name, MEMORY_LMK_THRESHOLD_LEAVE_NAME_CONF, + strlen(MEMORY_LMK_THRESHOLD_LEAVE_NAME_CONF) + 1)) { + error = memcg_set_conf_threshold_leave(percent, temp, result->value); + } else { _E("[CONFIG] Unknown configuration name (%s) and value (%s) on section (%s)", result->name, result->value, result->section); diff --git a/src/common/conf/config-parser.h b/src/common/conf/config-parser.h index 6ce08e99..1a82e5b2 100644 --- a/src/common/conf/config-parser.h +++ b/src/common/conf/config-parser.h @@ -100,6 +100,7 @@ extern "C" { #define WORKING_SET_SIZE_POST_GOVERNOR_NAME_CONF "WorkingSetSizePostGovernor" #define MEMORY_LIMIT_TRIGGER_NAME_CONF "MemoryLimitTrigger" #define MEMORY_LMK_KILL_EXCEPTION_NAME_CONF "LmkKillException" +#define MEMORY_LMK_THRESHOLD_LEAVE_NAME_CONF "LmkThresholdLeave" /* CPU specific configuration name */ #define CPU_SCHED_NAME_CONF "CpuSched" diff --git a/src/resource-limiter/memory/lowmem.c b/src/resource-limiter/memory/lowmem.c index 9d5e62a5..1ef02d43 100644 --- a/src/resource-limiter/memory/lowmem.c +++ b/src/resource-limiter/memory/lowmem.c @@ -1600,8 +1600,6 @@ static void load_configs(void) calculate_threshold_size(memcg_conf->threshold[lvl].threshold)); if (lvl == MEM_LEVEL_OOM) { - memcg_set_leave_threshold(MEMCG_ROOT, - get_memcg_info(MEMCG_ROOT)->threshold_mb[lvl] * 1.5); proactive_threshold_mb = get_memcg_info(MEMCG_ROOT)->threshold_leave_mb; proactive_leave_mb = proactive_threshold_mb * 1.5; } @@ -1611,14 +1609,22 @@ static void load_configs(void) memcg_conf->threshold[lvl].threshold); if (lvl == MEM_LEVEL_OOM) { - memcg_set_leave_threshold(MEMCG_ROOT, - get_memcg_info(MEMCG_ROOT)->threshold_mb[lvl] * 1.5); proactive_threshold_mb = get_memcg_info(MEMCG_ROOT)->threshold_leave_mb; proactive_leave_mb = proactive_threshold_mb * 1.5; } } } + + if (memcg_conf->threshold_leave.percent && + memcg_conf->threshold_leave.threshold > 0) { + memcg_set_leave_threshold(MEMCG_ROOT, + calculate_threshold_size(memcg_conf->threshold_leave.threshold)); + } else if (memcg_conf->threshold_leave.threshold > 0) { + memcg_set_leave_threshold(MEMCG_ROOT, + memcg_conf->threshold_leave.threshold); + } + oom_popup_enable = memcg_conf->oom_popup; set_memcg_limit_trigger(memcg_conf->limit_trigger); |