From: Masami Hiramatsu <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it
Date: Sat, 4 Mar 2017 11:35:51 +0900 [thread overview]
Message-ID: <20170304113551.6a008b969a3ed713729cbd57@kernel.org> (raw)
In-Reply-To: <20170304094911.5f96a10a9f075b6f16fe90d3@kernel.org>
On Sat, 4 Mar 2017 09:49:11 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:
> On Thu, 2 Mar 2017 23:25:06 +0530
> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
>
> > We indicate support for accepting sym+offset with kretprobes through a
> > line in ftrace README. Parse the same to identify support and choose the
> > appropriate format for kprobe_events.
>
> Could you give us an example of this change here? :)
> for example, comment of commit 613f050d68a8 .
>
> I think the code is OK, but we need actual example of result.
Hi Naveen,
I've tried following commands
$ grep "[Tt] user_read$" /proc/kallsyms
0000000000000000 T user_read
0000000000000000 t user_read
$ sudo ./perf probe -D user_read%return
r:probe/user_read _text+3539616
r:probe/user_read_1 _text+3653408
OK, looks good. However, when I set the retprobes, I got an error.
$ sudo ./perf probe -a user_read%return
Failed to write event: Invalid argument
Error: Failed to add events.
And kernel rejected that.
$ dmesg -k | tail -n 1
[ 850.315068] Given offset is not valid for return probe.
Hmm, curious..
I tried normal probes
$ sudo ./perf probe -D user_read
p:probe/user_read _text+3539616
p:probe/user_read_1 _text+3653408
$ sudo ./perf probe -a user_read
Added new events:
probe:user_read (on user_read)
probe:user_read_1 (on user_read)
You can now use it in all perf tools, such as:
perf record -e probe:user_read_1 -aR sleep 1
It works!
$ sudo ./perf probe -l
probe:user_read (on user_read@security/keys/user_defined.c)
probe:user_read_1 (on user_read@selinux/ss/policydb.c)
$ sudo cat /sys/kernel/debug/kprobes/list
ffffffff9237bf20 k user_read+0x0 [DISABLED][FTRACE]
ffffffff923602a0 k user_read+0x0 [DISABLED][FTRACE]
So, the both "_text+3539616" and "_text+3653408" are correctly located
on the entry address of user_read functions. It seems kernel-side
symbol+offset check is wrong.
Thank you,
>
> Thanks,
>
> >
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> > ---
> > tools/perf/util/probe-event.c | 12 +++++-------
> > tools/perf/util/probe-file.c | 7 +++++++
> > tools/perf/util/probe-file.h | 1 +
> > 3 files changed, 13 insertions(+), 7 deletions(-)
> >
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 35f5b7b7715c..faf5789902f5 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -757,7 +757,9 @@ post_process_kernel_probe_trace_events(struct probe_trace_event *tevs,
> > }
> >
> > for (i = 0; i < ntevs; i++) {
> > - if (!tevs[i].point.address || tevs[i].point.retprobe)
> > + if (!tevs[i].point.address)
> > + continue;
> > + if (tevs[i].point.retprobe && !kretprobe_offset_is_supported())
> > continue;
> > /* If we found a wrong one, mark it by NULL symbol */
> > if (kprobe_warn_out_range(tevs[i].point.symbol,
> > @@ -1528,11 +1530,6 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
> > return -EINVAL;
> > }
> >
> > - if (pp->retprobe && !pp->function) {
> > - semantic_error("Return probe requires an entry function.\n");
> > - return -EINVAL;
> > - }
> > -
> > if ((pp->offset || pp->line || pp->lazy_line) && pp->retprobe) {
> > semantic_error("Offset/Line/Lazy pattern can't be used with "
> > "return probe.\n");
> > @@ -2841,7 +2838,8 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
> > }
> >
> > /* Note that the symbols in the kmodule are not relocated */
> > - if (!pev->uprobes && !pp->retprobe && !pev->target) {
> > + if (!pev->uprobes && !pev->target &&
> > + (!pp->retprobe || kretprobe_offset_is_supported())) {
> > reloc_sym = kernel_get_ref_reloc_sym();
> > if (!reloc_sym) {
> > pr_warning("Relocated base symbol is not found!\n");
> > diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> > index 8a219cd831b7..1542cd0d6799 100644
> > --- a/tools/perf/util/probe-file.c
> > +++ b/tools/perf/util/probe-file.c
> > @@ -879,6 +879,7 @@ int probe_cache__show_all_caches(struct strfilter *filter)
> >
> > enum ftrace_readme {
> > FTRACE_README_PROBE_TYPE_X = 0,
> > + FTRACE_README_KRETPROBE_OFFSET,
> > FTRACE_README_END,
> > };
> >
> > @@ -889,6 +890,7 @@ static struct {
> > #define DEFINE_TYPE(idx, pat) \
> > [idx] = {.pattern = pat, .avail = false}
> > DEFINE_TYPE(FTRACE_README_PROBE_TYPE_X, "*type: * x8/16/32/64,*"),
> > + DEFINE_TYPE(FTRACE_README_KRETPROBE_OFFSET, "*place (kretprobe): *"),
> > };
> >
> > static bool scan_ftrace_readme(enum ftrace_readme type)
> > @@ -939,3 +941,8 @@ bool probe_type_is_available(enum probe_type type)
> >
> > return true;
> > }
> > +
> > +bool kretprobe_offset_is_supported(void)
> > +{
> > + return scan_ftrace_readme(FTRACE_README_KRETPROBE_OFFSET);
> > +}
> > diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
> > index a17a82eff8a0..dbf95a00864a 100644
> > --- a/tools/perf/util/probe-file.h
> > +++ b/tools/perf/util/probe-file.h
> > @@ -65,6 +65,7 @@ struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
> > const char *group, const char *event);
> > int probe_cache__show_all_caches(struct strfilter *filter);
> > bool probe_type_is_available(enum probe_type type);
> > +bool kretprobe_offset_is_supported(void);
> > #else /* ! HAVE_LIBELF_SUPPORT */
> > static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused)
> > {
> > --
> > 2.11.1
> >
>
>
> --
> Masami Hiramatsu <mhiramat@kernel.org>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2017-03-04 2:46 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 13:53 [PATCH v2 0/5] kretprobe fixes Naveen N. Rao
2017-02-22 13:53 ` [PATCH v2 1/5] kretprobes: ensure probe location is at function entry Naveen N. Rao
2017-03-07 8:13 ` [tip:perf/core] kretprobes: Ensure " tip-bot for Naveen N. Rao
2017-02-22 13:53 ` [PATCH v2 2/5] powerpc: kretprobes: override default function entry offset Naveen N. Rao
2017-02-24 19:57 ` Arnaldo Carvalho de Melo
2017-02-27 12:56 ` Michael Ellerman
2017-02-25 2:45 ` Ananth N Mavinakayanahalli
2017-02-22 13:53 ` [PATCH v2 3/5] trace/kprobes: allow return probes with offsets and absolute addresses Naveen N. Rao
2017-02-27 16:32 ` Steven Rostedt
2017-02-27 16:52 ` [PATCH v2 3.5/5] trace/kprobes: Add back warning about offset in return probes Steven Rostedt (VMware)
2017-02-28 0:01 ` Masami Hiramatsu
2017-03-01 15:16 ` Naveen N. Rao
2017-03-07 8:20 ` [tip:perf/core] " tip-bot for Steven Rostedt (VMware)
2017-03-07 8:15 ` [tip:perf/core] trace/kprobes: Allow return probes with offsets and absolute addresses tip-bot for Naveen N. Rao
2017-02-22 13:53 ` [PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if kernel supports it Naveen N. Rao
2017-02-23 9:10 ` Masami Hiramatsu
2017-02-23 11:37 ` [PATCH v3 1/2] perf: probe: generalize probe event file open routine Naveen N. Rao
2017-02-24 16:46 ` Masami Hiramatsu
2017-02-24 20:07 ` Arnaldo Carvalho de Melo
2017-03-01 15:12 ` Naveen N. Rao
2017-03-07 8:17 ` [tip:perf/core] perf probe: Generalize " tip-bot for Naveen N. Rao
2017-02-23 11:37 ` [PATCH v3 2/2] perf: kretprobes: offset from reloc_sym if kernel supports it Naveen N. Rao
2017-02-24 17:12 ` Masami Hiramatsu
2017-03-01 15:11 ` Naveen N. Rao
2017-02-23 19:16 ` [PATCH v2 4/5] " Naveen N. Rao
2017-02-24 17:29 ` Masami Hiramatsu
2017-02-24 20:11 ` Arnaldo Carvalho de Melo
2017-02-24 23:55 ` Masami Hiramatsu
2017-03-01 15:14 ` Naveen N. Rao
2017-03-02 17:55 ` Naveen N. Rao
2017-03-02 19:06 ` Arnaldo Carvalho de Melo
2017-03-02 17:55 ` [PATCH v4 1/3] perf: probe: factor out the ftrace README scanning Naveen N. Rao
2017-03-04 0:09 ` Masami Hiramatsu
2017-03-07 20:45 ` Steven Rostedt
2017-03-02 17:55 ` [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it Naveen N. Rao
2017-03-04 0:49 ` Masami Hiramatsu
2017-03-04 2:35 ` Masami Hiramatsu [this message]
2017-03-04 2:38 ` Masami Hiramatsu
2017-03-04 4:34 ` Masami Hiramatsu
2017-03-06 16:20 ` Naveen N. Rao
2017-03-06 17:49 ` Naveen N. Rao
2017-03-06 21:06 ` Masami Hiramatsu
2017-03-07 10:47 ` [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel Naveen N. Rao
2017-03-07 10:47 ` [RESEND PATCH 1/6] trace/kprobes: fix check for kretprobe offset within function entry Naveen N. Rao
2017-03-07 20:47 ` Steven Rostedt
2017-03-08 8:01 ` Naveen N. Rao
2017-03-07 10:47 ` [RESEND PATCH 2/6] powerpc: kretprobes: override default function entry offset Naveen N. Rao
2017-03-07 10:47 ` [RESEND PATCH 3/6] perf: probe: factor out the ftrace README scanning Naveen N. Rao
2017-03-07 10:47 ` [RESEND PATCH 4/6] perf: kretprobes: offset from reloc_sym if kernel supports it Naveen N. Rao
2017-03-07 10:47 ` [PATCH 5/6] perf: probes: move ftrace README parsing logic into trace-event-parse.c Naveen N. Rao
2017-03-07 14:03 ` Masami Hiramatsu
2017-03-07 14:29 ` Naveen N. Rao
2017-03-07 15:51 ` Masami Hiramatsu
2017-03-07 16:31 ` Naveen N. Rao
2017-03-07 10:47 ` [RESEND PATCH 6/6] perf: powerpc: choose local entry point with kretprobes Naveen N. Rao
2017-03-07 16:49 ` [PATCH v2 " Naveen N. Rao
2017-03-06 15:04 ` [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it Naveen N. Rao
2017-03-06 21:14 ` Masami Hiramatsu
2017-03-02 17:55 ` [PATCH v4 3/3] perf: powerpc: choose local entry point with kretprobes Naveen N. Rao
2017-03-04 0:50 ` Masami Hiramatsu
2017-02-22 13:53 ` [PATCH v2 5/5] " Naveen N. Rao
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=20170304113551.6a008b969a3ed713729cbd57@kernel.org \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=ananth@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®