public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] flamegraph: force flamegraph-report script to run in live mode when using 'perf script flamegraph'
@ 2025-01-30 21:35 Anubhav Shelat
  2025-01-31 13:18 ` Michael Petlan
  0 siblings, 1 reply; 2+ messages in thread
From: Anubhav Shelat @ 2025-01-30 21:35 UTC (permalink / raw)
  To: mpetlan, acme, namhyung, irogers, linux-perf-users
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa,
	adrian.hunter, kan.liang, dapeng1.mi, james.clark

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.

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
---
 tools/perf/scripts/python/bin/flamegraph-report | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/bin/flamegraph-report b/tools/perf/scripts/python/bin/flamegraph-report
index 53c5dc90c87e..83d5738c75ca 100755
--- a/tools/perf/scripts/python/bin/flamegraph-report
+++ b/tools/perf/scripts/python/bin/flamegraph-report
@@ -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 - -- "$@"
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] flamegraph: force flamegraph-report script to run in live mode when using 'perf script flamegraph'
  2025-01-30 21:35 [PATCH] flamegraph: force flamegraph-report script to run in live mode when using 'perf script flamegraph' Anubhav Shelat
@ 2025-01-31 13:18 ` Michael Petlan
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Petlan @ 2025-01-31 13:18 UTC (permalink / raw)
  To: Anubhav Shelat
  Cc: acme, namhyung, irogers, linux-perf-users, peterz, mingo,
	mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
	dapeng1.mi, james.clark

On Thu, 30 Jan 2025, Anubhav Shelat wrote:
> 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.
> 
> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>

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

Otherwise, thanks for the fix.

Tested-by: Michael Petlan <mpetlan@redhat.com>

> ---
>  tools/perf/scripts/python/bin/flamegraph-report | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/scripts/python/bin/flamegraph-report b/tools/perf/scripts/python/bin/flamegraph-report
> index 53c5dc90c87e..83d5738c75ca 100755
> --- a/tools/perf/scripts/python/bin/flamegraph-report
> +++ b/tools/perf/scripts/python/bin/flamegraph-report
> @@ -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 - -- "$@"
> -- 
> 2.48.1
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-31 13:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-30 21:35 [PATCH] flamegraph: force flamegraph-report script to run in live mode when using 'perf script flamegraph' Anubhav Shelat
2025-01-31 13:18 ` Michael Petlan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox