Android seems to have a buggy `mount` command which causes
`mount -o remount` to result in duplicated mounts. We can't unmonunt and
then re-mount /sys/fs/cgroup because there may be pre-existing mounts at
subdirectories. So we create a 'cgroups' directory in the devlib working
directory and mount cgroup controller FS's there.
Without this patch, this will result in an error due to trying to call
`.cgroup` on None. Making this a RuntimeError instaed means that a) you
get a more useful error message and b) you can catch the exception
without blanket `except Exception as e`.
On some systems CPUs sometimes remain idle for several seconds. If a
trace capture begins during one of these long idle periods, that CPU's
idle state is unknown (in practice it is probably in its deepest
available state from cpuidle's perspective but that can't be known for
sure).
The solution to the equivalent problem for cpufreq is to read the
current frequencies from sysfs and inject artificial cpu_frequency
events using trace_marker (see cpu_freq_trace_all_frequencies in
bin/scripts/shutils.in). However we can't read the current idle state
from sysfs.
Instead, wake up each CPU by executing the "true" command on it via
taskset.
Some systems mount CGroups RO, thus we need to ensure we remount that
FS as root otherwise we cannot create new groups.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
When this information is not needed, this avoids executing 4 commands on
the host for each CPU, which significantly speeds up initialising the
cpuidle module.
Currently when using set_all_governors to try to set an unsupported
governor, the error is a somewhat cryptic "sh: echo: I/O error". Add a
check that diagnoses this error.
In order to avoid slowing down the "good" path, the check for
unsupported governors is only done if the failure has already occured.
When passing an idle state ID to get_states(), nothing is returned. Also, there
is a wrong call to enable() in the method.
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
The cgroups module requires busybox and shutil to properly initialise.
This patch required the module to be initialized once the setup has
completed.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
In case a target does not report a configuration file, we can still check
the user-space API to verify it CGroups are supported.
NOTE: a rooted target is still a mandatory requirement because some commands
are still dependant on the possibility to run them with root permissions.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Certain commands requires in general root permissions to be properly
executed (for example on an Android target).
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
CGroups controller can be mounted by specifying a "noprefix" option,
in which case attribute names are named as:
<mountpoint>/<attribute_name>
instead of the (more recent) naming schema using:
<mountpoint>/<contoller_name>.<attribute_name>
For example, Android uses the old format for backward compatibility
with user-space. Thus, it's possible in general to work on a target
system where some controller are mounted "noprefix" while others not.
This patchset adds a set of updates which allows to use the proper
attributes naming schema based on how the controller has been mounted.
This patch makes use of the Controller::_noprefix option to properly
build the attribute path. It adds also a check which reports a more
clear error in case an attribute is set which is not provided by the
controller.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
CGroups controller can be mounted by specifying a "noprefix" option,
in which case attribute names are named as:
<mountpoint>/<attribute_name>
instead of the (more recent) naming schema using:
<mountpoint>/<contoller_name>.<attribute_name>
For example, Android uses the old format for backward compatibility
with user-space. Thus, it's possible in general to work on a target
system where some controller are mounted "noprefix" while others not.
This patchset adds a set of updates which allows to use the proper
attributes naming schema based on how the controller has been mounted.
This first patch keeps track of whatever a controller has been mounted
using the noprefix option.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This patch provides a couple of utility functions which makes it
easy to run a command under a specific CGroup or to move all tasks
from a group to another.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
The info statements are clobbering the "normal" output of devlib users.
This patch demote the logging to debug level. The user can still
log-report these information from the corresponding functions call site.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
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 patch adds a couple of shutils functions to efficiently read all
the frequencies/governors and returne them into a dictionary indexed by
CPU id.
The shutils functions are returning a line per each CPU that can be easily
converted into a dictionary in the host side.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This patch convert some functions to the usage of shutils provided calls.
This approach is more portable and allows to use these calls also on
an Android target.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Add a thermal module that will allow querying for thermal zones and trip
points in the target. The module allow supports enable/disabling thermal
zones as well as change trip temperatures.
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
This patch add a method which allows to inject into a trace a "cpu_frequency"
event for each CPU reporting the current frequency the CPU is running at.
Such a method could be useful to force report CPUs frequency into a trace
file, for example at tracing start and stop, thus allowing to know always
at which frequency an experiment has been executed.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Sometimes it could be required to change governor or frequency for a all the
online CPUs of a target. This patch provides an utility method to easily
do that using a single method call.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Sometimes it could be required to change the governor for a set of different
CPUs. This patch provides an utility method to easily and achieve that with
a single method call.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This patch refactors the CGroup module to support multiple controllers.
The new interface is based on two main classes:
.:: Controller(kind)
Provides a wrapper class for a CGgroup controller of "kind".
At module initialization time, all the controller available in the
system are enumerated and a corresponding controller class created.
A valid reference to the Controller class for a specific CGroup
controller can be obtained using the controller(kind) method exposed
by the module, e.g. to get a reference to the CPUSET controller:
cpuset = target.cgroups.controller('cpuset')
.:: CGroup(name)
Provides a wrapper class for a CGroup of "name", i.e. a folder which
path is "name" relative to the controller mount point.
At module initialization time, the root control group for each
controller is created by the controller class.
A valid reference to a CGroup for a specific controller can be
obtained using the cgroup(name) method exposed by the controller
object, e.g. to get a reference to the "/LITTLE" cgroup of the
cpuset controller:
cpuset_littles = cpuset.cgroup('/LITTLE')
The CGroup object exposes simple get()/set() methods which allows to
read and configure all the supported attributes of a controller.
For example, to set the "cpus" of a cpuset control group:
cpuset_littles.set(cpus=[0,1])
NOTE: the set() method accepts a variable list of parameters which name
must match a valid (writable) attribute for that controller.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
On some machines, when a different CPUFreq policy could be configured
for each CPU, there is not a top-level 'cpufreq' folder exposed
at top level but just per-CPU ones.
This patch makes the probing for CPUFreq support more robust by checking
on all the supported paths.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Recent Intel machines uses the CPUFreq pstate driver, which does not create
the standard "/sys/devices/system/cpu/cpufreq" folder usually created by
other (mostly ARM platform) drivers.
This patch fixes the probe method to check for the propert pstate driver
being available in order to enabled the CPUFreq module.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
In general it makes not sense to hotplug out all the CPUs of a system, thus
ususally CPU0 is configured as not hot/plugggable.
Definitively, on a single core system it does not make sense to hotpolug out
the only available CPU.
This patch switch to usage of CPU1 for hotplug support probing, which is the
really first one for which enabling hotplug could be useful.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>