Check if the frame is within the text address before saving
into the buffer, this eliminates the extra, uninitialized frame
at the end of the unwind.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Relocate stack unwind backends from `arch/` to perf's
`backends/` folder, just like logging/shell/..
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The timer & dwork can be statically initialized,
SYS_INIT is not strictly required.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Currently, the timer is stopped:
- in the timer handler, when the buffer is full, or
- in work handler, when time's up
In any cases, the work handler is bounded to run to print
the message, so we can kill the timer there instead.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Added:
- `clear` to discard the buffer without printing
- `info` to print info about the buffer and if the
profiler is running
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
"Perf is already running" works for `record` but is a little
strange when doing `printbuf`, so remove the "already" to
make it more universal.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The `buf_full` flag is set when it is full, but dumping the
buf currently only resets the `idx`, this means that the perf
command only works when the buffer hasn't been full before.
Reset the flag when we clear the buffer.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
`PERF_EVENT_TRACING_BUF_OVERFLOW` isn't used, remove it.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
`cmd_perf` isn't doing anything meaningful, remove it so that
the help message will be printed when invoked. Updated
the help message of the main command.
```
uart:~$ perf
perf - Lightweight profiler
Subcommands:
record : Start recording for <duration> ms on <frequency> Hz
Usage: record <duration> <frequency>
printbuf : Print the perf buffer
```
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
static perf_data is zero-initialized by default, there's no
need to explicitly set `idx` to `0`.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Clean up documentation pages for the new perf tool
as they contained several typos, grammar errors, and
duplicated content between main doc page and sample
page
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add profiling subsystem.
Add perf util based on periodic stack unwinding. Perf from Linux
was taken as a reference.
The operation of module is based on frame pointer usage and saving
registers during interruption handling.
The unwinding function stay in timer as expiry functioin so is called
during interruption handling. Thus the function have access to saved
registers (program counter and frame pointer in particular) of the current
thread and use it to unwind the thread stack.
Timer starting and results printing function are made as shell commands
for conveniency.
Originally-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
Signed-off-by: Mikhail Kushnerov <m.kushnerov@yadro.com>