3 #include "cpu-cgroup.h"
6 static struct cpucg_conf *cpucg_conf = NULL;
8 char *get_cpucg_conf_name(void)
11 return cpucg_conf->name;
16 char *get_cpucg_conf_value(void)
19 return cpucg_conf->value;
24 int set_cpucg_conf(const char *name, const char *value)
26 cpucg_conf = (struct cpucg_conf *)calloc(1, sizeof (struct cpucg_conf));
28 _E("Failed to alloc memory for cpu configuration");
29 return RESOURCED_ERROR_OUT_OF_MEMORY;
32 if (strlen(name) + 1 > sizeof(cpucg_conf->name)) {
33 _E("Size of cpu configuration for name is not enough");
34 return RESOURCED_ERROR_OUT_OF_MEMORY;
36 strncpy(cpucg_conf->name, name, sizeof(cpucg_conf->name) - 1);
38 if (strlen(value) + 1 > sizeof(cpucg_conf->value)) {
39 _E("Size of cpu configuration for value is not enough");
40 return RESOURCED_ERROR_OUT_OF_MEMORY;
42 strncpy(cpucg_conf->value, value, sizeof(cpucg_conf->value) - 1);
44 return RESOURCED_ERROR_NONE;
47 void free_cpucg_conf(void)
53 static int cpu_move_cgroup(pid_t pid, char *path)
55 return cgroup_write_pid_fullpath(path, pid);
58 int cpu_move_cgroup_foreach(pid_t pid, struct proc_app_info *pai, char *path)
65 return RESOURCED_ERROR_INVALID_PARAMETER;
68 /* Don't touch cpu cgroup fixed process' score */
69 if (pai && pai->app_cpucg_update_exclude)
70 return RESOURCED_ERROR_NONE;
73 return cpu_move_cgroup(pid, path);
75 cpu_move_cgroup(pai->main_pid, path);
77 gslist_for_each_item(iter, pai->childs) {
78 child_pid = GPOINTER_TO_PID(iter->data);
79 cpu_move_cgroup(child_pid, path);
82 return RESOURCED_ERROR_NONE;