From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: cclaudio@linux.ibm.com, Jiri Olsa <jolsa@kernel.org>,
Linux Kernel? Mailing List <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH] perf trace: Fix SIGSEGV when processing augmented args
Date: Wed, 6 Jul 2022 12:50:23 -0300 [thread overview]
Message-ID: <YsWvPwRirNIT67tl@kernel.org> (raw)
In-Reply-To: <1657110053.93m1349h4k.naveen@linux.ibm.com>
Em Wed, Jul 06, 2022 at 06:01:29PM +0530, Naveen N. Rao escreveu:
> Hi Arnaldo,
>
> Arnaldo Carvalho de Melo wrote:
> > Em Tue, Mar 15, 2022 at 02:52:05PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Tue, Mar 15, 2022 at 10:57:57PM +0530, Naveen N. Rao escreveu:
> > > > Yes, it looks like the current check in 'perf' isn't working. The below
> > > > patch also resolves the crash we are seeing:
> > > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > > > index 2f1d20553a0aa3..86b459f4ebdd61 100644
> > > > --- a/tools/perf/builtin-trace.c
> > > > +++ b/tools/perf/builtin-trace.c
> > > > @@ -2326,7 +2326,7 @@ static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
> > > > * thinking that the extra 2 u64 args are the augmented filename, so just check
> > > > * here and avoid using augmented syscalls when the evsel is the raw_syscalls one.
> > > > */
> > > > - if (evsel != trace->syscalls.events.sys_enter)
> > > > + if (strcmp(evsel__name(evsel), "raw_syscalls:sys_enter"))
> > > > augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size);
> > > > ttrace->entry_time = sample->time;
> > > > msg = ttrace->entry_str;
> > >
> > > Interesting, that should be equivalent :-\ humm, not really, understood,
> > > when processing perf.data files we don't setup
> > > trace->syscalls.events.sys_enter...
> > >
> > > switching from strcmp() to something cheaper but equivalent should be
> > > the fix for now.
> >
> > I'll add a trace->use_augmented_args boolean that will do this test
> > once, and then use it in this case and will audit to check if this
> > should be used in other places.
>
> Does something like the below look reasonable?
>
> I know this isn't quite what you proposed, but it fixes the problem for me
> while avoiding the need for a string comparison. I also think this addresses
> all uses in 'perf trace', though I didn't audit the need for a similar fix
> elsewhere in 'perf'.
I'll check and test, but I like it, two-liner even :-)
- Arnaldo
>
> Thanks,
> Naveen
>
> ---
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index d2de2a4073e7eb..352b88a51dec2d 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -4291,6 +4292,8 @@ static int trace__replay(struct trace *trace)
> goto out;
> }
>
> + trace->syscalls.events.sys_enter = evsel;
> +
> evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_exit");
> if (evsel == NULL)
> evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_exit");
> @@ -4301,6 +4304,8 @@ static int trace__replay(struct trace *trace)
> goto out;
> }
>
> + trace->syscalls.events.sys_exit = evsel;
> +
> evlist__for_each_entry(session->evlist, evsel) {
> if (evsel->core.attr.type == PERF_TYPE_SOFTWARE &&
> (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ||
>
>
--
- Arnaldo
prev parent reply other threads:[~2022-07-06 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 10:47 [PATCH] perf trace: Fix SIGSEGV when processing augmented args Naveen N. Rao
2022-03-14 22:09 ` Arnaldo Carvalho de Melo
2022-03-15 17:27 ` Naveen N. Rao
2022-03-15 17:52 ` Arnaldo Carvalho de Melo
2022-03-16 20:36 ` Arnaldo Carvalho de Melo
2022-03-17 13:24 ` Naveen N. Rao
2022-07-06 12:31 ` Naveen N. Rao
2022-07-06 15:50 ` Arnaldo Carvalho de Melo [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=YsWvPwRirNIT67tl@kernel.org \
--to=acme@kernel.org \
--cc=cclaudio@linux.ibm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=naveen.n.rao@linux.vnet.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