Commit de76a07e authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: don't try to write the default value for memory.swappiness

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: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 3c2c69bf
...@@ -1409,9 +1409,18 @@ static int restore_special_props(char *paux, size_t off, CgroupDirEntry *e) ...@@ -1409,9 +1409,18 @@ static int restore_special_props(char *paux, size_t off, CgroupDirEntry *e)
for (j = 0; j < e->n_properties; j++) { for (j = 0; j < e->n_properties; j++) {
CgroupPropEntry *prop = e->properties[j]; CgroupPropEntry *prop = e->properties[j];
if (strcmp(name, prop->name) == 0) if (strcmp(name, prop->name) == 0) {
if (restore_cgroup_prop(prop, paux, off) < 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; return -1;
}
}
} }
} }
......
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