From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
David Ahern <dsahern@gmail.com>,
linux-kernel@vger.kernel.org, Martin Cermak <mcermak@redhat.com>
Subject: Re: [RFC] perf probe: -x option position issue
Date: Tue, 31 Mar 2015 17:04:18 +0900 [thread overview]
Message-ID: <551A5502.4070905@hitachi.com> (raw)
In-Reply-To: <20150330194849.GH32560@kernel.org>
(2015/03/31 4:48), Arnaldo Carvalho de Melo wrote:
> Em Mon, Mar 30, 2015 at 07:46:55PM +0200, Jiri Olsa escreveu:
>> hi,
>> Martin found out following issue.. having following ex binary:
>>
>> ---
>> int main(void)
>> {
>> return 0;
>> }
>> ---
>>
>> following will create uprobe on main:
>>
>> [root@dell-per510-01 perf]# gcc -g -o ex ex.c
>> [root@dell-per510-01 perf]# ./perf probe -x ./ex -a main
>> Added new event:
>> probe_ex:main (on main in /root/linux/tools/perf/ex)
>>
>> You can now use it in all perf tools, such as:
>>
>> perf record -e probe_ex:main -aR sleep 1
>>
>> [root@dell-per510-01 perf]# cat /sys/kernel/debug/tracing/uprobe_events
>> p:probe_ex/main /root/linux/tools/perf/ex:0x00000000000004f6
>>
>>
>> while following will create (?) kprobe with complain in dmesg:
>
> Right, it looks like it will create the probe on the currently selected
> DSO, which, if you have none, will be the kernel, thus the kprobe
> (probe:main), while if you do a '-x ./ex -a main' you are selecting the
> 'ex' DSO and then asking for the probe to be added to a function named
> 'main', on that DSO, that 'perf probe' realizes is a userspace binary,
> thus creates a uprobe: probe_%DSONAME:%FUNCTIONAME.
Right, but this looks strange and not easy to expect.
>
> I wonder if I can do:
>
> [root@ssdandy acme]# perf probe -a icmp_rcv -x ./ex -a main
> Probe point 'icmp_rcv' not found.
> Error: Failed to add events.
Ah, this should be fixed. Even with multiple -x, it fails.
# ./perf probe -x /usr/lib64/libc-2.17.so -a malloc -x ./perf -a main
usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
or: perf probe [<options>] --del '[GROUP:]EVENT' ...
or: perf probe --list
or: perf probe [<options>] --line 'LINEDESC'
or: perf probe [<options>] --vars 'PROBEPOINT'
-x, --exec <executable|path>
target executable name or path
...
I'd like to start with setting up the event only on single binary,
and showing appropriate error message.
> No, I can't, I'd say we should support that, i.e. inserting multiple
> probes per command line, for different DSOs, etc. I.e. the above would
> be equivalent to these two calls:
>
> [root@ssdandy acme]# perf probe -a icmp_rcv
> Added new event:
> probe:icmp_rcv (on icmp_rcv)
>
> You can now use it in all perf tools, such as:
>
> perf record -e probe:icmp_rcv -aR sleep 1
>
> [root@ssdandy acme]# perf probe -x ./ex -a main
> Added new event:
> probe_ex:main (on main in /home/acme/ex)
>
> You can now use it in all perf tools, such as:
>
> perf record -e probe_ex:main -aR sleep 1
>
> [root@ssdandy acme]#
OK, finally we should support that.
> But it isn't like that, so, yes, what you report is a bug, both for your
> expectation (that I think is that it should put a uprobes with both your
> examples) and for mine (that it would add the first to the kernel, and
> the second to the selected DSO via -x).
Yes, both are bugs. I'll fix that.
BTW, let me check that the below behaviors are OK for you.
perf probe -x BIN -a XXX
-> setup XXX on BIN
perf probe -a XXX -x BIN
-> setup XXX on BIN
perf probe -a XXX -x BIN -a YYY
-> setup XXX on kernel and YYY on BIN
perf probe -x BIN -a XXX -x BIN2 -a YYY
-> setup XXX on BIN and YYY on BIN2
Thank you,
>
> - Arnaldo
>
>> [root@dell-per510-01 perf]# gcc -g -o ex ex.c
>> [root@dell-per510-01 perf]# ./perf probe -a main -x ./ex
>> Added new event:
>> probe:main (on main in ex)
>>
>> You can now use it in all perf tools, such as:
>>
>> perf record -e probe:main -aR sleep 1
>>
>> [root@dell-per510-01 perf]# dmesg | tail -2
>> [16986.182159] Could not insert probe at ex:main+0: -2
>> [16986.187030] This probe might be able to register aftertarget module is loaded. Continue.
>>
>>
>> that does not seem as an expected behaviour, or am I missing something?
>>
>> thanks,
>> jirka
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2015-03-31 8:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 17:46 [RFC] perf probe: -x option position issue Jiri Olsa
2015-03-30 19:48 ` Arnaldo Carvalho de Melo
2015-03-31 8:04 ` Masami Hiramatsu [this message]
2015-03-31 13:33 ` Arnaldo Carvalho de Melo
2015-04-01 8:37 ` Masami Hiramatsu
2015-04-01 10:25 ` [PATCH perf/core 1/2] perf-probe: Support multiple probes on different binaries Masami Hiramatsu
2015-04-11 6:37 ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2015-04-01 10:25 ` [PATCH perf/core 2/2] perf-probe: Check the orphaned -x option Masami Hiramatsu
2015-04-01 11:11 ` Jiri Olsa
2015-04-10 6:51 ` Masami Hiramatsu
2015-04-10 13:22 ` Arnaldo Carvalho de Melo
2015-04-11 6:38 ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
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=551A5502.4070905@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcermak@redhat.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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 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).