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

823 Commits

Author SHA1 Message Date
Marc Bonnici
5601fdb108 target.py: Track connected_as_root in the connection
Move from tracking of `connected_as_root` from the target to the
connection to allow it to perform it's own caching.
2019-09-11 10:46:00 +01:00
Marc Bonnici
4e36bad2ab target.py: Un-memoize the is_rooted property
Un-memoize the `is_rooted` property of the connection and perform our
own caching instead as the state can be changed depending on the
connection status.
2019-09-11 10:46:00 +01:00
Marc Bonnici
72e4443b7d AdbConnection: Enable adb_as_root as a connection parameter
To allow for connecting to an `AndroidTarget` as root before the target
has been initialised, allow for passing `adb_as_root` as a connection
parameter to the `AdbConnection`. This will restart `adbd` as root
before attempting to connect to the target and will restart as unrooted
once all connections to that target have been closed.
2019-09-11 10:46:00 +01:00
Marc Bonnici
9ddf763650 AdbConnection: Add adb rooting to the connection to allow tracking
Add a method to `AdbConnection` to control whether whether adb is
connected as root. This allows for the connection to track whether it is
connected as root for a particular device across all instances of a
connection.
2019-09-11 10:46:00 +01:00
Marc Bonnici
18830b74da SshConnection: Implement tracking of connected_as_root status
Improve the detection of being `connected_as_root` from comparing the
username to checking the actual id of the user and export this as a
property for the connection.
2019-09-11 10:46:00 +01:00
Marc Bonnici
66de30799b doc/connection: Update connection documentation 2019-09-11 10:46:00 +01:00
Sergei Trofimov
156915f26f cpuidle: fix exist() --> exists() typo. 2019-09-05 09:17:26 +01:00
Douglas RAILLARD
74edfcbe43 target: Fix quoting of PATH components
Make sure the components of PATH are properly quoted.
2019-09-04 16:09:06 +01:00
Douglas RAILLARD
aa62a52ee3 target: Make sure subprocesses of Target.execute() inherit PATH
Make sure that the subprocesses of the command that is spawned see the same
value of PATH env var, so that the tools installed by devlib are available from
scripts that could be started as well.
2019-09-04 16:09:06 +01:00
Douglas RAILLARD
9c86174ff5 target: Add Target.execute(force_locale='C') parameter
To avoid locale-specific variations in the output of commands, set LC_ALL=C by
default. This can be disabled by using None, or set to another locale.
2019-09-04 16:09:06 +01:00
Douglas RAILLARD
ea19235aed trace: dmesg: Add KernelLogEntry.from_dmesg_output() classmethod
Allow building a list of KernelLogEntry from a full dmesg output, in addition to
building just one entry using KernelLogEntry.from_str() .
2019-09-04 16:08:53 +01:00
Valentin Schneider
e1fb6cf911 module/cpufreq: Make use_governor() affect only online CPUs
Turns out you can't change cpufreq attributes on an offlined
CPU (no big surprise!), so use_governor() will fail if a whole
frequency domain has been hotplugged out.

Change the default behaviour to only target online CPUs.
2019-09-03 09:27:22 +01:00
Douglas RAILLARD
d9d187471f trace: dmesg: Ignore empty lines
dmesg output seems to sometimes include an empty line. Ignore them, so we don't
fail to match with the regexes.
2019-09-03 09:27:10 +01:00
Marc Bonnici
c944d34593 utils/android: Fix echoing of commands.
The fix in commit 964fde2 caused issues with certain command structures,
for example running in the background. To prevent this run the original
command as a subshell.
2019-08-14 07:46:50 +01:00
Marc Bonnici
964fde2fef utils/android: Echo the exit code of the actual command
When executing a command using `su`, the `echo` command was returning the
error code of the invocation of `su` rather than the command itself.
Usually `su` should mimic the return code of the command it is executing
however this is not always the case which can cause issues.
2019-08-09 16:18:25 +01:00
Douglas RAILLARD
988de69b61 target: Add Target.revertable_write_value()
Same as write_value(), but returns a context manager that will write
back the old value on exit.

Also add batch_revertable_write_value() that takes a list of kwargs
dict, and will call revertable_write_value() on each of them, returning
a single combined context manager.
2019-07-30 18:05:21 +01:00
Douglas RAILLARD
ded30eef00 misc: Add batch_contextmanager
Convenience wrapper around standard contextlib.ExitStack class.
2019-07-30 18:05:21 +01:00
Javi Merino
71bd8b10ed trace/systrace: make start() return when tracing has started
In SystraceCollector, start() returns after executing
subprocess.Popen() for systrace. That doesn't mean that systrace is
running though, the function can return even before systrace has had a
chance to execute anything. Therefore, when you run the command
you want to trace, systrace will miss the first seconds of the
execution.

Run systrace with -u to unbuffer its stdin and wait for it to print
"Starting tracing (stop with enter)" before returning.

Fixes #403
2019-07-30 15:07:28 +01:00
Marc Bonnici
986261bc7e utils/android: Move private method to end of class 2019-07-30 13:44:52 +01:00
Marc Bonnici
dc5f4c6b49 android/adb: Enable fall back for su command
Commit 89c40fb switched from using `echo CMD | su` to `su -c CMD`
however not all modern versions of `su` support this format.
Automatically try and detect if the new style is supported when
connecting and if not, fall back to the old implementation.
2019-07-30 13:44:52 +01:00
Marc Bonnici
88f8c9e9ac module/cpuidle: Add fallback for reading governor
As per #407 if the kernel is compiled with the ability to switch cpuidle
governors via sysfs `current_governor_ro` is replaced with
`current_governor` so check if the intial path exists before reading.
2019-07-30 09:52:34 +01:00
Marc Bonnici
0c434e8a1b setup.py: Remove Python2 as a supported version 2019-07-19 17:07:41 +01:00
Marc Bonnici
5848369846 Version Bump 2019-07-19 17:07:41 +01:00
Marc Bonnici
002ade33a8 Version Bump v1.1.2 2019-07-19 16:37:04 +01:00
Marc Bonnici
2e8d42db79 setup.py Update classifiers 2019-07-19 16:37:04 +01:00
Pierre-Clément Tosi
6b414cc291 utils.adb_shell: Move from 'echo CMD | su' to '-c'
Move from the current implementation (piping the command to su) which
has unexpected behaviours to the '-c' su flag (which then becomes
required).
2019-07-19 16:36:01 +01:00
Pierre-Clément Tosi
0d798f1c4f utils.adb_shell: Improve stability (Py3)
Move from pipes.quote (private) to shlex.quote (Py3.3+ standard).

Make tests of inputs against None (their default value) instead of based
on their truthiness.

Improve logging through quoted commands (runnable as-is, less confusing).

Make the command-building process straightforward for readability and
maintainability.
2019-07-19 16:36:01 +01:00
Marc Bonnici
1325e59b1a target/KernelConfig: Implement the __bool__ method
To aid in checking whether any information is contained in the
`KernelConfig` ensure that that `__bool__` method value indicated the
presence of parsed input.
2019-07-18 15:12:30 +01:00
Marc Bonnici
f141899dae target/KernelConfig: Ensure get_config_name is static
`get_config_name` was previsouly treaded as a bound method so
ensure that is defined as static as expected.
2019-07-18 15:12:30 +01:00
Valentin Schneider
984556bc8e module/sched: Make SchedModule probing more accurate
Right now, this module won't be loaded if the sched_domain procfs
entries are not present on the target. However, other pieces of
information may be present in which case it would make sense to load
the module.

For instance, mainline kernels compiled without SCHED_DEBUG can still
expose the cpu_capacity sysfs entry. As such, try to get a better idea
of what's available and only disable the loading of the module if it
can provide absolutely nothing.
2019-07-09 15:36:13 +01:00
Valentin Schneider
03a469fc38 module/sched: Expose the remote CPU capacity sysfs path
A later change needs to access this outside of a SchedModule instance,
so make the information available as a classmethod.
2019-07-09 15:36:13 +01:00
Valentin Schneider
2d86474682 module/sched: Expose a classmethod variant of SchedModule.has_debug
A later change needs to access this outside of a SchedModule instance,
so make the information available as a classmethod.
2019-07-09 15:36:13 +01:00
Valentin Schneider
ada318f27b module/sched: Fix None check
As mentioned in the previous commit, CPU numbers would be passed to
SchedProcFSData's __init__() (instead of a proper sysfs path). When
done with CPU0, that path would be evaluated as False and the code
would carry on with the default path, which was quite confusing.

This has now been fixed (and 0 isn't such a great path to give
anyway), nevertheless this check should just catter to None.
2019-07-09 15:36:13 +01:00
Valentin Schneider
b8f7b24790 module/sched: Fix incorrect SchedProcFSData usage
Rather than using the conveniently provided `get_cpu_sd_info()` helper
method, `has_em()` and `get_em_capacity()` would build a
`SchedProcFSData` with `path=<CPU number>`, which is obviously broken.

Do the right thing and use `get_cpu_sd_info()` in those places.
2019-07-09 15:36:13 +01:00
Josh Choo
a9b9938b0f module/sched: Return the correct maximum capacity
The existing behaviour assumes that the cap_states file contains a list
of capacity|cost pairs, and attempts to return the maximum capacity by
selecting the value at the second last index of the list.

This assumption fails on some newer Qualcomm kernels where the
cap_states file contains a list of capacity|frequency|cost triplets.
Consequently, the maximum frequency would be erroneously returned
instead of the maximum capacity.

Fix the problem by dynamically calculating the index of the maximum
capacity by dividing the number of entries in cap_states by the value in
nr_cap_states.

---

For example, on a certain Snapdragon 845 device:

/proc/sys/kernel/sched_domain/cpu0/domain0/group0/energy/cap_states
        54 entries:

        CAP     FREQ    COST
        --------------------
        65	300000	12
        87	403200	17
        104	480000	21
        125	576000	27
        141	652800	31
        162	748800	37
        179     825600	42
        195	902400	47
        212	979200	52
        228	1056000	57
        245	1132800	62
        266	1228800	70
        286	1324800 78
        307	1420800	89
        328	1516800	103
        348	1612800	122
        365	1689600	141
        381	1766400	160

/proc/sys/kernel/sched_domain/cpu0/domain0/group0/energy/nr_cap_states
        18

Max capacity = 381 (third-last index)
2019-07-09 09:04:34 +01:00
Marc Bonnici
f619f1dd07 setup.py: Set maximum package version for python2.7 support
In the latest versions of panadas and numpy python2.7 support has been
dropped therefore restrict the maximum version of these packages.
2019-07-08 13:46:19 +01:00
Marc Bonnici
ad350c9267 bin/perf: Update binaries
In the previous version there appears to be a bug causing perf to
segfault as per https://github.com/ARM-software/devlib/issues/395.
Therefore update provided binaries to v3.19 which does not appear to
have this issue.
2019-06-11 13:05:37 +01:00
Douglas RAILLARD
8343794d34 module/thermal: Gracefully handle unexpected sysfs names
Instead of raising an exception, log an warning and carry on.
2019-06-05 15:52:20 +01:00
Douglas RAILLARD
f2bc5dbc14 devlib: Re-export DmesgCollector in devlib package
Allow using 'import devlib.DmesgCollector', just like
devlib.FtraceCollector.
2019-06-03 14:16:28 +01:00
Patrick Bellasi
6f42f67e95 target: Ensure we use installed binaries
Apart from busybox, devlib itself makes use of other system provided binaries.
For example, the DmesgCollector module uses the system provided dmesg.
In cases the system provided binary does not support some of the features
required by devlib, we currently just fails with an error.

For the user it is still possible to deploy a custom/updated version of a
required binary via the Target::install API. However, that binary is not
automatically considered by devlib.

Let's ensure that all Target::execute commands use a PATH which gives priority
to devlib installed binaries.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2019-05-24 17:47:18 +01:00
Marc Bonnici
ae7f01fd19 target: Use root if available when determine number of cpus
On some targets some entries in `/sys/devices/system/cpu` require root
to list otherwise will return a permission error.
2019-05-24 11:18:54 +01:00
Pierre-Clément Tosi
b5f36610ad trace/perf: Soften POSIX signal for termination
Replace the default SIGKILL signal sent to perf to "request" its
termination by a SIGINT, allowing it to handle the signal by cleaning up
before exit. This should address issues regarding corrupted perf.data
output files.
2019-05-15 14:30:18 +01:00
Douglas RAILLARD
4c8f2430e2 trace: dmesg: Allow using old util-linux binary
Old util-linux binaries don't support --force-prefix. Multi-line entry
parsing will break on these, but at least we can collect the log.

Also decode the raw priority, so only the facility is not decoded in
case busybox or old util-linux is used.
2019-03-26 09:38:58 +00:00
Douglas RAILLARD
a8b6e56874 trace: dmesg: Call dmesg -c as root
Clearing the kernel ring buffer needs root permission.
2019-03-25 14:57:33 +00:00
Douglas RAILLARD
c92756d65a trace: Fix dmesg collector when using util-linux dmesg
Set missing "facility" attribute on DmesgCollector instances.
2019-03-25 14:57:33 +00:00
Douglas RAILLARD
8512f116fc trace: Add DmesgCollector
Allows collecting dmesg output and parses it for easy filtering.
2019-03-19 13:52:04 +00:00
Valentin Schneider
be8b87d559 module/sched: Fix/simplify procfs packing behaviour
Back when I first wrote this I tried to make something smart that
would automatically detect which procfs entries to pack into a
mapping, the condition to do so being "the entry ends with a
digit and there is another entry with the same name but a different
digit".

I wrongly assumed this would always work for the sched_domain entries,
but it's possible to have a domain with a single group and thus a
single "group0" entry.

Since we know which entries we want to pack, let's hard-code these and
be less smart about it.
2019-03-19 13:48:29 +00:00
Valentin Schneider
d76c2d63fe module/sched: Make get_capacities() work with hotplugged CPUs 2019-03-19 13:48:29 +00:00
Valentin Schneider
8bfa050226 module/sched: SchedProcFSData: Don't assume SD name is always present
The existence of that field is gated by SCHED_DEBUG, so look for an
always-present field instead.
2019-03-19 13:48:29 +00:00
Chris Redpath
8871fe3c25 devlib/sched: Change order of CPU capacity algorithms
There are two ways we can load CPU capacity. Up until 4.14, supported
kernels did not have the /sys/devices/system/cpu/cpuX/cpu_capacity file
and the only way to read cpu capacity was by grepping the EM from
procfs sched_domain output. After 4.14, that route still exists but is
complicated due to a change in the format once support for
frequency-power models was merged.

In order to avoid rewriting the procfs EM grepping code, lets switch the
order of algorithms we try to use when loading CPU capacity. All newer
kernels provide the dedicated sysfs node and all kernels which do not
have this node use the old format for the EM in sched_domain output.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
2019-03-18 14:29:38 +00:00