<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/tools/proftool.c, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<entry>
<title>tools: proftool: Fix potential memory leaks</title>
<updated>2025-02-11T14:17:23+00:00</updated>
<author>
<name>Maks Mishin</name>
<email>maks.mishinfz@gmail.com</email>
</author>
<published>2025-02-05T16:26:07+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=4e18b47c73cdffb1dbd9ea196aeaff20e5030ade'/>
<id>4e18b47c73cdffb1dbd9ea196aeaff20e5030ade</id>
<content type='text'>
Dynamic memory, referenced by 'line', is allocated by calling
function 'calloc' and lost when the function terminates with code -1.

Signed-off-by: Maks Mishin &lt;maks.mishinFZ@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Dynamic memory, referenced by 'line', is allocated by calling
function 'calloc' and lost when the function terminates with code -1.

Signed-off-by: Maks Mishin &lt;maks.mishinFZ@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: proftool: dump-ftrace should write funcgraph times in ns not us</title>
<updated>2025-01-01T01:00:37+00:00</updated>
<author>
<name>Jerome Forissier</name>
<email>jerome.forissier@linaro.org</email>
</author>
<published>2024-12-06T10:11:31+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=788b4609dbbbf1e058836b42967e58ffcbdc3bb1'/>
<id>788b4609dbbbf1e058836b42967e58ffcbdc3bb1</id>
<content type='text'>
When converting a U-Boot trace records file to ftrace function graph
format for use by trace-cmd ('proftool -f funcgraph dump-ftrace'), the
time associated to each function is incorrectly saved in microseconds
instead of nanoseconds. Multuply the value by 1000 to fix the issue.

With this change, the trace-cmd output looks consistent. Here is an
example with udelay(25) added to mem_malloc_init() as a test case:

 $ ./tools/proftool -m System.map -t /tmp/trace.bin -f funcgraph \
                    dump-ftrace -o /tmp/trace.dat
 $ trace-cmd report  /tmp/trace.dat &gt;/tmp/trace.log
 $ vi /tmp/trace.log
 [...]
 u-boot-1     [000]     6.719659: funcgraph_entry:                   |    mem_malloc_init() {
 u-boot-1     [000]     6.719659: funcgraph_entry:                   |      udelay() {
 u-boot-1     [000]     6.719660: funcgraph_entry:                   |        schedule() {
 u-boot-1     [000]     6.719660: funcgraph_entry:                   |          cyclic_run() {
 u-boot-1     [000]     6.719660: funcgraph_entry:        1.000 us   |            cyclic_get_list();
 u-boot-1     [000]     6.719661: funcgraph_exit:         1.000 us   |            }
 u-boot-1     [000]     6.719661: funcgraph_exit:         1.000 us   |          }
 u-boot-1     [000]     6.719661: funcgraph_entry:                   |        __udelay() {
 u-boot-1     [000]     6.719662: funcgraph_entry:        0.000 us   |          usec_to_tick();
 u-boot-1     [000]     6.719687: funcgraph_exit:       + 26.000 us  |          }
 u-boot-1     [000]     6.719687: funcgraph_exit:       + 28.000 us  |        }
 u-boot-1     [000]     6.719687: funcgraph_entry:      # 37971.000 us |      memset();
 u-boot-1     [000]     6.757658: funcgraph_exit:       # 37999.000 us |      }
 u-boot-1     [000]     6.757658: funcgraph_exit:       # 38000.000 us |    }

In the above dump, the udelay() call is reported as taking 26 us which
is consistent with the timestamps (6.719687 - 6.719659 = 0.000026).
Without this patch we would have "0.026 us" instead of "+ 26.000 us".

Signed-off-by: Jerome Forissier &lt;jerome.forissier@linaro.org&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Reviewed-by: Ilias Apalodimas &lt;ilias.apalodimas@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When converting a U-Boot trace records file to ftrace function graph
format for use by trace-cmd ('proftool -f funcgraph dump-ftrace'), the
time associated to each function is incorrectly saved in microseconds
instead of nanoseconds. Multuply the value by 1000 to fix the issue.

With this change, the trace-cmd output looks consistent. Here is an
example with udelay(25) added to mem_malloc_init() as a test case:

 $ ./tools/proftool -m System.map -t /tmp/trace.bin -f funcgraph \
                    dump-ftrace -o /tmp/trace.dat
 $ trace-cmd report  /tmp/trace.dat &gt;/tmp/trace.log
 $ vi /tmp/trace.log
 [...]
 u-boot-1     [000]     6.719659: funcgraph_entry:                   |    mem_malloc_init() {
 u-boot-1     [000]     6.719659: funcgraph_entry:                   |      udelay() {
 u-boot-1     [000]     6.719660: funcgraph_entry:                   |        schedule() {
 u-boot-1     [000]     6.719660: funcgraph_entry:                   |          cyclic_run() {
 u-boot-1     [000]     6.719660: funcgraph_entry:        1.000 us   |            cyclic_get_list();
 u-boot-1     [000]     6.719661: funcgraph_exit:         1.000 us   |            }
 u-boot-1     [000]     6.719661: funcgraph_exit:         1.000 us   |          }
 u-boot-1     [000]     6.719661: funcgraph_entry:                   |        __udelay() {
 u-boot-1     [000]     6.719662: funcgraph_entry:        0.000 us   |          usec_to_tick();
 u-boot-1     [000]     6.719687: funcgraph_exit:       + 26.000 us  |          }
 u-boot-1     [000]     6.719687: funcgraph_exit:       + 28.000 us  |        }
 u-boot-1     [000]     6.719687: funcgraph_entry:      # 37971.000 us |      memset();
 u-boot-1     [000]     6.757658: funcgraph_exit:       # 37999.000 us |      }
 u-boot-1     [000]     6.757658: funcgraph_exit:       # 38000.000 us |    }

In the above dump, the udelay() call is reported as taking 26 us which
is consistent with the timestamps (6.719687 - 6.719659 = 0.000026).
Without this patch we would have "0.026 us" instead of "+ 26.000 us".

Signed-off-by: Jerome Forissier &lt;jerome.forissier@linaro.org&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Reviewed-by: Ilias Apalodimas &lt;ilias.apalodimas@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: use dynamic string buffer in make_flamegraph()</title>
<updated>2024-04-10T15:34:53+00:00</updated>
<author>
<name>Vincent Stehlé</name>
<email>vincent.stehle@arm.com</email>
</author>
<published>2024-04-02T11:29:16+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=b782be47f12b1957c67e612e7d3b0ef7b3f32b36'/>
<id>b782be47f12b1957c67e612e7d3b0ef7b3f32b36</id>
<content type='text'>
The str[] buffer declared in make_flamegraph() is used to hold strings
representing the full call-stacks recorded in traces. The size of this
buffer is currently 500 characters and this works well for the documented
examples.

However, it is possible to exhaust this buffer when processing traces
captured when running the UEFI shell on aarch64 sandbox for example.
Indeed, the maximum length needed for such traces can reach 780 characters.

As it is difficult to evaluate the maximum size that would ever be needed
for all the possible traces, let's use a dynamically allocated `abuf'
instead, which we reallocate when needed.

This fixes the following error:

  String too short (500 chars)

While at it, fix a few typos in strings and comments.

Signed-off-by: Vincent Stehlé &lt;vincent.stehle@arm.com&gt;
Cc: Tom Rini &lt;trini@konsulko.com&gt;
Cc: Simon Glass &lt;sjg@chromium.org&gt;
Cc: Michal Simek &lt;michal.simek@amd.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The str[] buffer declared in make_flamegraph() is used to hold strings
representing the full call-stacks recorded in traces. The size of this
buffer is currently 500 characters and this works well for the documented
examples.

However, it is possible to exhaust this buffer when processing traces
captured when running the UEFI shell on aarch64 sandbox for example.
Indeed, the maximum length needed for such traces can reach 780 characters.

As it is difficult to evaluate the maximum size that would ever be needed
for all the possible traces, let's use a dynamically allocated `abuf'
instead, which we reallocate when needed.

This fixes the following error:

  String too short (500 chars)

While at it, fix a few typos in strings and comments.

Signed-off-by: Vincent Stehlé &lt;vincent.stehle@arm.com&gt;
Cc: Tom Rini &lt;trini@konsulko.com&gt;
Cc: Simon Glass &lt;sjg@chromium.org&gt;
Cc: Michal Simek &lt;michal.simek@amd.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: Fix alignment logic in flyrecord header</title>
<updated>2023-09-23T15:00:37+00:00</updated>
<author>
<name>Michal Simek</name>
<email>michal.simek@amd.com</email>
</author>
<published>2023-09-15T12:12:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=e278ad9a2ea5e4a089773a8fd79a5ea0e8572316'/>
<id>e278ad9a2ea5e4a089773a8fd79a5ea0e8572316</id>
<content type='text'>
Current alignment which is using 16 bytes is not correct in connection to
trace_clocks description and it's length.
That's why use start_addr variable and record proper size based on used
entries.

Fixes: be16fc81b2ed ("trace: Update proftool to use new binary format").
Signed-off-by: Michal Simek &lt;michal.simek@amd.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Current alignment which is using 16 bytes is not correct in connection to
trace_clocks description and it's length.
That's why use start_addr variable and record proper size based on used
entries.

Fixes: be16fc81b2ed ("trace: Update proftool to use new binary format").
Signed-off-by: Michal Simek &lt;michal.simek@amd.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: Move trace_clocks description above record offset calculation</title>
<updated>2023-09-23T15:00:37+00:00</updated>
<author>
<name>Michal Simek</name>
<email>michal.simek@amd.com</email>
</author>
<published>2023-09-15T12:12:04+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=5ae43b8706c8897cbd711dbb0f023703b08b5fd3'/>
<id>5ae43b8706c8897cbd711dbb0f023703b08b5fd3</id>
<content type='text'>
Flyrecord tracing data are page aligned that's why it is necessary to
calculate alignment properly. Because trace_clocks description is the part
of record length it is necessary to have information about length earlier.

Signed-off-by: Michal Simek &lt;michal.simek@amd.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Flyrecord tracing data are page aligned that's why it is necessary to
calculate alignment properly. Because trace_clocks description is the part
of record length it is necessary to have information about length earlier.

Signed-off-by: Michal Simek &lt;michal.simek@amd.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: Use 64bit variable for start and len</title>
<updated>2023-09-23T15:00:37+00:00</updated>
<author>
<name>Michal Simek</name>
<email>michal.simek@amd.com</email>
</author>
<published>2023-09-15T12:12:03+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=83711374ee127205dabecbbdab8f58abd504578c'/>
<id>83711374ee127205dabecbbdab8f58abd504578c</id>
<content type='text'>
tputq() requires variables to have 64bit width that's why make them 64bit
to clean alignment requirement.

Signed-off-by: Michal Simek &lt;michal.simek@amd.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
tputq() requires variables to have 64bit width that's why make them 64bit
to clean alignment requirement.

Signed-off-by: Michal Simek &lt;michal.simek@amd.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proftool: Remove unused variables in make_flame_tree</title>
<updated>2023-03-22T19:22:48+00:00</updated>
<author>
<name>Tom Rini</name>
<email>trini@konsulko.com</email>
</author>
<published>2023-02-27T22:08:38+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=d9ab69d7366a0d005b7cf4d65080f8309be3a9d6'/>
<id>d9ab69d7366a0d005b7cf4d65080f8309be3a9d6</id>
<content type='text'>
With clang-15 we now get reported that in the make_flame_tree function,
neither the missing_count nor depth variables are used, only
incremenete/decremented. Remove these.

Signed-off-by: Tom Rini &lt;trini@konsulko.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With clang-15 we now get reported that in the make_flame_tree function,
neither the missing_count nor depth variables are used, only
incremenete/decremented. Remove these.

Signed-off-by: Tom Rini &lt;trini@konsulko.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: Provide a flamegraph that uses timing</title>
<updated>2023-02-11T17:22:35+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2023-01-15T21:15:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=97f3024d16915fd885336c8b983c8a47ac19bcd8'/>
<id>97f3024d16915fd885336c8b983c8a47ac19bcd8</id>
<content type='text'>
Add a second variant of the flame graph that shows records in terms of the
number of microseconds used by each call stack. This is a useful way of
seeing where time is going within the execution of U-Boot.

This requires a call stack that records the start time of each function,
as well as a way of subtracting all time consumed by child functions, so
that this time is not counted twice by the flamegraph. The time values in
the output are just for the function itself, not for its children.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a second variant of the flame graph that shows records in terms of the
number of microseconds used by each call stack. This is a useful way of
seeing where time is going within the execution of U-Boot.

This requires a call stack that records the start time of each function,
as well as a way of subtracting all time consumed by child functions, so
that this time is not counted twice by the flamegraph. The time values in
the output are just for the function itself, not for its children.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: Support output of a flamegraph</title>
<updated>2023-02-11T17:22:35+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2023-01-15T21:15:57+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=47b89d61f2a867f07455d5a3d89df0e7d7a6ec9a'/>
<id>47b89d61f2a867f07455d5a3d89df0e7d7a6ec9a</id>
<content type='text'>
It is useful to see how many times each function is called, particularly
in the context of its callers. A flamegraph is a way of showing this.

Support output in this format which can be used by the flamegraph.pl
script, to generate an SVG image for browsing.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It is useful to see how many times each function is called, particularly
in the context of its callers. A flamegraph is a way of showing this.

Support output in this format which can be used by the flamegraph.pl
script, to generate an SVG image for browsing.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>trace: Support output of funcgraph records</title>
<updated>2023-02-11T17:22:35+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2023-01-15T21:15:56+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=b54d8cf0b5b86a49399c1855f26361d8796d0491'/>
<id>b54d8cf0b5b86a49399c1855f26361d8796d0491</id>
<content type='text'>
Add support for writing ftrace records in the 'funcgraph' format, which
shows function entry and exit points as well as the time taken by each
function.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add support for writing ftrace records in the 'funcgraph' format, which
shows function entry and exit points as well as the time taken by each
function.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
