zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
9.92k stars 6.1k forks source link

subsys: samples: doc: arch: Make perf subsystem #72890

Open KushnerovMikhail opened 4 weeks ago

KushnerovMikhail commented 4 weeks ago

Add profiling util based on periodic stack unwinding. Perf from Linux was taken as a reference.

Code is based on Sampling profiler (#29304) by @Jongy.

The operation of module is based on frame pointer usage and saving registers during interruption handling by zephyr.

General work description: The unwinding function stay in timer as expiry function 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. Obtained samples can be translated into flamegraph using stackcollapse.py script.

Flame graph example, generated from echo_server sample:

graph

Kconfig optioins:

Kconfig requirements:

github-actions[bot] commented 4 weeks ago

Hello @KushnerovMikhail, and thank you very much for your first pull request to the Zephyr project! Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary. If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊