[CRIU] [PATCH 2/2] cgroup: don't try to write the default value for memory.swappiness

Tycho Andersen tycho.andersen at canonical.com
Tue Jul 12 17:53:20 PDT 2016


This is a little bit of a hack. The problem is that we can't actually write
this value if memory.use_hierarchy is set, which it is by default.
Additionally, we can't do a hack like unsetting memory.use_hierarchy and
then writing this, because if the bit is set on the parent, unsetting it
will fail. So the restore *can* succeed if things are configured correctly
initially, but won't by default, which is annoying for the tests.

Plus in the case of systemd, there are child cgroups, so we can't ever
unset the root's memroy.use_hierarchy anyway, meaning we could never
actually restore correctly. Instead, let's just not try to write the
default value, which is probably what everyone is using anyway.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
CC: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/cgroup.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/criu/cgroup.c b/criu/cgroup.c
index b35878b..c9b339c 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -1409,9 +1409,18 @@ static int restore_special_props(char *paux, size_t off, CgroupDirEntry *e)
 		for (j = 0; j < e->n_properties; j++) {
 			CgroupPropEntry *prop = e->properties[j];
 
-			if (strcmp(name, prop->name) == 0)
-				if (restore_cgroup_prop(prop, paux, off) < 0)
+			if (strcmp(name, prop->name) == 0) {
+				/* XXX: we can drop this hack and make
+				 * memory.swappiness a regular property when we
+				 * drop support for kernels < 3.16. See 3dae7fec5.
+				 */
+				if (!strcmp(prop->name, "memory.swappiness") &&
+						!strcmp(prop->value, "60")) {
+					continue;
+				} else if (restore_cgroup_prop(prop, paux, off) < 0) {
 					return -1;
+				}
+			}
 		}
 	}
 
-- 
2.7.4



More information about the CRIU mailing list