* perf probe: Trying to read a 'ctx' named local variable
@ 2023-07-17 18:06 Arnaldo Carvalho de Melo
2023-07-17 23:54 ` Masami Hiramatsu
0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-07-17 18:06 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: linux-perf-users
Hi Masami,
Trying to use perf to debug perf I stumbled on this:
[root@quaco ~]# perf probe -x ~/bin/perf -L sigtrap_handler
<sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>
0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused)
{
if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
3 ctx.first_siginfo = *info;
4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED);
}
static void *test_thread(void *arg)
[root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count"
Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@quaco ~]#
[root@quaco ~]# uname -a
Linux quaco 6.3.8-100.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 15 01:51:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[root@quaco ~]# rpm -qa | grep kernel-debuginfo
kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
kernel-debuginfo-6.3.8-100.fc37.x86_64
[root@quaco ~]#
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: perf probe: Trying to read a 'ctx' named local variable
2023-07-17 18:06 perf probe: Trying to read a 'ctx' named local variable Arnaldo Carvalho de Melo
@ 2023-07-17 23:54 ` Masami Hiramatsu
2023-07-20 14:40 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2023-07-17 23:54 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
On Mon, 17 Jul 2023 15:06:10 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Hi Masami,
>
> Trying to use perf to debug perf I stumbled on this:
>
> [root@quaco ~]# perf probe -x ~/bin/perf -L sigtrap_handler
> <sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>
> 0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused)
> {
> if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
> 3 ctx.first_siginfo = *info;
> 4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED);
> }
>
> static void *test_thread(void *arg)
>
> [root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count"
> Failed to write event: Invalid argument
> Please upgrade your kernel to at least 3.14 to have access to feature @ctx
> Error: Failed to add events.
> [root@quaco ~]#
Ah, this is a wrong usage (I'm also trapped the same thing). Correctly, it should
pass it as a single parameter.
perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
This is for adding several events at the same time. But now it becomes just a trap.
Can I change the syntax from
perf probe [OPTIONS] <PROBE-DEFINITION> [PROBE-DEFINITION...]
To,
perf probe [OPTIONS] <PROBE-POINT> [ARGS...]
?
We can keep --add having optional parameter as below.
perf probe [OPTIONS] --add <PROBE-DEFINITION>
Thank you,
>
> [root@quaco ~]# uname -a
> Linux quaco 6.3.8-100.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 15 01:51:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
> [root@quaco ~]# rpm -qa | grep kernel-debuginfo
> kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
> kernel-debuginfo-6.3.8-100.fc37.x86_64
> [root@quaco ~]#
>
> --
>
> - Arnaldo
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: perf probe: Trying to read a 'ctx' named local variable
2023-07-17 23:54 ` Masami Hiramatsu
@ 2023-07-20 14:40 ` Arnaldo Carvalho de Melo
2023-07-21 0:38 ` Masami Hiramatsu
0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-07-20 14:40 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: linux-perf-users
Em Tue, Jul 18, 2023 at 08:54:51AM +0900, Masami Hiramatsu escreveu:
> On Mon, 17 Jul 2023 15:06:10 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> > Hi Masami,
> >
> > Trying to use perf to debug perf I stumbled on this:
> >
> > [root@quaco ~]# perf probe -x ~/bin/perf -L sigtrap_handler
> > <sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>
> > 0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused)
> > {
> > if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
> > 3 ctx.first_siginfo = *info;
> > 4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED);
> > }
> >
> > static void *test_thread(void *arg)
> >
> > [root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count"
> > Failed to write event: Invalid argument
> > Please upgrade your kernel to at least 3.14 to have access to feature @ctx
> > Error: Failed to add events.
> > [root@quaco ~]#
>
> Ah, this is a wrong usage (I'm also trapped the same thing). Correctly, it should
> pass it as a single parameter.
>
> perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
[root@five ~]# perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@five ~]#
Didn't work?
- Arnaldo
> This is for adding several events at the same time. But now it becomes just a trap.
> Can I change the syntax from
>
> perf probe [OPTIONS] <PROBE-DEFINITION> [PROBE-DEFINITION...]
>
> To,
>
> perf probe [OPTIONS] <PROBE-POINT> [ARGS...]
>
> ?
>
> We can keep --add having optional parameter as below.
>
> perf probe [OPTIONS] --add <PROBE-DEFINITION>
>
> Thank you,
>
> >
> > [root@quaco ~]# uname -a
> > Linux quaco 6.3.8-100.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 15 01:51:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
> > [root@quaco ~]# rpm -qa | grep kernel-debuginfo
> > kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
> > kernel-debuginfo-6.3.8-100.fc37.x86_64
> > [root@quaco ~]#
> >
> > --
> >
> > - Arnaldo
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: perf probe: Trying to read a 'ctx' named local variable
2023-07-20 14:40 ` Arnaldo Carvalho de Melo
@ 2023-07-21 0:38 ` Masami Hiramatsu
0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2023-07-21 0:38 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users
On Thu, 20 Jul 2023 11:40:42 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Tue, Jul 18, 2023 at 08:54:51AM +0900, Masami Hiramatsu escreveu:
> > On Mon, 17 Jul 2023 15:06:10 -0300
> > Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> >
> > > Hi Masami,
> > >
> > > Trying to use perf to debug perf I stumbled on this:
> > >
> > > [root@quaco ~]# perf probe -x ~/bin/perf -L sigtrap_handler
> > > <sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>
> > > 0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused)
> > > {
> > > if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
> > > 3 ctx.first_siginfo = *info;
> > > 4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED);
> > > }
> > >
> > > static void *test_thread(void *arg)
> > >
> > > [root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count"
> > > Failed to write event: Invalid argument
> > > Please upgrade your kernel to at least 3.14 to have access to feature @ctx
> > > Error: Failed to add events.
> > > [root@quaco ~]#
> >
> > Ah, this is a wrong usage (I'm also trapped the same thing). Correctly, it should
> > pass it as a single parameter.
> >
> > perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
>
> [root@five ~]# perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
> Failed to write event: Invalid argument
> Please upgrade your kernel to at least 3.14 to have access to feature @ctx
> Error: Failed to add events.
> [root@five ~]#
>
> Didn't work?
Ah, I got it. The error message is wrong.
/sys/kernel/debug/tracing# cat error_log
[122869.758693] trace_uprobe: error: Symbol is not available with uprobe
Command: p:probe_perf/sigtrap_handler_L4 /usr/local/bin/perf:0xfc8e9 signal_count=@ctx+4:s32
^
"ctx" is not a local variable in this context and @ctx (global variable) is not
accessible from uprobe events.
Hmm, it must be checked while parsing the debuginfo.
Thank you,
>
> - Arnaldo
>
> > This is for adding several events at the same time. But now it becomes just a trap.
> > Can I change the syntax from
> >
> > perf probe [OPTIONS] <PROBE-DEFINITION> [PROBE-DEFINITION...]
> >
> > To,
> >
> > perf probe [OPTIONS] <PROBE-POINT> [ARGS...]
> >
> > ?
> >
> > We can keep --add having optional parameter as below.
> >
> > perf probe [OPTIONS] --add <PROBE-DEFINITION>
> >
> > Thank you,
> >
> > >
> > > [root@quaco ~]# uname -a
> > > Linux quaco 6.3.8-100.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 15 01:51:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
> > > [root@quaco ~]# rpm -qa | grep kernel-debuginfo
> > > kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
> > > kernel-debuginfo-6.3.8-100.fc37.x86_64
> > > [root@quaco ~]#
> > >
> > > --
> > >
> > > - Arnaldo
> >
> >
> > --
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> --
>
> - Arnaldo
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-21 0:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 18:06 perf probe: Trying to read a 'ctx' named local variable Arnaldo Carvalho de Melo
2023-07-17 23:54 ` Masami Hiramatsu
2023-07-20 14:40 ` Arnaldo Carvalho de Melo
2023-07-21 0:38 ` Masami Hiramatsu
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).