Commit 333ec70d authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: special handling of memory.oom_control

memory.oom_control when read displays something like:

root@kernel:/sys/fs/cgroup/memory/zdtmtst# cat memory.oom_control
oom_kill_disable 0
under_oom 0

but when setting it, it expects a "1" or "0" when written. Let's parse out
this 1 or 0.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 7e588c1d
...@@ -384,6 +384,28 @@ static int dump_cg_props_array(const char *fpath, struct cgroup_dir *ncd, const ...@@ -384,6 +384,28 @@ static int dump_cg_props_array(const char *fpath, struct cgroup_dir *ncd, const
return -1; return -1;
} }
if (!strcmp("memory.oom_control", cgp->props[j])) {
char *new;
int disable;
if (sscanf(prop->value, "oom_kill_disable %d\n", &disable) != 1) {
pr_err("couldn't scan oom state from %s\n", prop->value);
free_cgroup_prop(prop);
free_all_cgroup_props(ncd);
return -1;
}
if (asprintf(&new, "%d", disable) < 0) {
pr_err("couldn't aloocate new oom value\n");
free_cgroup_prop(prop);
free_all_cgroup_props(ncd);
return -1;
}
xfree(prop->value);
prop->value = new;
}
pr_info("Dumping value %s from %s/%s\n", prop->value, fpath, prop->name); pr_info("Dumping value %s from %s/%s\n", prop->value, fpath, prop->name);
list_add_tail(&prop->list, &ncd->properties); list_add_tail(&prop->list, &ncd->properties);
ncd->n_properties++; ncd->n_properties++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment