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

38 Commits

Author SHA1 Message Date
Ola Olsson
8247ac91e7 Add option not to validate PMU counters.
The validation call can take a long for targets where PLL:s have
been clocked down, such as FPGAs.
2024-03-28 20:03:53 -05:00
Metin Kaya
38d8053f2f devlib: Remove unused imports
Also import 'warnings' before 'wrapt' module to address a pylint
warning.

Signed-off-by: Metin Kaya <metin.kaya@arm.com>
2024-01-23 06:51:59 -08:00
Douglas Raillard
416e8ac40f devlib: Remove Python 2 dead code
Remove code that was used for Python 2 only.
2024-01-09 12:07:57 -08:00
Douglas Raillard
d7d1deedda collector/dmesg: Query systcl kernel.dmesg_restrict
Query systcl instead of checking CONFIG_SECURITY_DMESG_RESTRICT as that
option only provides a default value for the sysctl parameter.

Fixes https://github.com/ARM-software/devlib/issues/653
2023-11-06 08:57:13 -08:00
Christian Loehle
9199d8884e ftrace: Do not read-verify buffer_size_kb value
The sysfs documentation mentions that the value written
to buffer_size_kb ftrace field may be rounded up.
So skip the verify loop on this field.

The case we are worried about, a requested buffer
size that the target cannot fulfill is caught anyway,
as the sysfs write returns with an error that is caught.

Signed-off-by: Christian Loehle <christian.loehle@arm.com>
2023-09-21 08:54:50 -07:00
Douglas Raillard
14bb86efad collector/perfetto: Use busybox cat
Use busybox cat instead of system's cat.
2023-09-12 17:04:26 -05:00
Kajetan Puchalski
9b15807c17 collector: Add PerfettoCollector
Add a Collector for accessing Google's Perfetto tracing infrastructure.
The Collector takes a path to an on-device config file, starts tracing
in the background using the perfetto binary and then stops by killing
the tracing process.

Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
2023-09-06 16:48:56 -05:00
Kajetan Puchalski
6b09571859 ftrace: Separate top_buffer_size from buffer_size
Since we now set the top buffer size to be the same as the devlib buffer
size, this effectively halves the maximum available buffer size that can
be set while using devlib. Whatever size is passed as `buffer_size` will
be allocated twice, even if the top buffer is hardly used at all.

This commit separates them into `buffer_size` and `top_buffer_size`. If
the latter is not passed, the behaviour will not change compared to now.

Fixes: e0c53d09990b5501e493d048a5dce067d8990281
Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
2023-08-15 17:47:10 -05:00
Douglas Raillard
cf4d3b5f4c collector/dmesg: Avoid unnecessary dmesg command
Only run the minimal amount of commands, as executing a command can be
costly.

In the sequence reset() -> start(), we only need to get the output of
dmesg upon start() to know what part of the log will be ignored
(everything before the call to start()). There is no need to perform
that upon reset() since the sequence:

    reset() -> start() -> stop() -> start() -> stop()
               \______1________/    \______2________/

is anyway equivalent to:

    reset() -> start() -> stop()
               \______2________/

So reset() can essentially be a no-op and the actual reset logic lives
in start().
2023-08-09 16:39:21 -05:00
Douglas Raillard
e0c53d0999 ftrace: Set top-level buffer size
trace-cmd start -B devlib -b 42 will set the buffer size for the
"devlib" ftrace instance but will not set the buffer size of the
top-level buffer.

Unfortunately, some events still end up in the top-level buffer
regardless of any configuration such as the "print" event. This can lead
to lost events because the buffer size was too small.

Avoid that by using the buffer size for both top-level and devlib's
instance.
2023-04-18 18:12:26 -05:00
Douglas Raillard
4b13ee79eb ftrace: Avoid repeated available events query
FtraceCollector.available_events is not memoized anymore as the set of
events supported by the target can change dynamically (e.g. loading a
kernel module).

This means that calling self.available_events is somewhat expensive, so
avoid doing it in a loop. Instead, save the events in a variable and
reuse it in the function to save a substantial amount of time.
2023-04-06 11:05:04 -05:00
Douglas Raillard
fade6b4247 ftrace: Fix use of named buffer
trace-cmd extract needs -B devlib to be passed, otherwise an empty
buffer will be extracted.
2023-03-13 14:10:17 -05:00
Douglas Raillard
3d2cdd99c5 ftrace: Use named ftrace buffer
Use a buffer named "devlib" instead of using the top-level default
buffer. That will improve interop with other tools trying to collect a
trace at the same time as devlib.
2023-02-03 12:04:51 +00:00
Douglas Raillard
93ada9762d devlib: Remove "future"
Remove the "future" dependency as devlib does not support Python 2
anymore.

Also remove the "from __future__ import division" as this is the default
in Python 3.
2023-01-19 11:38:11 +00:00
setrofim
111aa327ce Import quote() form shlex rather than pipes
pipes module is deprecated since 3.11, and quote() has been available in
shlex since 3.3.
2022-11-24 10:55:22 +00:00
Douglas Raillard
2c4b16f280 devlib: Use async Target API
Make use of the new async API to speedup other parts of devlib.
2022-07-28 14:40:15 +01:00
Douglas Raillard
a9fcc75f60 collector/dmesg: Fix dmesg_out property
When no entry has been recorded by the collector, return an empty string
rather than returning the full dmesg log.

Also fix get_data() that would fail try to add None + '\n' if dmesg_out
property returns None.
2022-05-18 15:21:18 +01:00
Douglas Raillard
e0abb9db48 collector/dmesg.py: Allow nesting DmesgCollector
Rather than systematically clearing the buffer on reset(), record the
timestamp of the last entry and use it to filter-out old entries in
DmesgCollector.entries property.

This also allows detecting if the ring buffer has ran out of memory, or
if something has cleared the buffer while collecting, leading to missing
entries.
2022-04-29 13:59:24 +01:00
Douglas Raillard
bdb04aa8d0 ftrace: Detect tracefs mount point
Change default FtraceCollector(tracing_path=...) to None, and
auto-detect mount point when None is given.

Also expose an FtraceCollector.find_tracing_path() method so that user
code can also access this path without having to instantiate an
FtraceCollector.
2022-04-22 18:29:53 +01:00
Douglas Raillard
b4c76007c8 ftrace: Do not memoize FtraceCollector.available_events
ftrace events can be added and removed dynamically by kernel modules, so
they cannot be memoized.
2021-10-27 11:56:23 +01:00
Douglas Raillard
917800ffa6 collector: ftrace: Use trace-cmd start --cmdlines-size
Use --cmdlines-size option rather than setting the file manually.
2021-09-01 17:38:49 +01:00
Douglas Raillard
5671b49c2f collector: ftrace: Use trace-cmd start -C
Use -C to set the clock rather than writing manually to the file.
2021-09-01 17:38:49 +01:00
Douglas Raillard
27616813ea collector: ftrace: Use trace-cmd start -b
Avoid manually setting the buffer size since trace-cmd start can do it
directly.
2021-09-01 17:38:49 +01:00
Javi Merino
34e51e7230 collector/perf: raise an error if report_options or report_sample_options are specified when not using perf/simpleperf record 2021-04-27 10:40:06 +01:00
douglas-raillard-arm
b6d1863e77 collector/dmesg: DmesgCollector: Avoid not rooted targets
Fail early if the target is not rooted, as root is required by
DmesgCollector.start() anyway.
2021-04-07 10:55:27 +01:00
Robert Freeman
fe2fe3ae04 collector/perf: run simpleperf report-sample in the target if requested
If simpleperf record is called with "-f N", we may want to run
"simpleperf report-sample" on the output to dump the periodic
records.  Let the PerfCollector() run report-sample in the target,
similar to how we run report.
2021-03-31 10:03:33 +01:00
Robert Freeman
4859e818fb collector/perf: Only kill sleep if running perf stat
The stop() command of the PerfCollector kills all sleep commands in
the target, saying "We hope that no other important sleep is
on-going".  This is only needed if we are running "perf stat",
simpleperf does not need this.  Background the
perf/simpleperf command and only kill all sleeps in that specific case.
2021-03-31 10:03:33 +01:00
douglas-raillard-arm
552040f390 devlib/collector/dmesg: handle CONFIG_SECURITY_DMESG_RESTRICT
Some kernels compiled with CONFIG_SECURITY_DMESG_RESTRICT can restrict
reading the dmesg buffer to root user as a security hardening measure.
Detect this case and use root accordingly.
2021-02-12 12:11:07 +00:00
Javi Merino
0d259be01b collector/perf: Run perf as root if the target is rooted
If you want to collect events by event id (eg. in simpleperf, "rNNN"
with NNN a number), you must run it as root.  Otherwise, simpleperf
fails with a SIGABRT.

Run simpleperf as root by default if the target is rooted to avoid
this.
2021-02-02 11:30:09 +00:00
Marc Bonnici
3cb2793e51 collector/serial_trace: Ensure log is opened in binary mode 2020-06-24 17:16:11 +01:00
Marc Bonnici
1ad2e895b3 collector/serial_trace: Fix typo 2020-06-24 17:16:11 +01:00
Javi Merino
569e4bd057 LogcatCollector: Learn to pass format to logcat
logcat -v lets you specify the format for the logcat output.  Add a
parameter to the LogcatCollector to allow us to pass that information
down to the logcat invocation.
2020-05-15 14:52:26 +01:00
Marc Bonnici
a4f9231707 collector/perf: Disable pager for perf event list.
Pipe the list of perf events via cat to ensure that a pager is not
used to display the output as this can cause some systems to hang
waiting for user input.
2020-05-12 10:25:46 +01:00
Ambroise Vincent
0465a75c56 devlib/trace/ftrace.py: Fix reset and stop states
A system with function_profile_enabled set to 1 prevents using
function_graph.

Using nop tracer left the tracing files in a dirty state.
2020-01-07 14:14:38 +00:00
Marc Bonnici
cf8ebf6668 devlib/collector: Update Collectors to implement collector interface 2019-12-20 15:16:32 +00:00
Marc Bonnici
15a77a841d collector/screencapture: Refactor to use new collector interface
Update the interface to make use of the collector interface.
Notable changes are the removal of the `output_path` path provided on
initialisation which will now be provided by the dedicated `set_output`
method.
2019-12-20 15:16:32 +00:00
Marc Bonnici
9bf9f2dd1b collector: Update the Collector Interface
Update `get_trace` to `get_data` to better reflect the purpose.
The return type of said method will be a `CollectorOutput` object will
contain one or more `CollectorOutputEntry` objects which will be used to
provide the `path`and `path_kind` attributes to indicate the path to the
obtained output and it's type (currently a "file" or "directory")
respectively.
2019-12-20 15:16:32 +00:00
Marc Bonnici
19887de71e devlib/trace: Refactor trace to be collector
We now have have multiple `trace` instruments that do not match the
description and therefore are moved to have a more suitably named
hierarchy.
2019-12-20 15:16:32 +00:00