1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00
Commit Graph

194 Commits

Author SHA1 Message Date
Sergei Trofimov
8528568c1c gitignore update. 2016-12-07 18:13:55 +00:00
Sergei Trofimov
01253100cd doc: documeting connections 2016-12-07 18:13:55 +00:00
Sergei Trofimov
925fccb4f9 LocalConnection: remove unused timeout parameter
`timeout` parameter passed to LocalConnection gets assigned to an
instance variable, however it is not used for anything.
2016-12-07 18:13:55 +00:00
Sergei Trofimov
889f72c883 Adding connection classes to main __init__.py
Now that connection classes can be passed as arguments on Target
instatiation, they are part of the user-facing API and are marked as
such by exporting them in the main __init__.py
2016-12-07 18:13:55 +00:00
Sergei Trofimov
beaf8d48ac target: switching conn_cls to an __init__ parameter
conn_cls is no longer a class attribute and is specified on
instantiaation as well. This more flexible -- new connection types no
longer require a corresponding new Target subclass but can be used with
existing targets. This is also more consistent with how Platforms are
handled.
2016-12-07 18:13:55 +00:00
Sergei Trofimov
c35230890e AndroidTarget: removing unused parameter
external_storage_directory parmeter of __init__ was not being set is
entrirely used.
2016-12-07 18:13:55 +00:00
setrofim
689c478ca8 Merge pull request #79 from bjackman/cpuidle-additions
Cpuidle additions
2016-12-07 17:46:44 +00:00
Brendan Jackman
c9f7e0e066 cpuidle: Add docstrings for properties requiring units
Unit info from comments on `struct cpuidle_state` definition in
include/linux/cpuidle.h in Linux 4.9 source (see drivers/cpuidle/sysfs.c
for the code that exposes that data to userspace)
2016-12-07 17:44:55 +00:00
Brendan Jackman
7cc8675fa0 cpuidle: Add getter for target residency 2016-12-06 11:46:16 +00:00
setrofim
d1263567d0 Merge pull request #78 from derkling/cgroups-multi-controller
Cgroups multi controller
2016-11-29 13:17:19 +00:00
Sergei Trofimov
5d492ca957 utils/misc: Adding Kryo cores to CPU part map
Adding part IDs of Qualcomm Kryo Gold and Silver cores to the CPU part
map.
2016-11-29 13:11:04 +00:00
Patrick Bellasi
b569a561a4 cgroups: add support for multi-controller hierarchies
Some systems mount multiple CGroup controllers in the same hierarchy, this
happens in desktop systems using systemd but it's also the default for
systems using CGroups v2. Unfortunately the current CGroup modules can
mount only single-controller hierarchies, thus failing when a controller
is already mounted with others in a single hierarchy.

This patch fixes this issue by:
- keeping track of which controllers are mounted in each hierarchy
- muting hierarchies instead of controllers
- creating Controller objects which reference the hierarchy they belong to

Thus, the new constructor of the Controller object requires to specify
the hierarchy ID as well as the list of controller which have to be
mounted in that hierarchy. The hierarchy ID is used to create a single
mount point for all the controllers in that hierarchy. This single mount
points are now named:
  <CGMOUNT>/devlib_cgh<ID>
where "cgh" stands for "CGroup Hierarchy" and <ID> is the specified
numerical identified of that hierarchy.

This patch removes also the Controller::__new__() method, which seems not to
have sense anymore, as well as the Controller::probe() method, which is
not more used. Indeed, all and only the available hierarchies are pre-mounted
at module initialization time.



Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-11-29 10:39:28 +00:00
Patrick Bellasi
103f792736 cgroups: use subsystems namedtuple in the controllers mounting loop
This is just a simple re-factoring patch in preparation of the following
one. Since we have a list of CGroups subsystems, which includes the
hierarchy ID for each entry, let's use directly these namedtuples in the
mouting loop. The following patch will make use of the hierarchy ID to
properly mount each controller.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-11-29 10:13:01 +00:00
Patrick Bellasi
b2ec957bf8 shutils/cgroups: fix run_into support
In the previous patch:
  cgroups: Mount cgroups controllers in devlib working dir
we changed the default mount point for devlib managed CGroups but forgot to
update the support for execution of a workload within a specified CGroup.

The run_into support is provide by a shutil script, which still has hardcoded
the old path (i.e. /sys/fs/cgroup/devlib_*). This patch fixes this by:
- resetting the default path to the Linux standard /sys/fs/cgroup
- use-sing the existing CGMOUNT env variable to specify which CGroups mount
  point to use

The cgroups::run_into is also updated to use the self.cgroup_root via
CGMOUNT when the shutils' script is called.
Moreover, an additional cgroups::run_into_cmd method is added which just
returns a properly formatted run_into shutils' call.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2016-11-29 10:02:57 +00:00
setrofim
68f7585ac2 Merge pull request #77 from bjackman/cgroups-shutils-fix
shutils/cgroups: Don't fail when racing with process exit
2016-11-28 14:40:42 +00:00
Brendan Jackman
454a2d5db5 shutils/cgroups: Don't fail when racing with process exit
If a process is added to $PIDS but then exits before the
cgroups_task_move invokation finishes, then echoing its PID to
cgroups.procs results in an I/O error. If that process is the last in
$PIDS, then that failing echo command is the last of the function, so
the script exits with an error and devlib raises an exception.

Add `|| true` to avoid this problem.
2016-11-28 12:41:41 +00:00
setrofim
b35a283592 Merge pull request #73 from bjackman/file-exists-root
target: Use root in file_exists check
2016-11-28 12:22:37 +00:00
Brendan Jackman
c1b5152790 target: Use root in file_exists check
Use case: To check if a kernel supports function profiling we need to
check for the presence of
"/sys/kernel/debug/tracing/function_profiler_enabled", but
"/sys/kernel/debug/"'s permissions are 700.
2016-11-28 11:47:44 +00:00
setrofim
78ac92bd84 Merge pull request #66 from mdigiorgio/cpu_freq-trace-event
shutils.in: rename manually injected cpu_frequency trace event
2016-11-28 11:39:00 +00:00
setrofim
7949b93114 Merge pull request #71 from bjackman/master
target: Note return value in Target::invoke docstring
2016-11-28 11:31:58 +00:00
setrofim
bfdfc0e311 Merge pull request #72 from bjackman/adb-pull-whitespace
android: Fix whitespace in wildcard match for ADB pull
2016-11-28 11:30:57 +00:00
setrofim
6eabf7fc56 Merge pull request #76 from bjackman/cgroups-fixes
Fixes for cgroups
2016-11-28 11:27:32 +00:00
Brendan Jackman
ee38a4244a android: Fix whitespace in wildcard match for ADB pull
When there are multiple matches for the wildcard, the output has been
observed to have a space at the end. That means the pull command doesn't
work. This commit fixes that.
2016-11-25 18:29:59 +00:00
Brendan Jackman
0dc65bddb6 shutils/cgroups: Use busybox ps to fix output format
Different `ps` implementations (e.g. Android vs GNU) have different
default columns and process selections.
2016-11-25 18:11:23 +00:00
Brendan Jackman
3dd4ea69b4 cgroups: Remove quotes from grep expressions in move_all_tasks_to
These quotes end up being passed literally into the shutils function
arguments (i.e $3 is '-e', $4 is '"foo"') which means that the grep
command never finds matches. `exclude` is a list of comms, which don't
have spaces in them, so we can just remove the quotes.
2016-11-25 18:11:23 +00:00
Brendan Jackman
e45fcca385 shutils/cgroups: Fix typo 2016-11-25 18:11:23 +00:00
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
Brendan Jackman
27f545f3f6 target: Note return value in Target::invoke docstring 2016-11-15 16:58:57 +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
setrofim
02696e99e0 Merge pull request #68 from bjackman/cpuidle-trace-all
ftrace: Poke all CPUs before collecting trace
2016-11-08 17:19:02 +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
setrofim
df9b23aa4f Merge pull request #69 from marcbonnici/master
android: Fixed issue using single quoted command with adb_shell
2016-11-02 15:21:13 +00:00
Marc Bonnici
b59f7c360e android: Fixed issue using single quoted command with adb_shell
When using 'check_exit_code' and 'as_root' options for adb_shell with
a command containing single quotes, the provided command was escaped
twice which has now been avoided.
2016-11-02 14:36:03 +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
Michele Di Giorgio
d7f3092b46 shutils.in: rename manually injected cpu_frequency trace event
The injection of a fake cpu_frequency event in the trace may end up getting
interleaved with trace events generated by the cpufreq governor, for example:

  sh	     ... cpu_frequency: state=120000 cpu_id=0
  kschedfreq ... cpu_frequency: state=120000 cpu_id=0
  kschedfreq ... cpu_frequency: state=120000 cpu_id=1
  kschedfreq ... cpu_frequency: state=120000 cpu_id=2
  kschedfreq ... cpu_frequency: state=120000 cpu_id=3
  sh         ... cpu_frequency: state=120000 cpu_id=1
  sh         ... cpu_frequency: state=120000 cpu_id=2
  sh         ... cpu_frequency: state=120000 cpu_id=3

Such a trace may confuse trace parsers during postprocessing and lead to wrong
or no results.

This patch renames the events injected by devlib so that they can be easily
recognized and then used by the trace parser in the best way.

Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
2016-10-17 08:35:02 +01:00
setrofim
a89c3fb009 Merge pull request #65 from credp/more_android7_ls
Fix adb pull with wildcard on Android v7+
2016-10-14 14:44:51 +01:00
Chris Redpath
e8e945a700 Fix adb pull with wildcard on Android v7+
Similarly to other uses of ls, the change to multi-column default output
format has confused this API. Add in a similar routine to other objects
which use ls, so that we can try to figure out if we have a multi-column
default and control the output if so, or just use the plain command if
that doesn't work and hope it is still single column output.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
2016-10-14 14:35:58 +01:00
setrofim
934075c76c Merge pull request #64 from bjackman/memoize-cpuidle-info
cpuidle: Make desc, name, latency, power memoized properties
2016-10-13 10:20:17 +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
setrofim
1a47cadfa7 Merge pull request #63 from bjackman/get-domain-cpus
cpufreq: Add function to get CPUs in frequency domain
2016-10-12 08:29:14 +01:00
Brendan Jackman
f1b4bf2845 cpufreq: Add function to get CPUs in frequency domain 2016-10-11 20:40:10 +01:00
setrofim
25818b035e Merge pull request #62 from bjackman/check-governor-supported
cpufreq: Improve error when setting all CPUs to unsupported governor
2016-10-11 14:36:12 +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
setrofim
1cc6ddf140 Merge pull request #61 from credp/android_disconnect
android: don't try to disconnect devices which aren't connected
2016-10-07 08:24:11 +01:00
Chris Redpath
119fd7dc24 android: don't try to disconnect devices which aren't connected
If you try to disconnect a device and there are none, certain versions
of adb return 1, which leads to a TargetError and stops everything in
its tracks.

Try to mitigate this by checking if the device we want to disconnect is
connected before we make the disconnect call.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
2016-10-06 16:34:14 +01:00
Sergei Trofimov
cae239d1dc memoized: detect hashability by catching TypeError
This is a fix for

https://github.com/ARM-software/devlib/issues/60

Apprently, being an instance of Hashable does not mean that the object
is, in fact, hashable. So rather than testing for hashability, try to
hash the object and handle the potential error by falling back to the
old method.
2016-10-06 08:44:42 +01:00
Sergei Trofimov
09ec88e946 memoized: further fixes; hash objects whre possible
This is further to commit 6d854fd4dc

Due to the way certain objects are handled, getting the frist few bytes
of an object may not be enough (e.g. strings do not store their values
inline). To further mitigate the issue, hash the object where possible.
2016-10-04 17:57:46 +01:00
setrofim
f8440cf354 Merge pull request #59 from derkling/fix-ftrace
ftrace: ensure ftrace commands are executed as root
2016-09-28 08:20:10 +01:00
setrofim
46d65c8237 Merge pull request #58 from credp/android7_ls
AndroidTarget: Handle ls format change in Android 7.0
2016-09-27 16:28:32 +01:00