mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 10:10:46 +00:00
module/cgroups: Really move all tasks in Controller.move_all_tasks_to()
The docstring of Controller.move_all_tasks_to() says that the function moves all the tasks to the "dest" cgroup. However, it iterates over self._cgroups, which is a dictionary that is lazily populated when you call Controller.cgroup(). For example, this doesn't work: cpuset_cg = target.cgroups.controller("cpuset") cpuset_cg.move_all_tasks_to("top-app") Because you haven't populated self._cgroups yet. You need to manually populate the dictionary with something like: for group in cpuset_cg.list_all(): cpuset_cg.cgroup(group) before you can use move_all_tasks_to(). Iterate through self.list_all() instead of self._cgroups to really move all tasks to to the destination directory. Controller.move_tasks() has a try-except block to get the cgroups of the source and destination groups. Controller.cgroup() caches the groups in self._cgroups and populates it if it hasn't been already. Simplify move_tasks() and let it deal with source and dest cgroups that exist but the controller hasn't loaded yet.
This commit is contained in:
parent
5b5da7c392
commit
c212ef2146
@ -124,11 +124,10 @@ class Controller(object):
|
||||
def move_tasks(self, source, dest, exclude=None):
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
try:
|
||||
srcg = self._cgroups[source]
|
||||
dstg = self._cgroups[dest]
|
||||
except KeyError as e:
|
||||
raise ValueError('Unknown group: {}'.format(e))
|
||||
|
||||
srcg = self.cgroup(source)
|
||||
dstg = self.cgroup(dest)
|
||||
|
||||
self.target._execute_util( # pylint: disable=protected-access
|
||||
'cgroups_tasks_move {} {} \'{}\''.format(
|
||||
srcg.directory, dstg.directory, exclude),
|
||||
@ -169,7 +168,7 @@ class Controller(object):
|
||||
self.logger.debug(' excluding tasks which name matches:')
|
||||
self.logger.debug(' %s', ', '.join(exclude))
|
||||
|
||||
for cgroup in self._cgroups:
|
||||
for cgroup in self.list_all():
|
||||
if cgroup != dest:
|
||||
self.move_tasks(cgroup, dest, grep_filters)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user