Skip to contentSkip to conversation

flamegraph: force flamegraph-report script to run in live mode when using 'perf script flamegraph'

PATCH Superseded Anubhav Shelat 2 participants 2 messages Jan 30, 2025 – Jan 31, 2025 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 flamegraph: force flamegraph-report script to run in live mode when using 'perf script flamegraph'

Currently, running "perf script flamegraph -a -F 99 sleep 1" should produce flamegraph.html containing the flamegraph. Howevever, it gives a segmentation fault.

This is caused because the flamegraph.py script is
supposed to take as input the output of "perf record", which should be in stdin. This would require passing "-i -" to flamegraph.py. However, the "flamegraph-report" script causes "perf script" command to take the "-i -" option instead of flamegraph.py, which causes no problem for "perf script", but causes a seg fault since flamegraph.py has no input file. To fix this I added the "-i -" option directly to the flamegraph-report script to ensure flamegraph.py gets input from stdin.

---
 tools/perf/scripts/python/bin/flamegraph-report | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/scripts/python/bin/flamegraph-report +1 -1
index 53c5dc90c87e..83d5738c75ca 100755
@@ -1,3 +1,3 @@
 #!/bin/bash
 # description: create flame graphs
-perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -- "$@"
+perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -i - -- "$@"
Signature · 1 line
2.48.1
Tested-by on v1 1/1
#1 lore raw
Quoted 13 lines · Anubhav Shelat

Currently, running "perf script flamegraph -a -F 99 sleep 1" should produce flamegraph.html containing the flamegraph. Howevever, it gives a segmentation fault.

This is caused because the flamegraph.py script is
supposed to take as input the output of "perf record", which should be in stdin. This would require passing "-i -" to flamegraph.py. However, the "flamegraph-report" script causes "perf script" command to take the "-i -" option instead of flamegraph.py, which causes no problem for "perf script", but causes a seg fault since flamegraph.py has no input file. To fix this I added the "-i -" option directly to the flamegraph-report script to ensure flamegraph.py gets input from stdin.

Quoted 1 line

I'd suggest adjusting the title slightly, e.g.:
"perf script flamegraph: Force stdin in live mode"

Otherwise, thanks for the fix.

Quoted 17 lines
---
 tools/perf/scripts/python/bin/flamegraph-report | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/scripts/python/bin/flamegraph-report +1 -1
index 53c5dc90c87e..83d5738c75ca 100755
@@ -1,3 +1,3 @@
 #!/bin/bash
 # description: create flame graphs
-perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -- "$@"
+perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -i - -- "$@"
Signature · 1 line
2.48.1