mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
cgroups: add support list tasks in a specified CGroup
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
parent
83c1312b22
commit
42efd0a2e2
@ -152,6 +152,17 @@ cgroups_tasks_move() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cgroups_tasks_in() {
|
||||||
|
GRP=${1}
|
||||||
|
for TID in $($CAT $GRP/tasks); do
|
||||||
|
COMM=`$CAT /proc/$TID/comm 2>/dev/null`
|
||||||
|
[ "$COMM" != "" ] && CMDL=`$CAT /proc/$TID/cmdline 2>/dev/null`
|
||||||
|
[ "$COMM" != "" ] && echo "$TID,$COMM,$CMDL"
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Main Function Dispatcher
|
# Main Function Dispatcher
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -181,6 +192,9 @@ cgroups_run_into)
|
|||||||
cgroups_tasks_move)
|
cgroups_tasks_move)
|
||||||
cgroups_tasks_move $*
|
cgroups_tasks_move $*
|
||||||
;;
|
;;
|
||||||
|
cgroups_tasks_in)
|
||||||
|
cgroups_tasks_in $*
|
||||||
|
;;
|
||||||
ftrace_get_function_stats)
|
ftrace_get_function_stats)
|
||||||
ftrace_get_function_stats
|
ftrace_get_function_stats
|
||||||
;;
|
;;
|
||||||
|
@ -136,6 +136,28 @@ class Controller(object):
|
|||||||
if cgroup != dest:
|
if cgroup != dest:
|
||||||
self.move_tasks(cgroup, dest)
|
self.move_tasks(cgroup, dest)
|
||||||
|
|
||||||
|
def tasks(self, cgroup):
|
||||||
|
try:
|
||||||
|
cg = self._cgroups[cgroup]
|
||||||
|
except KeyError as e:
|
||||||
|
raise ValueError('Unkown group: {}'.format(e))
|
||||||
|
output = self.target._execute_util(
|
||||||
|
'cgroups_tasks_in {}'.format(cg.directory),
|
||||||
|
as_root=True)
|
||||||
|
entries = output.splitlines()
|
||||||
|
tasks = {}
|
||||||
|
for task in entries:
|
||||||
|
tid = task.split(',')[0]
|
||||||
|
try:
|
||||||
|
tname = task.split(',')[1]
|
||||||
|
except: continue
|
||||||
|
try:
|
||||||
|
tcmdline = task.split(',')[2]
|
||||||
|
except:
|
||||||
|
tcmdline = ''
|
||||||
|
tasks[int(tid)] = (tname, tcmdline)
|
||||||
|
return tasks
|
||||||
|
|
||||||
class CGroup(object):
|
class CGroup(object):
|
||||||
|
|
||||||
def __init__(self, controller, name, create=True):
|
def __init__(self, controller, name, create=True):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user