[CRIU] [PATCH 4/8] cgroup: special handling of memory.oom_control
Tycho Andersen
tycho.andersen at canonical.com
Tue Jun 21 15:41:41 PDT 2016
memory.oom_control when read displays something like:
root at 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: Tycho Andersen <tycho.andersen at canonical.com>
---
criu/cgroup.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/criu/cgroup.c b/criu/cgroup.c
index 149a646..270a0e2 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -384,6 +384,28 @@ static int dump_cg_props_array(const char *fpath, struct cgroup_dir *ncd, const
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);
list_add_tail(&prop->list, &ncd->properties);
ncd->n_properties++;
--
2.7.4
More information about the CRIU
mailing list