1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-10 14:01:53 +01:00
Commit Graph

38 Commits

Author SHA1 Message Date
Brendan Jackman
2f35999f37 cgroups: Mount cgroups controllers in devlib working dir
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.
2016-11-25 18:11:23 +00:00
Brendan Jackman
c89f712923 cgroups: Raise RuntimeError in freeze if no freezer controller
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`.
2016-11-25 18:10:06 +00:00
setrofim
290af6619d Merge pull request #70 from derkling/cgroups-fix-mount-rw
cgroups: ensure CGroups are mounted RW
2016-11-10 14:14:24 +00:00
Brendan Jackman
6cdae6bbe1 ftrace: Poke all CPUs for cpu_idle events before collecting trace
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.
2016-11-08 17:00:23 +00:00
Patrick Bellasi
da128f917b cgroups: ensure CGroups are mounted RW
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>
2016-10-28 18:54:10 +01:00
Brendan Jackman
d3a02d9d9e cpuidle: Make desc, name, latency, power memoized properties
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.
2016-10-12 18:31:12 +01:00
Brendan Jackman
f1b4bf2845 cpufreq: Add function to get CPUs in frequency domain 2016-10-11 20:40:10 +01:00
Brendan Jackman
af4214c3fb cpufreq: Improve error when setting all CPUs to unsupported governor
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.
2016-10-11 14:28:58 +01:00
Patrick Bellasi
730bb606b1 cgroup: fix documentation of freeze function
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-31 11:40:10 +01:00
Patrick Bellasi
c8f118da4f cgroups: change log level to avoid cluttering caller output
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-31 11:39:33 +01:00
Patrick Bellasi
23ad61fcae cgroups: add support for tasks freezing
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-26 18:27:08 +01:00
Patrick Bellasi
75a086d77a cgroups: add support for CPUs isolation
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-26 18:27:08 +01:00
Patrick Bellasi
21d18f8b78 cgroups: fix support to filter tasks to move into a specified CGroup
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-26 18:20:11 +01:00
Patrick Bellasi
3cab786d03 cgroups: use shutils for move_tasks
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-26 18:17:32 +01:00
Patrick Bellasi
d8ae3aba1a cgroups: add couple of methods to return the tasks of a CGroup
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-26 18:17:32 +01:00
Patrick Bellasi
42efd0a2e2 cgroups: add support list tasks in a specified CGroup
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-08-26 18:15:41 +01:00
Michele Di Giorgio
f9cb932d9c cgroups: fix get_states() return value when passing integer state
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>
2016-08-01 10:41:38 +01:00
Patrick Bellasi
616f229949 cgroups: requires initialization after the "setup" stage
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>
2016-05-13 18:17:22 +01:00
Patrick Bellasi
4b58c573a5 cgroups: make probe method more robust
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>
2016-04-26 16:38:30 +01:00
Patrick Bellasi
3acf5d56df cgroups: run some commands with root permissions
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>
2016-04-26 16:38:30 +01:00
Patrick Bellasi
658005a178 cgroups: properly format attributes path and check for being supported
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>
2016-04-26 16:38:25 +01:00
Patrick Bellasi
15f9c03b45 cgroups: keep track if a controller is mounted with noprefix option
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>
2016-04-26 16:38:21 +01:00
Patrick Bellasi
28739397c0 cgroups: add a couple of functions to move tasks among groups
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>
2016-04-22 11:43:49 +01:00
Patrick Bellasi
7112cfef3a cgroup: demote info logging statement
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>
2016-02-25 18:47:39 +00:00
Patrick Bellasi
e2e5e687e9 cgroups: use splitlines instead of split('\n')
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-02-24 11:22:48 +00:00
Patrick Bellasi
a65ff13617 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>
2016-02-24 11:22:48 +00:00
Patrick Bellasi
51b7f01d36 cpufreq: add functions to get frequencies and governors for all online CPUs
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>
2016-01-26 15:58:41 +00:00
Patrick Bellasi
cf761317bd cpufreq: switch to usage of shutils functions
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>
2016-01-26 15:58:41 +00:00
Punit Agrawal
c7fc01c6b5 module: Add thermal support
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>
2015-11-24 11:43:05 +00:00
Patrick Bellasi
701e6adf7a cpufreq: add method to trace current frequencies
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>
2015-11-16 17:47:58 +00:00
setrofim
f46057f836 Merge pull request #3 from derkling/drk-for-master
Fixes and additions for master
2015-11-13 08:24:09 +00:00
Patrick Bellasi
b598b38f12 cpufreq: add methods to configure all CPUs at once
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>
2015-11-12 19:35:25 +00:00
Patrick Bellasi
4dcb4974e5 cpufreq: add methods to set the governor for a specified set of CPUs
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>
2015-11-12 19:35:25 +00:00
Patrick Bellasi
9c9a74826a cgroups: big refactoring to make it more generic
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>
2015-11-12 19:20:09 +00:00
Patrick Bellasi
cbe80da3a1 cpufreq: make probing more robust
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>
2015-10-12 18:35:29 +01:00
Patrick Bellasi
b19d76d4b0 cpufreq: fix probe method to support Intel machine
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>
2015-10-12 18:35:29 +01:00
Patrick Bellasi
7ba791b2a7 hotplug: make hotplug probing more robust
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>
2015-10-12 18:35:29 +01:00
Sergei Trofimov
4e6afe960b devlib initial commit. 2015-10-09 09:30:04 +01:00