From: Namhyung Kim <namhyung@kernel.org>
To: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: acme@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com,
irogers@google.com, linux-perf-users@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com,
kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com,
hbathini@linux.vnet.ibm.com, Aditya.Bodkhe1@ibm.com,
Tejas.Manhas1@ibm.com
Subject: Re: [PATCH] tools/perf: Use perf_tool__init() to initialize default values in builtin trace
Date: Wed, 26 Feb 2025 16:38:38 -0800 [thread overview]
Message-ID: <Z7-0DuisrMHyscDj@google.com> (raw)
In-Reply-To: <20250225113157.28836-1-atrajeev@linux.ibm.com>
On Tue, Feb 25, 2025 at 05:01:57PM +0530, Athira Rajeev wrote:
> Perf trace on perf.data fails as below:
>
> ./perf trace record -- sleep 1
> ./perf trace -i perf.data
> perf: Segmentation fault
> Segmentation fault (core dumped)
>
> Backtrace pointed to :
> ?? ()
> perf_session.process_user_event ()
> reader.read_event ()
> perf_session.process_events ()
> cmd_trace ()
> run_builtin ()
> handle_internal_command ()
> main ()
>
> Further debug pointed that, segmentation fault happens when
> trying to access id_index. Code snippet:
>
> case PERF_RECORD_ID_INDEX:
> err = tool->id_index(session, event);
>
> Since 'commit 15d4a6f41d72 ("perf tool: Remove
> perf_tool__fill_defaults()")', perf_tool__fill_defaults is
> removed. All tools are initialized using perf_tool__init()
> prior to use. But in builtin-trace, perf_tool__init is not
> used and hence the defaults are not initialized. Use
> perf_tool__init() in perf trace to handle the initialization.
Thanks for fixing this. I can reproduce the problem and confirmed this
patch fixed it.
Thanks,
Namhyung
>
> Reported-by: Tejas Manhas <Tejas.Manhas1@ibm.com>
> Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
> ---
> tools/perf/builtin-trace.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index f55a8a6481f2..092c5f6404ba 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -4589,6 +4589,7 @@ static int trace__replay(struct trace *trace)
> struct evsel *evsel;
> int err = -1;
>
> + perf_tool__init(&trace->tool, /*ordered_events=*/true);
> trace->tool.sample = trace__process_sample;
> trace->tool.mmap = perf_event__process_mmap;
> trace->tool.mmap2 = perf_event__process_mmap2;
> --
> 2.43.5
>
next prev parent reply other threads:[~2025-02-27 0:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 11:31 [PATCH] tools/perf: Use perf_tool__init() to initialize default values in builtin trace Athira Rajeev
2025-02-27 0:38 ` Namhyung Kim [this message]
2025-02-27 6:42 ` Athira Rajeev
2025-02-27 16:50 ` Namhyung Kim
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=Z7-0DuisrMHyscDj@google.com \
--to=namhyung@kernel.org \
--cc=Aditya.Bodkhe1@ibm.com \
--cc=Tejas.Manhas1@ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=atrajeev@linux.ibm.com \
--cc=disgoel@linux.vnet.ibm.com \
--cc=hbathini@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kjain@linux.ibm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).