All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org,
	James Clark <james.clark@linaro.org>,
	Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org,
	Alice <alice.mei.rogers@gmail.com>
Subject: Re: [PATCH 0/2] perf script flamegraph: Fix input file name errors
Date: Fri, 02 Oct 2026 11:27:57 -0700	[thread overview]
Message-ID: <87o6dc9cuq.fsf@oracle.com> (raw)
In-Reply-To: <CAP-5=fVkoy6ZJ_3Y3E2s=7ccdQd3aUz_g-e6ivX68=aHBsmnkg@mail.gmail.com>

Ian Rogers <irogers@google.com> writes:
> On Thu, Oct 1, 2026 at 11:20 AM Stephen Brennan
> <stephen.s.brennan@oracle.com> wrote:
>>
>> The flamegraph.py script has a "-i" option which it uses in an attempt to
>> know the input file name for the data it is processing. But perf itself is
>> using that flag and not forwarding its value to the script, so the entire
>> strategy won't work. It's further complicated by how the option processing
>> is handled in the flamegraph-report script -- details in patch 2.
>>
>> This series introduces a helper to allow python scripts to see the input
>> file name, and then fixes flamegraph.py. Testing with a variety of options
>> like below shows that it is using the correct input files in most use cases
>> I can think of:
>>
>> $ export PERF_EXEC_PATH=$(pwd)/tools/perf
>>
>> $ sudo -E tools/perf/perf script flamegraph -a -F999 -- sleep 1
>> dumping data to flamegraph.html
>>
>> $ sudo -E tools/perf/perf script record flamegraph \
>>                           -o myfile.data -a -F999 -- sleep 1
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 2.891 MB myfile.data (1832 samples) ]
>>
>> $ sudo -E tools/perf/perf script report flamegraph -i myfile.data \
>>                                  -- -o myfile.html
>> dumping data to myfile.html
>>
>> $ sudo -E tools/perf/perf script \
>>        -s tools/perf/scripts/python/flamegraph.py -i myfile.data
>> dumping data to flamegraph.html
>>
>> $ sudo -E tools/perf/perf script record flamegraph \
>>        -o - -a -F999 -- sleep 1 \
>>     | tools/perf/perf script report flamegraph -i - -- -o manual.html
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 2.936 MB - ]
>> dumping data to manual.html
>
> Hi Stephen,
>
> Thank you for the contribution! Unfortunately we recently deleted all
> of this code in this series:
> https://lore.kernel.org/linux-perf-users/20260926062029.800743-1-irogers@google.com/
> You can find the latest code in the perf-tools-next branch:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/

Hi Ian,
Thanks, I should have checked there first.

> The flamegraph code that now uses perf's python module is here:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/python/flamegraph.py?h=perf-tools-next

That looks exciting! It makes things a lot easier to have perf as a
regular Python module rather than wrapping the interpreter. It will be
tricky for Oracle Linux which allows parallel installation of perf
versions, but I guess we made our own bed there :)

> and we even have some tests now:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/tests/shell/test_flamegraph_python.sh?h=perf-tools-next
>
> You may also like to play with the console flamegraph that is part of treport:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/python/treport.py?h=perf-tools-next

This is quite slick! I'll definitely be playing more with the python
module.

Thanks,
Stephen

> Thanks,
> Ian
>
>
>> Stephen Brennan (2):
>>   tools: perf: add perf_input_name() helper
>>   tools: perf: flamegraph.py: fix "Error reading report header"
>>
>>  .../perf/Documentation/perf-script-python.txt |  1 +
>>  .../scripts/python/Perf-Trace-Util/Context.c  | 16 ++++++++++++++
>>  tools/perf/scripts/python/flamegraph.py       | 22 +++++++++----------
>>  3 files changed, 27 insertions(+), 12 deletions(-)
>>
>> --
>> 2.52.0
>>

      reply	other threads:[~2026-10-02 18:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 18:19 [PATCH 0/2] perf script flamegraph: Fix input file name errors Stephen Brennan
2026-10-01 18:20 ` [PATCH 1/2] tools: perf: add perf_input_name() helper Stephen Brennan
2026-10-02  9:12   ` sashiko-bot
2026-10-01 18:20 ` [PATCH 2/2] tools: perf: flamegraph.py: fix "Error reading report header" Stephen Brennan
2026-10-02  9:12   ` sashiko-bot
2026-10-02  5:24 ` [PATCH 0/2] perf script flamegraph: Fix input file name errors Ian Rogers
2026-10-02 18:27   ` Stephen Brennan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o6dc9cuq.fsf@oracle.com \
    --to=stephen.s.brennan@oracle.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alice.mei.rogers@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.