diff options
-rw-r--r-- | src/common/cgroup.c | 10 | ||||
-rw-r--r-- | src/cpu/cpu.c | 15 | ||||
-rw-r--r-- | src/memory/memcontrol.c | 6 | ||||
-rw-r--r-- | src/memory/vmpressure-lowmem-handler.c | 8 |
4 files changed, 20 insertions, 19 deletions
diff --git a/src/common/cgroup.c b/src/common/cgroup.c index 180a5c8d..7a466fb8 100644 --- a/src/common/cgroup.c +++ b/src/common/cgroup.c @@ -43,8 +43,8 @@ #include <unistd.h> #include <sys/mount.h> -#define RELEASE_AGENT "/release_agent" -#define NOTIFY_ON_RELEASE "/notify_on_release" +#define RELEASE_AGENT "release_agent" +#define NOTIFY_ON_RELEASE "notify_on_release" static bool cgroup_is_exists(const char *cgroup_full_path) { @@ -130,7 +130,7 @@ int cgroup_write_node(const char *cgroup_name, const char *file_name, unsigned int value) { char buf[MAX_PATH_LENGTH]; - snprintf(buf, sizeof(buf), "%s%s", cgroup_name, file_name); + snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name); _SD("cgroup_buf %s, value %d\n", buf, value); return fwrite_int(buf, value); } @@ -139,7 +139,7 @@ int cgroup_write_node_str(const char *cgroup_name, const char *file_name, const char *string) { char buf[MAX_PATH_LENGTH]; - snprintf(buf, sizeof(buf), "%s%s", cgroup_name, file_name); + snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name); _SD("cgroup_buf %s, string %s\n", buf, string); return fwrite_str(buf, string); } @@ -149,7 +149,7 @@ int cgroup_read_node(const char *cgroup_name, { char buf[MAX_PATH_LENGTH]; int ret; - snprintf(buf, sizeof(buf), "%s%s", cgroup_name, file_name); + snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name); ret = fread_uint(buf, value); _SD("cgroup_buf %s, value %d\n", buf, *value); return ret; diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 8f929ee5..fb0cae16 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -45,18 +45,19 @@ #include "const.h" #include "file-helper.h" -#define CPU_DEFAULT_CGROUP "/sys/fs/cgroup/cpu" -#define CPU_BACKGROUND_GROUP CPU_DEFAULT_CGROUP"/background" -#define CPU_CPUQUOTA_GROUP CPU_DEFAULT_CGROUP"/quota" -#define CPU_CONTROL_BANDWIDTH "/cpu.cfs_quota_us" -#define CPU_CONTROL_FULL_BANDWIDTH "/cpu.cfs_period_us" +#define CPU_DEFAULT_CGROUP "/sys/fs/cgroup/cpu" +#define CPU_BACKGROUND_GROUP CPU_DEFAULT_CGROUP"/background" +#define CPU_CPUQUOTA_GROUP CPU_DEFAULT_CGROUP"/quota" +#define CPU_CONTROL_BANDWIDTH "cpu.cfs_quota_us" +#define CPU_CONTROL_FULL_BANDWIDTH "cpu.cfs_period_us" +#define CPU_SHARE "cpu.shares" + #define CPU_CONF_FILE RD_CONFIG_FILE(cpu) #define CPU_CONF_SECTION "CONTROL" #define CPU_CONF_PREDEFINE "PREDEFINE" #define CPU_CONF_BOOTING "BOOTING_PREDEFINE" #define CPU_CONF_WRT "WRT_PREDEFINE" #define CPU_CONF_LAZY "LAZY_PREDEFINE" -#define CPU_SHARE "/cpu.shares" #define MAX_PREDEFINED_TASKS 10 #define CPU_TIMER_INTERVAL 30 #define CPU_DEFAULT_PRI 0 @@ -152,7 +153,7 @@ static void cpu_check_cpuquota(void) int ret, node = 0; char buf[MAX_PATH_LENGTH]; - snprintf(buf, sizeof(buf), "%s%s", CPU_DEFAULT_CGROUP, CPU_CONTROL_BANDWIDTH); + snprintf(buf, sizeof(buf), "%s/%s", CPU_DEFAULT_CGROUP, CPU_CONTROL_BANDWIDTH); ret = fread_int(buf, &node); if (!ret) bCPUQuota = true; diff --git a/src/memory/memcontrol.c b/src/memory/memcontrol.c index 87455fc0..50acf4f3 100644 --- a/src/memory/memcontrol.c +++ b/src/memory/memcontrol.c @@ -63,7 +63,7 @@ static struct memcg_info *memcg_info_alloc_subcgroup(struct memcg *memcg) return NULL; mi->id = memcg->num_subcgroup; pmi = memcg->info; - snprintf(mi->name, MAX_PATH_LENGTH, "%s%d/", + snprintf(mi->name, MAX_PATH_LENGTH, "%s/%d", pmi->name, memcg->num_subcgroup++); mi->limit_ratio = pmi->limit_ratio; mi->limit = pmi->limit; @@ -161,7 +161,7 @@ int memcg_get_anon_usage(struct memcg_info *mi, unsigned long long *anon_usage) char name[BUF_MAX] = {0, }; unsigned long long tmp, active_anon = 0, inactive_anon = 0; - snprintf(buf, sizeof(buf), "%smemory.stat", mi->name); + snprintf(buf, sizeof(buf), "%s/memory.stat", mi->name); _I("get mem usage anon from %s", buf); f = fopen(buf, "r"); @@ -213,7 +213,7 @@ int memcg_get_pids(struct memcg_info *mi, GArray *pids) if (pids == NULL) return RESOURCED_ERROR_FAIL; - snprintf(buf, sizeof(buf), "%scgroup.procs", mi->name); + snprintf(buf, sizeof(buf), "%s/cgroup.procs", mi->name); f = fopen(buf, "r"); if (!f) { diff --git a/src/memory/vmpressure-lowmem-handler.c b/src/memory/vmpressure-lowmem-handler.c index e55a74e3..504eb689 100644 --- a/src/memory/vmpressure-lowmem-handler.c +++ b/src/memory/vmpressure-lowmem-handler.c @@ -1496,10 +1496,10 @@ static int init_memcg_params(void) } memcg_init(memcg_tree[idx]); if (memcg_name[idx]) - snprintf(buf, MAX_PATH_LENGTH, "%s/%s/", LOWMEM_DEFAULT_CGROUP, + snprintf(buf, MAX_PATH_LENGTH, "%s/%s", LOWMEM_DEFAULT_CGROUP, memcg_name[idx]); else - snprintf(buf, MAX_PATH_LENGTH, "%s/", LOWMEM_DEFAULT_CGROUP); + snprintf(buf, MAX_PATH_LENGTH, "%s", LOWMEM_DEFAULT_CGROUP); mi = (struct memcg_info *)malloc(sizeof(struct memcg_info)); if (!mi) { int i; @@ -1849,14 +1849,14 @@ static void lowmem_press_register_eventfd(struct memcg_info *mi) if (mi->threshold[LOWMEM_MEDIUM] == LOWMEM_THRES_INIT) return; - snprintf(buf, sizeof(buf), "%s%s", name, MEMCG_EVENTFD_CONTROL); + snprintf(buf, sizeof(buf), "%s/%s", name, MEMCG_EVENTFD_CONTROL); cgfd = open(buf, O_WRONLY); if (cgfd < 0) { _E("open event_control failed"); return; } - snprintf(buf, sizeof(buf), "%s%s", name, MEMCG_EVENTFD_MEMORY_PRESSURE); + snprintf(buf, sizeof(buf), "%s/%s", name, MEMCG_EVENTFD_MEMORY_PRESSURE); pressurefd = open(buf, O_RDONLY); if (pressurefd < 0) { _E("open pressure control failed"); |