The docstring of Controller.move_all_tasks_to() says that the function
moves all the tasks to the "dest" cgroup. However, it iterates over
self._cgroups, which is a dictionary that is lazily populated when you
call Controller.cgroup(). For example, this doesn't work:
cpuset_cg = target.cgroups.controller("cpuset")
cpuset_cg.move_all_tasks_to("top-app")
Because you haven't populated self._cgroups yet. You need to manually
populate the dictionary with something like:
for group in cpuset_cg.list_all():
cpuset_cg.cgroup(group)
before you can use move_all_tasks_to(). Iterate through
self.list_all() instead of self._cgroups to really move all tasks to
to the destination directory.
Controller.move_tasks() has a try-except block to get the cgroups of
the source and destination groups. Controller.cgroup() caches the
groups in self._cgroups and populates it if it hasn't been already.
Simplify move_tasks() and let it deal with source and dest cgroups
that exist but the controller hasn't loaded yet.
Not all devices have the `saved_cmdlines_size` node exposed and therefore
attempting to set this can fail. Raise an error for this only when
`strict` is set to `True` otherwise raise a warning instead.
Emit one warning message or one exception referring to the whole list of
unavailable events, rather than spreading it through multiple calls. In strict
mode, this allows the user to fix the whole list of bogus events at once rather
than incrementally.
Signed-off-by: Douglas RAILLARD <douglas.raillard@arm.com>
"function_graph" tracer allows getting funcgraph_entry/funcgraph_exit events for
listed functions. This allows getting precise information on when a given
function was called, and how long its execution took (to build a time-based
heatmap for example).
This can be enabled using:
FtraceCollector(target, functions=['foo', 'bar'], tracer='function_graph')
If needed, children functions can also be traced with
trace_children_functions=True .
Signed-off-by: Douglas RAILLARD <douglas.raillard@arm.com>
While tracing, ftrace records a mapping of PIDs to cmdlines. By default, it will
only record up to 128 such entries, which is not enough for a typical android
system. The consequence is trace-cmd reporting "<...>" as cmdline.
Allow setting that number to a higher value, and default to a comfortable 4096
entries.
Signed-off-by: Douglas RAILLARD <douglas.raillard@arm.com>
trace-cmd start -C <clock> allows selecting the ftrace clock. Expose that in
FtraceCollector API.
Signed-off-by: Douglas RAILLARD <douglas.raillard@arm.com>
On newer devices dumpsys output is more explanatory and does not only
contain numerical data. Update the parser to ignore non numerical
data for example the arguments that were passed and section headers.
As of commit 5601fdb1085af2eccf16a84b48c9995699bb8489 the
`connected_as_root` status is tracked in the connection. Add missing
implementation to `LocalConnection`.
A `Target` should be independent of the connection type used however we
do have some adb specific functionality as part of the `Target` for
speed/compatibility reasons. For the cases that we can perform the
operation in a connection agnostic method add alternative implementation
and for those raise a error to inform the user of the issue.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.