module/cgroups: robustify task freezer
The set() method of the CGroup class used to freeze tasks relies on
target's write_value(). Sometimes, the freezing procedure takes some
time and the call to write_value() in set() fails by reading "FREEZING"
while it expected "FROZEN". To avoid this issue, this commits introduces
a shutil call dedicated to changing the state of the freezer controller.
diff --git a/devlib/module/cgroups.py b/devlib/module/cgroups.py
index bfe2785..8987899 100644
--- a/devlib/module/cgroups.py
+++ b/devlib/module/cgroups.py
@@ -466,11 +466,11 @@
if freezer is None:
raise RuntimeError('freezer cgroup controller not present')
freezer_cg = freezer.cgroup('/DEVLIB_FREEZER')
- thawed_cg = freezer.cgroup('/')
+ cmd = 'cgroups_freezer_set_state {{}} {}'.format(freezer_cg.directory)
if thaw:
# Restart froozen tasks
- freezer_cg.set(state='THAWED')
+ freezer.target._execute_util(cmd.format('THAWED'), as_root=True)
# Remove all tasks from freezer
freezer.move_all_tasks_to('/')
return
@@ -482,7 +482,7 @@
tasks = freezer.tasks('/')
# Freeze all tasks
- freezer_cg.set(state='FROZEN')
+ freezer.target._execute_util(cmd.format('FROZEN'), as_root=True)
return tasks