1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

Merge pull request #22 from derkling/cgroup-fixups

Cgroup fixups
This commit is contained in:
setrofim 2016-02-24 14:32:13 +00:00
commit 9c89ca0437
2 changed files with 23 additions and 10 deletions

View File

@ -55,6 +55,20 @@ ftrace_get_function_stats() {
done done
} }
################################################################################
# CGroups Utility Functions
################################################################################
cgroups_get_attributes() {
[[ $# -eq 2 ]] || exit -1
CGROUP="$1"
CONTROLLER="$2"
$GREP '' $CGROUP/* | \
$GREP "$CONTROLLER\." | \
$SED -e "s|$CONTROLLER\.||" -e "s|$CGROUP/||"
}
################################################################################ ################################################################################
# Main Function Dispatcher # Main Function Dispatcher
################################################################################ ################################################################################
@ -75,6 +89,9 @@ cpufreq_get_all_governors)
cpufreq_trace_all_frequencies) cpufreq_trace_all_frequencies)
cpufreq_trace_all_frequencies $* cpufreq_trace_all_frequencies $*
;; ;;
cgroups_get_attributes)
cgroups_get_attributes $*
;;
ftrace_get_function_stats) ftrace_get_function_stats)
ftrace_get_function_stats ftrace_get_function_stats
;; ;;

View File

@ -98,7 +98,7 @@ class Controller(object):
output = self.target.execute('{} find {} -type d'\ output = self.target.execute('{} find {} -type d'\
.format(self.target.busybox, self.mount_point)) .format(self.target.busybox, self.mount_point))
cgroups = [] cgroups = []
for cg in output.split('\n'): for cg in output.splitlines():
cg = cg.replace(self.mount_point + '/', '/') cg = cg.replace(self.mount_point + '/', '/')
cg = cg.replace(self.mount_point, '/') cg = cg.replace(self.mount_point, '/')
cg = cg.strip() cg = cg.strip()
@ -166,14 +166,10 @@ class CGroup(object):
self.controller.kind) self.controller.kind)
logging.debug(' %s', logging.debug(' %s',
self.directory) self.directory)
output = self.target.execute('{} grep \'\' {}/{}.*'.format( output = self.target._execute_util(
self.target.busybox, 'cgroups_get_attributes {} {}'.format(
self.directory, self.directory, self.controller.kind))
self.controller.kind)) for res in output.splitlines():
for res in output.split('\n'):
if res.find(self.controller.kind) < 0:
continue
res = res.split('.')[1]
attr = res.split(':')[0] attr = res.split(':')[0]
value = res.split(':')[1] value = res.split(':')[1]
conf[attr] = value conf[attr] = value
@ -261,7 +257,7 @@ class CgroupsModule(Module):
def list_subsystems(self): def list_subsystems(self):
subsystems = [] subsystems = []
for line in self.target.execute('{} cat /proc/cgroups'\ for line in self.target.execute('{} cat /proc/cgroups'\
.format(self.target.busybox)).split('\n')[1:]: .format(self.target.busybox)).splitlines()[1:]:
line = line.strip() line = line.strip()
if not line or line.startswith('#'): if not line or line.startswith('#'):
continue continue