{
char buf[MAX_PATH_LENGTH];
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
- _SD("cgroup_buf %s, value %d\n", buf, value);
+ _SD("cgroup_buf %s, value %u\n", buf, value);
return fwrite_uint(buf, value);
}
return;
}
+ if (limit == prev)
+ return;
+
if (prev > limit) {
cgroup_write_node_uint32(dir, MEMCG_LIMIT_BYTE, limit);
cgroup_write_node_uint32(dir, MEMCG_SWAP_LIMIT_BYTE, limit);
return RESOURCED_ERROR_NONE;
}
-static int memcg_write_params_info(struct memcg_info *mi)
+static int memcg_write_limiter_info(struct memcg_info *mi)
{
unsigned int limit = mi->limit;
const char *name = mi->name;
int ret = RESOURCED_ERROR_NONE;
- int swappiness = -1;
- _I("write memcg param for %s", name);
/* enable cgroup move */
ret = cgroup_write_node_uint32(name,
MEMCG_MOVE_CHARGE, 3);
if (ret)
return ret;
+ if (mi->limit_ratio == MEMCG_NO_LIMIT)
+ return ret;
+
+ /* write limit_in_bytes */
+ ret = check_oom_and_set_limit(name, limit);
+ return ret;
+}
+
+static int memcg_write_optimizer_info(struct memcg_info *mi)
+{
+ const char *name = mi->name;
+ int ret = RESOURCED_ERROR_NONE;
+ int swappiness = -1;
+
/*
* write swapness if it has a meaningful value.
* if it has own swappiness value, set it to memcg at first.
ret = cgroup_write_node_uint32(name,
MEMCG_SWAPPINESS, swappiness);
if (ret)
- _I("failed to write %s %d to %s the",
+ _I("[DEBUG] failed to write %s %d to %s the",
MEMCG_SWAPPINESS, swappiness, name);
}
- if (mi->limit_ratio == MEMCG_NO_LIMIT)
- return ret;
-
- /* write limit_in_bytes */
- ret = check_oom_and_set_limit(name, limit);
- _I("set %s's limit to %u", name, limit);
return ret;
}
-int memcg_write_params(void)
+int memcg_write_limiter_params(void)
+{
+ unsigned int i;
+ unsigned int lower_group_limit = 0;
+
+ for (i = CGROUP_LOW; i > CGROUP_ROOT; i--) {
+ struct memcg_info *mi = get_memcg_info(i);
+
+ if (mi->limit < lower_group_limit)
+ mi->limit = lower_group_limit;
+
+ memcg_write_limiter_info(mi);
+ lower_group_limit = mi->limit;
+ }
+
+ return RESOURCED_ERROR_NONE;
+}
+
+int memcg_write_optimizer_params(void)
{
unsigned int i;
- for (i = CGROUP_ROOT; i < CGROUP_END; i++) {
+ for (i = CGROUP_VIP; i < CGROUP_END; i++) {
struct memcg_info *mi = get_memcg_info(i);
- memcg_write_params_info(mi);
+ memcg_write_optimizer_info(mi);
}
return RESOURCED_ERROR_NONE;
mi->limit = (float)totalram * ratio;
mi->limit_ratio = ratio;
- _I("[DEBUG] ratio = %f, limit = %u, ram = %u", ratio, mi->limit, totalram);
mi->threshold[MEM_LEVEL_CRITICAL] = (unsigned int)(mi->limit * MEMCG_LOW_RATIO);
mi->threshold[MEM_LEVEL_OOM] = (unsigned int)(mi->limit * MEMCG_MEDIUM_RATIO);
mi->threshold_leave = (float)mi->limit * MEMCG_FOREGROUND_LEAVE_RATIO;
const char *cgroup_memory_stat_id_to_string(enum cgroup_memory_stat_id id);
enum cgroup_memory_stat_id cgroup_memory_stat_string_to_id(const char *str);
-int memcg_write_params(void);
+int memcg_write_limiter_params(void);
+int memcg_write_optimizer_params(void);
void memcg_set_threshold(int type, int level, int value);
void memcg_set_leave_threshold(int type, int value);
_cleanup_free_ char *digit_buf = NULL;
int ret;
- ret = asprintf(&digit_buf, "%d", number);
+ ret = asprintf(&digit_buf, "%u", number);
ret_value_errno_msg_if(ret < 0, -ENOMEM,
"sprintf failed\n");
{
ret_msg_if(!module, "Invalid module handler\n");
- _I("[DEBUG] module: %s is added", module->name);
-
if (module->priority == MODULE_PRIORITY_EARLY)
modules_list = g_slist_prepend(modules_list, (gpointer)module);
else
}
module->initalized = MODULE_INITIALIZED;
- _D("[DEBUG] Initialized [%s] module\n", module->name);
}
}
assert(set);
assert(set->name);
- _D("[DEBUG] cpu-sched: init cgroup set for %s", set->name);
r = cgroup_make_subdir(CPUSET_CGROUP, set->name, NULL);
if (r < 0) {
_E("[DEBUG] failed to make cpuset cgroup (%s)", set->name);
GSList *i;
struct coreset *c;
- _D("[DEBUG] cpu-sched: init cgroup subsystem");
if (cpu_sched_is_cpuset_mounted() == false) {
r = cgroup_make_subdir(CGROUP_PATH, "cpuset", NULL);
if (r < 0) {
assert(set);
assert(core_id >= 0);
- _D("[DEBUG] cpu-sched: new core %d for set %s", core_id, set->name);
c = (struct core *)calloc(1, sizeof *c);
if (c == NULL) {
_E("cpu-sched: could not allocate memory for core struct");
assert(set);
assert(value);
assert(!set->cores);
- _D("[DEBUG] cpu-sched: parse cpuset for %s (%s)", set->name, value);
ptr = strtok_r(value, ",", &saveptr);
while (ptr) {
static int cpu_sched_parse_config(struct cpu_sched *data)
{
- _D("[DEBUG] cpu-sched: parse config");
load_config(data);
/* if (config_parse(CPU_SCHED_CONF_FILE, load_config, data) < 0)
return RESOURCED_ERROR_FAIL;*/
static int cpu_sched_init(void *data)
{
int r;
- _D("[DEBUG] cpu-sched: init module");
if (cpu_sched_parse_config(&cs) != RESOURCED_ERROR_NONE) {
_E("cpu-sched: error parsing config");
return RESOURCED_ERROR_FAIL;
}
- _D("[DEBUG] cpu-sched: init module end");
cs.is_initalized = true;
cpu_sched_check_apps();
return RESOURCED_ERROR_NONE;
if (ret < 0)
_E("[DEBUG] Fail to broadcast dbus signal with pid(%d), appname(%s)", pid, appname);
- _I("[DEBUG] broadcast signal to notify");
return ret;
}
}
if (kill(mle->pid, 0) == 0) {
- _D("[DEBUG] pid (%d) is still alive, so kill directly using SIGKILL", mle->pid);
safe_kill(mle->pid, SIGKILL);
}
- _D("[DEBUG] pid (%d) is dead", mle->pid);
-
mle_timer_init:
mle->pid = -1;
timer_out:
struct memory_limit_event *mle;
_cleanup_free_ struct cgroup_memory_stat *mem_stat = NULL;
- _I("[DEBUG] receive lowmem limit about %s", cg_dir);
mle = g_hash_table_lookup(memory_limit_hash, cg_dir);
if (!mle) {
_E("invalid event\n");
g_hash_table_insert(memory_limit_hash, (gpointer)mle->path,
(gpointer)mle);
- _I("[DEBUG] a memory cgroup notificatoin is registered at %s", dir);
return RESOURCED_ERROR_NONE;
}
int result;
unsigned int totalram = lowmem_get_totalram();
- _I("[DEBUG] pid: %d, limit: %u, name: %s, action: %d", pid, limit, name, action);
-
if (limit < MIN_LIMIT_VALUE || limit > totalram) {
_E("[DEBUG] It's meaningless to set memory limit with size (%d)", limit);
return;
mem_widget_limit = widget_limit;
mem_guiapp_limit = guiapp_limit;
mem_bgapp_limit = bgapp_limit;
-
- _I("[DEBUG] Limit of service = %u, widget = %u, guiap = %u, bgapp = %u bytes",
- mem_service_limit, mem_widget_limit, mem_guiapp_limit, mem_bgapp_limit);
}
void lowmem_action_init(int service_action, int widget_action,
if (bgapp_action > 0)
mem_bgapp_action = bgapp_action;
-
- _I("[DEBUG] action of service = %d, widget = %d, guiap = %d, bgapp = %d bytes",
- service_action, widget_action, guiapp_action, bgapp_action);
}
void lowmem_limit_init(void)
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_3072_THRES_LEAVE);
num_max_victims = CGROUP_ROOT_3072_NUM_VICTIMS;
}
-
}
static void lowmem_move_memcgroup(int pid, int next_oom_score_adj, struct proc_app_info *pai)
if (cur_oom_score_adj != OOMADJ_APP_MAX + 10) {
/* VIP processes should not be asked to move. */
if (cur_memcg_idx <= CGROUP_VIP) {
- _I("[DEBUG] pid: %d, name: %s, cur_oom_score_adj: %d", pid, pai->appid, cur_oom_score_adj);
_E("[DEBUG] current cgroup (%s) cannot be VIP or Root", convert_cgroup_type_to_str(cur_memcg_idx));
return;
}
_I("[DEBUG] set number of max victims as %d", num_max_victims);
_I("[DEBUG] set threshold leave to %u MB", get_root_memcg_info()->threshold_leave);
_I("[DEBUG] set proactive threshold to %u MB", proactive_threshold);
- _I("[DEUBG] set proactive low memory killer leave to %u MB", proactive_leave);
+ _I("[DEBUG] set proactive low memory killer leave to %u MB", proactive_leave);
/* print info of POPUP section */
_I("[DEBUG] oom popup is %s", oom_popup_enable == true ? "enabled" : "disabled");
_I("prefix of memlimit memps is %s", memlog_prefix[MEMLOG_MEMPS_MEMLIMIT]);*/
}
+#include "file-helper.h"
+
/* To Do: should we need lowmem_fd_start, lowmem_fd_stop ?? */
static int lowmem_init(void)
{
load_configs(MEM_CONF_FILE);
/* this function should be called after parsing configurations */
- memcg_write_params();
+ memcg_write_limiter_params();
print_mem_configs();
/* make a worker thread called low memory killer */
lowmem_limit_init();
lowmem_system_init();
- _D("[DEBUG] resourced memory init end with ret = %d", ret);
register_notifier(RESOURCED_NOTIFIER_APP_PRELAUNCH, lowmem_prelaunch_handler);
register_notifier(RESOURCED_NOTIFIER_MEM_CONTROL, lowmem_control_handler);
register_notifier(RESOURCED_NOTIFIER_LCD_OFF, lowmem_bg_reclaim_handler);
if (arg_swap_enable == false)
goto free_swap_conf;
- _I("[DEBUG] swap type: %s", swap_conf->type);
-
arg_swap_at_boot = swap_conf->boot_reclaim_enable;
if (config_parse_swap_types(swap_conf->type, &arg_swap_type) < 0) {
_E("[DEBUG] Failed to parse type of swap, so use default zram type");
if (!arg_swap_enable)
return -ENODEV;
+ memcg_write_optimizer_params();
+
gslist_for_each_safe(swap_module, iter, next, swaps) {
swaps = (struct swap_module_ops *)iter->data;
if (!CHECK_BIT(arg_swap_type, swaps->type)) {
/* fixed memory cgroup */
if (pci->mem_type != CGROUP_TOP) {
- _I("[DEBUG] pid = %d, oom: %d, name: %s", pid, cgroup_get_lowest_oom_score_adj(pci->mem_type), pci->name);
proc_set_oom_score_adj(pid, cgroup_get_lowest_oom_score_adj(pci->mem_type), NULL);
}
/* fixed cpu cgroup */
if (pci->cpu_type != CGROUP_TOP) {
- _I("[DEBUG] pid = %d, cgroup: %s, name: %s", pid, CPU_CGROUP_PATH(pci->cpu_type), pci->name);
cpu_move_cgroup_foreach(pid, NULL, CPU_CGROUP_PATH(pci->cpu_type));
}
/* fixed cpu priority */
if (pci->cpu_priority != CPU_INIT_PRIO) {
- _I("[DEBUG] pid = %d, cpu prio: %d, name: %s", pid, pci->cpu_priority, pci->name);
setpriority(PRIO_PROCESS, pid, pci->cpu_priority);
}
/* register a notification when this service is released */
switch (pci->fail_action) {
case PROC_ACTION_REBOOT:
- _I("[DEBUG] Reboot on Failure");
proc_watchdog_booting_done(pci->name, pid);
break;
default: