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

cgroups: fix attributes reporting for controller with only one attribute

The current code used to read the attributes values for a controller uses
a "grep '' CONTROLLER.*" under the assumption that the output is a list of
   file:value
However, if there is a single controller attribute, grep does not report
the file name in output thus returning an empty list at the python side.

This patch fix that issue by also switching to the usage of a shutil
implementation of the attributes parsing code.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
Patrick Bellasi 2016-02-23 12:11:06 +00:00
parent 615f1ce5e8
commit a65ff13617
2 changed files with 21 additions and 8 deletions

View File

@ -55,6 +55,20 @@ ftrace_get_function_stats() {
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
################################################################################
@ -75,6 +89,9 @@ cpufreq_get_all_governors)
cpufreq_trace_all_frequencies)
cpufreq_trace_all_frequencies $*
;;
cgroups_get_attributes)
cgroups_get_attributes $*
;;
ftrace_get_function_stats)
ftrace_get_function_stats
;;

View File

@ -166,14 +166,10 @@ class CGroup(object):
self.controller.kind)
logging.debug(' %s',
self.directory)
output = self.target.execute('{} grep \'\' {}/{}.*'.format(
self.target.busybox,
self.directory,
self.controller.kind))
for res in output.split('\n'):
if res.find(self.controller.kind) < 0:
continue
res = res.split('.')[1]
output = self.target._execute_util(
'cgroups_get_attributes {} {}'.format(
self.directory, self.controller.kind))
for res in output.splitlines():
attr = res.split(':')[0]
value = res.split(':')[1]
conf[attr] = value