* [PATCH] tools/perf probe: Print a hint if adding a probe fails
@ 2021-06-10 9:44 Naveen N. Rao
2021-06-10 10:29 ` Masami Hiramatsu
0 siblings, 1 reply; 4+ messages in thread
From: Naveen N. Rao @ 2021-06-10 9:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Arnaldo Carvalho de Melo, Masami Hiramatsu, Aneesh Kumar K.V
Adding a probe can fail in a few scenarios. perf already checks for the
address in the kprobe blacklist. However, the address could still be a
jump label, or have a BUG_ON(). In such cases, it isn't always evident
why adding the probe failed. Add a hint so that the user knows how to
proceed.
Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
tools/perf/builtin-probe.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 6b150756677014..ff9f3fdce600dd 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -352,8 +352,11 @@ static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
}
ret = apply_perf_probe_events(pevs, npevs);
- if (ret < 0)
+ if (ret < 0) {
+ pr_info("Hint: Check dmesg to understand reason for probe failure.\n"
+ " Consider probing at the next/previous instruction.\n");
goto out_cleanup;
+ }
for (i = k = 0; i < npevs; i++)
k += pevs[i].ntevs;
base-commit: 0808b3d5b7514dc856178dbc509929329bbf301d
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/perf probe: Print a hint if adding a probe fails
2021-06-10 9:44 [PATCH] tools/perf probe: Print a hint if adding a probe fails Naveen N. Rao
@ 2021-06-10 10:29 ` Masami Hiramatsu
2021-06-18 13:15 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2021-06-10 10:29 UTC (permalink / raw)
To: Naveen N. Rao
Cc: linux-kernel, Arnaldo Carvalho de Melo, Masami Hiramatsu,
Aneesh Kumar K.V
Hi Naveen,
On Thu, 10 Jun 2021 15:14:42 +0530
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> Adding a probe can fail in a few scenarios. perf already checks for the
> address in the kprobe blacklist. However, the address could still be a
> jump label, or have a BUG_ON(). In such cases, it isn't always evident
> why adding the probe failed. Add a hint so that the user knows how to
> proceed.
>
Thanks for the report.
Since now there is <tracefs>/error_log, if you see any errors in registering
probe-events, perf probe should dump the error_log for the hint message.
Also, kprobes should return the correct different error code for each
errors.
Thank you,
> Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
> tools/perf/builtin-probe.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index 6b150756677014..ff9f3fdce600dd 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -352,8 +352,11 @@ static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
> }
>
> ret = apply_perf_probe_events(pevs, npevs);
> - if (ret < 0)
> + if (ret < 0) {
> + pr_info("Hint: Check dmesg to understand reason for probe failure.\n"
> + " Consider probing at the next/previous instruction.\n");
> goto out_cleanup;
> + }
>
> for (i = k = 0; i < npevs; i++)
> k += pevs[i].ntevs;
>
> base-commit: 0808b3d5b7514dc856178dbc509929329bbf301d
> --
> 2.31.1
>
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/perf probe: Print a hint if adding a probe fails
2021-06-10 10:29 ` Masami Hiramatsu
@ 2021-06-18 13:15 ` Arnaldo Carvalho de Melo
2021-06-21 9:40 ` Naveen N. Rao
0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-06-18 13:15 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Naveen N. Rao, linux-kernel, Aneesh Kumar K.V
Em Thu, Jun 10, 2021 at 07:29:26PM +0900, Masami Hiramatsu escreveu:
> Hi Naveen,
>
> On Thu, 10 Jun 2021 15:14:42 +0530
> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
>
> > Adding a probe can fail in a few scenarios. perf already checks for the
> > address in the kprobe blacklist. However, the address could still be a
> > jump label, or have a BUG_ON(). In such cases, it isn't always evident
> > why adding the probe failed. Add a hint so that the user knows how to
> > proceed.
> >
>
> Thanks for the report.
>
> Since now there is <tracefs>/error_log, if you see any errors in registering
> probe-events, perf probe should dump the error_log for the hint message.
> Also, kprobes should return the correct different error code for each
> errors.
Was there any followup on this? I think we should do as Masami suggests,
Naveen, could you do it?
Thanks,
- Arnaldo
> Thank you,
>
> > Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> > ---
> > tools/perf/builtin-probe.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> > index 6b150756677014..ff9f3fdce600dd 100644
> > --- a/tools/perf/builtin-probe.c
> > +++ b/tools/perf/builtin-probe.c
> > @@ -352,8 +352,11 @@ static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
> > }
> >
> > ret = apply_perf_probe_events(pevs, npevs);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pr_info("Hint: Check dmesg to understand reason for probe failure.\n"
> > + " Consider probing at the next/previous instruction.\n");
> > goto out_cleanup;
> > + }
> >
> > for (i = k = 0; i < npevs; i++)
> > k += pevs[i].ntevs;
> >
> > base-commit: 0808b3d5b7514dc856178dbc509929329bbf301d
> > --
> > 2.31.1
> >
>
>
> --
> Masami Hiramatsu <mhiramat@kernel.org>
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/perf probe: Print a hint if adding a probe fails
2021-06-18 13:15 ` Arnaldo Carvalho de Melo
@ 2021-06-21 9:40 ` Naveen N. Rao
0 siblings, 0 replies; 4+ messages in thread
From: Naveen N. Rao @ 2021-06-21 9:40 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Masami Hiramatsu; +Cc: Aneesh Kumar K.V, linux-kernel
Hi Arnaldo,
Arnaldo Carvalho de Melo wrote:
> Em Thu, Jun 10, 2021 at 07:29:26PM +0900, Masami Hiramatsu escreveu:
>> Hi Naveen,
>>
>> On Thu, 10 Jun 2021 15:14:42 +0530
>> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
>>
>> > Adding a probe can fail in a few scenarios. perf already checks for the
>> > address in the kprobe blacklist. However, the address could still be a
>> > jump label, or have a BUG_ON(). In such cases, it isn't always evident
>> > why adding the probe failed. Add a hint so that the user knows how to
>> > proceed.
>> >
>>
>> Thanks for the report.
>>
>> Since now there is <tracefs>/error_log, if you see any errors in registering
>> probe-events, perf probe should dump the error_log for the hint message.
>> Also, kprobes should return the correct different error code for each
>> errors.
>
> Was there any followup on this? I think we should do as Masami suggests,
> Naveen, could you do it?
Thanks for checking. We have been discussing this on the kernel side of
things here (sorry, missed copying you on that):
http://lkml.kernel.org/r/20210610085617.1590138-1-naveen.n.rao@linux.vnet.ibm.com
I will work on the related changes to perf after the kernel changes.
Thanks,
Naveen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-21 9:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 9:44 [PATCH] tools/perf probe: Print a hint if adding a probe fails Naveen N. Rao
2021-06-10 10:29 ` Masami Hiramatsu
2021-06-18 13:15 ` Arnaldo Carvalho de Melo
2021-06-21 9:40 ` Naveen N. Rao
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).