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>
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
LowLevel= 15%
CriticalLevel= 10%
OomLevel= 7%
+LmkThresholdLeave= 14%
OomPopup= no
[MemoryAppTypeLimit]
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;
}
float cgroup_limit[MEMCG_END]; /* % */
bool oom_popup;
enum memcg_limit_trigger limit_trigger;
+ struct mem_threshold threshold_leave;
};
struct memcg_info {
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);
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);
#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"
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;
}
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);