Skip to content

Commit 3735ae9

Browse files
kartbenfabiobaltieri
authored andcommitted
profiling: doc: clean up grammar/spelling
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é <[email protected]>
1 parent 420f230 commit 3735ae9

File tree

3 files changed

+57
-107
lines changed

3 files changed

+57
-107
lines changed

doc/services/profiling/perf.rst

Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,38 @@
11
.. _profiling-perf:
22

3-
43
Perf
54
####
65

6+
Perf is a profiler tool based on stack tracing. It can be used for lightweight profiling
7+
with minimal code overhead.
78

8-
Perf is a profiler tool, based on stack tracing. It can be used to light weight profiling
9-
almost without any code overhead.
10-
11-
Work principe
12-
*************
9+
Work Principle
10+
**************
1311

14-
``perf record`` shell-command starts timer with perf tracer function.
15-
Timers are driven by inerrupts, so perf tracer function is calling during interruption.
16-
Zephyr core save return address and frame pointer in interrupt stack or ``callee_saved``
17-
struture before caling interrupt hundler. So perf trace function makes stack traces by
18-
using return address and frame pointer.
12+
The ``perf record`` shell command starts a timer with the perf tracer function.
13+
Timers are driven by interrupts, so the perf tracer function is called during an interruption.
14+
The Zephyr core saves the return address and frame pointer in the interrupt stack or ``callee_saved``
15+
structure before calling the interrupt handler. Thus, the perf trace function makes stack traces by
16+
using the return address and frame pointer.
1917

20-
Then stackcollapse.py script convert return addresses in stack trace to function names
21-
by elf file and print them in required for FlameGraph format.
18+
The :zephyr_file:`scripts/profiling/stackcollapse.py` script can be used to convert return addresses
19+
in the stack trace to function names using symbols from the ELF file, and to prints them in the
20+
format expected by `FlameGraph`_.
2221

2322
Configuration
2423
*************
2524

26-
Configure this module using the following options.
25+
You can configure this module using the following options:
2726

28-
* :kconfig:option:`CONFIG_PROFILING_PERF`: enable the module. This opion add
29-
perf command in shell.
27+
* :kconfig:option:`CONFIG_PROFILING_PERF`: Enables the module. This option adds
28+
the ``perf`` command to the shell.
3029

31-
* :kconfig:option:`CONFIG_PROFILING_PERF_BUFFER_SIZE`: sets size of perf buffer,
30+
* :kconfig:option:`CONFIG_PROFILING_PERF_BUFFER_SIZE`: Sets the size of the perf buffer
3231
where samples are saved before printing.
3332

3433
Usage
3534
*****
3635

37-
More specific example can be found in :zephyr:code-sample:`profiling-perf`.
38-
39-
#. Build with perf enabled and run.
40-
41-
#. Begin perf sampling by shell-command
42-
43-
.. code-block:: text
44-
45-
perf record <period> <frequency>
46-
47-
This command will start timer with perf sampler for *period* in seconds and
48-
with *frequency* in hertz.
49-
50-
Wait for the completion message ``perf done!`` or ``perf buf override!``
51-
(if perf buffer size is smaller than required).
52-
53-
#. Print made by perf samles in terminal by shell-command
54-
55-
.. code-block:: text
56-
57-
perf printbuf
58-
59-
Output exaple:
60-
61-
.. code-block:: text
62-
63-
Perf buf length 1985
64-
0000000000000004
65-
0000000080004e58
66-
00000000800071ca
67-
0000000080000964
68-
aaaaaaaaaaaaaaaa
69-
0000000000000002
70-
....
71-
00000000800163e0
72-
73-
Copy gotten output in some file, for example *perf_buf*.
74-
75-
#. Translate perf samples by stackcollapse script to format, required by FlameGraph
76-
77-
.. code-block:: bash
78-
79-
python zephyr/scripts/perf/stackcollapse.py perf_buf <build_dir>/zephyr/zephyr.elf > perf_buf.folded
80-
81-
And turn into .svg FlameGraph (for example *graph.svg*)
82-
83-
.. code-block:: bash
84-
85-
./FlameGraph/flamegraph.pl perf_buf.folded > graph.svg
86-
87-
All this step can be done by one command
88-
89-
.. code-block:: bash
36+
Refer to the :zephyr:code-sample:`profiling-perf` sample for an example of how to use the perf tool.
9037

91-
python zephyr/scripts/perf/stackcollapse.py perf_buf <build_dir>/zephyr/zephyr.elf | ./FlameGraph/flamegraph.pl > graph.svg
38+
.. _FlameGraph: https://github.com/brendangregg/FlameGraph/

samples/subsys/profiling/perf/README.rst

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,70 @@
33

44
Send perf samples to the host with console support
55

6-
This application can be used to demonstrate :ref:`profiling-perf` work.
6+
This application can be used to understand how to use the :ref:`profiling-perf`
7+
tool.
78

89
Requirements
910
************
1011

11-
Perf tool so far implemente only for riscv and x86_64 architectures.
12+
The Perf tool is currently implemented only for RISC-V and x86_64 architectures.
1213

1314
Usage example
1415
*************
1516

16-
Build an image with:
17+
* Build and run the sample with:
1718

18-
.. zephyr-app-commands::
19-
:zephyr-app: samples/subsys/profiling/perf
20-
:board: qemu_riscv64
21-
:goals: build
22-
:compact:
19+
.. zephyr-app-commands::
20+
:zephyr-app: samples/subsys/profiling/perf
21+
:board: qemu_riscv64
22+
:goals: run
23+
:compact:
2324

24-
After the sample starts, enter shell command:
25+
* After the sample has started, enter the shell command:
2526

26-
.. code-block:: console
27+
.. code-block:: console
2728
28-
uart:~$ perf record <period> <frequency>
29+
uart:~$ perf record <duration> <frequency>
2930
30-
Wait for the completion message ``perf done!`` or ``perf buf override!``
31-
(if perf buffer size is smaller than required).
31+
This command will start a timer for *duration* milliseconds at *frequency* Hz.
3232

33-
Print made by perf samles in terminal by shell-command:
33+
* Wait for the completion message ``perf done!``, or ``perf buf override!`` if
34+
the perf buffer size is smaller than required.
3435

35-
.. code-block:: console
36+
* Print the samples captured by perf in the terminal with the shell command:
3637

37-
uart:~$ perf printbuf
38+
.. code-block:: console
3839
39-
Output exaple:
40+
uart:~$ perf printbuf
4041
41-
.. code-block:: console
42+
The output should be similar to:
4243

43-
Perf buf length 2046
44-
0000000000000004
45-
00000000001056b2
46-
0000000000108192
47-
000000000010052f
48-
0000000000000000
49-
....
50-
000000000010052f
51-
0000000000000000
44+
.. code-block:: console
5245
53-
Copy gotten output in some file, for example *perf_buf*.
46+
Perf buf length 2046
47+
0000000000000004
48+
00000000001056b2
49+
0000000000108192
50+
000000000010052f
51+
0000000000000000
52+
....
53+
000000000010052f
54+
0000000000000000
5455
55-
Make graph.svg with :zephyr_file:`scripts/perf/stackcollapse.py` and
56-
`FlameGraph`_:
56+
* Copy the output into a file, for example :file:`perf_buf`.
5757

58-
.. _FlameGraph: https://github.com/brendangregg/FlameGraph/
58+
* Generate :file:`graph.svg` with
59+
:zephyr_file:`scripts/profiling/stackcollapse.py` and `FlameGraph`_:
5960

60-
.. code-block:: shell
61+
.. _FlameGraph: https://github.com/brendangregg/FlameGraph/
6162

62-
python scripts/perf/stackcollapse.py perf_buf build/zephyr/zephyr.elf | <flamegraph_dir_path>/flamegraph.pl > graph.svg
63+
.. code-block:: shell
64+
65+
python scripts/perf/stackcollapse.py perf_buf build/zephyr/zephyr.elf | <flamegraph_dir_path>/flamegraph.pl > graph.svg
6366
6467
Graph example
6568
=============
6669

6770
.. image:: images/graph_example.svg
68-
:align: center
69-
:alt: graph example
71+
:align: center
72+
:alt: graph example

subsys/profiling/perf/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ config PROFILING_PERF_BUFFER_SIZE
1818
int "Perf buffer size"
1919
default 2048
2020
help
21-
Size of buffer, that used by perf to save samples from stack tracing.
21+
Size of buffer used by perf to save stack trace samples.
2222

2323
endif

0 commit comments

Comments
 (0)