* [PATCH] perf tool: report user-friendly error from timechart
@ 2013-10-03 9:05 Ramkumar Ramachandra
2013-10-03 12:38 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Ramkumar Ramachandra @ 2013-10-03 9:05 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Jiri Olsa, Arnaldo Carvalho de Melo
Earlier, when 'timechart record' was invoked by a user without
permissions to debugfs:
$ perf timechart record
invalid or unsupported event: 'power:cpu_frequency'
Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
[... detailed usage information ...]
This is highly user unfriendly, as the real problem is not reported to
the user correctly. Now, the user gets a much more friendly:
$ perf timechart record
Error: No permissions to read $debugfs/tracing/events/power/cpu_frequency
Hint: Change the permissions of debugfs: /sys/kernel/debug
The directory will be present if your kernel was compiled with debugfs support.
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
tools/perf/builtin-timechart.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index c2e0231..ceaf9b8 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1056,6 +1056,14 @@ static int __cmd_record(int argc, const char **argv)
}
#endif
+ /* Perform a quick sanity check */
+ if (!is_valid_tracepoint("power:cpu_frequency")) {
+ fprintf(stderr, "Error:\tNo permissions to read $debugfs/tracing/events/power/cpu_frequency\n");
+ fprintf(stderr, "Hint:\tChange the permissions of debugfs: /sys/kernel/debug\n");
+ fprintf(stderr, "\tThe directory will be present if your kernel was compiled with debugfs support.\n");
+ return 1;
+ }
+
rec_argc = record_elems + argc - 1;
rec_argv = calloc(rec_argc + 1, sizeof(char *));
--
1.8.4.477.g5d89aa9
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] perf tool: report user-friendly error from timechart
2013-10-03 9:05 [PATCH] perf tool: report user-friendly error from timechart Ramkumar Ramachandra
@ 2013-10-03 12:38 ` Ingo Molnar
2013-10-03 12:43 ` Ramkumar Ramachandra
2013-10-03 13:35 ` David Ahern
0 siblings, 2 replies; 7+ messages in thread
From: Ingo Molnar @ 2013-10-03 12:38 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: LKML, Jiri Olsa, Arnaldo Carvalho de Melo
* Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> + /* Perform a quick sanity check */
> + if (!is_valid_tracepoint("power:cpu_frequency")) {
> + fprintf(stderr, "Error:\tNo permissions to read $debugfs/tracing/events/power/cpu_frequency\n");
> + fprintf(stderr, "Hint:\tChange the permissions of debugfs: /sys/kernel/debug\n");
> + fprintf(stderr, "\tThe directory will be present if your kernel was compiled with debugfs support.\n");
Is missing permissions the only way how is_valid_tracepoint() can fail?
What if debugfs has the right permissions but CONFIG_TRACEPOINTS is
disabled in the kernel?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] perf tool: report user-friendly error from timechart
2013-10-03 12:38 ` Ingo Molnar
@ 2013-10-03 12:43 ` Ramkumar Ramachandra
2013-10-03 13:09 ` Ingo Molnar
2013-10-03 13:35 ` David Ahern
1 sibling, 1 reply; 7+ messages in thread
From: Ramkumar Ramachandra @ 2013-10-03 12:43 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, Jiri Olsa, Arnaldo Carvalho de Melo
Ingo Molnar wrote:
>> + /* Perform a quick sanity check */
>> + if (!is_valid_tracepoint("power:cpu_frequency")) {
>> + fprintf(stderr, "Error:\tNo permissions to read $debugfs/tracing/events/power/cpu_frequency\n");
>> + fprintf(stderr, "Hint:\tChange the permissions of debugfs: /sys/kernel/debug\n");
>> + fprintf(stderr, "\tThe directory will be present if your kernel was compiled with debugfs support.\n");
>
> Is missing permissions the only way how is_valid_tracepoint() can fail?
>
> What if debugfs has the right permissions but CONFIG_TRACEPOINTS is
> disabled in the kernel?
I'm thinking about all this in terms of files present in debugfs. Will
the cpu_frequecy file be present if tracepoints is disabled? (should I
quickly check using User-Mode Linux?). If it won't be present, then we
can just change the last line to "compiled with debugfs and
tracepoints support".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] perf tool: report user-friendly error from timechart
2013-10-03 12:43 ` Ramkumar Ramachandra
@ 2013-10-03 13:09 ` Ingo Molnar
0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2013-10-03 13:09 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: LKML, Jiri Olsa, Arnaldo Carvalho de Melo
* Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Ingo Molnar wrote:
> >> + /* Perform a quick sanity check */
> >> + if (!is_valid_tracepoint("power:cpu_frequency")) {
> >> + fprintf(stderr, "Error:\tNo permissions to read $debugfs/tracing/events/power/cpu_frequency\n");
> >> + fprintf(stderr, "Hint:\tChange the permissions of debugfs: /sys/kernel/debug\n");
> >> + fprintf(stderr, "\tThe directory will be present if your kernel was compiled with debugfs support.\n");
> >
> > Is missing permissions the only way how is_valid_tracepoint() can fail?
> >
> > What if debugfs has the right permissions but CONFIG_TRACEPOINTS is
> > disabled in the kernel?
>
> I'm thinking about all this in terms of files present in debugfs. Will
> the cpu_frequecy file be present if tracepoints is disabled? (should I
> quickly check using User-Mode Linux?). If it won't be present, then we
> can just change the last line to "compiled with debugfs and tracepoints
> support".
The debug/tracing/events directory won't be present if tracing is
disabled.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] perf tool: report user-friendly error from timechart
2013-10-03 12:38 ` Ingo Molnar
2013-10-03 12:43 ` Ramkumar Ramachandra
@ 2013-10-03 13:35 ` David Ahern
2013-10-03 17:08 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 7+ messages in thread
From: David Ahern @ 2013-10-03 13:35 UTC (permalink / raw)
To: Ingo Molnar, Ramkumar Ramachandra
Cc: LKML, Jiri Olsa, Arnaldo Carvalho de Melo
On 10/3/13 6:38 AM, Ingo Molnar wrote:
>
> * Ramkumar Ramachandra <artagnon@gmail.com> wrote:
>
>> + /* Perform a quick sanity check */
>> + if (!is_valid_tracepoint("power:cpu_frequency")) {
>> + fprintf(stderr, "Error:\tNo permissions to read $debugfs/tracing/events/power/cpu_frequency\n");
>> + fprintf(stderr, "Hint:\tChange the permissions of debugfs: /sys/kernel/debug\n");
>> + fprintf(stderr, "\tThe directory will be present if your kernel was compiled with debugfs support.\n");
>
> Is missing permissions the only way how is_valid_tracepoint() can fail?
>
> What if debugfs has the right permissions but CONFIG_TRACEPOINTS is
> disabled in the kernel?
There are a number of reasons that function can fail. The complete
solution is to plumb various error numbers and on failure request a
string for that failure. Take a look at util/target.[ch] as an example.
The comment applies to the perf-trace patch as well, but it gets more
complicated to handle the error paths from perf_evsel__newtp when they
dip into the tracepoint code
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] perf tool: report user-friendly error from timechart
2013-10-03 13:35 ` David Ahern
@ 2013-10-03 17:08 ` Arnaldo Carvalho de Melo
2013-10-03 17:22 ` David Ahern
0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-03 17:08 UTC (permalink / raw)
To: David Ahern; +Cc: Ingo Molnar, Ramkumar Ramachandra, LKML, Jiri Olsa
Em Thu, Oct 03, 2013 at 07:35:18AM -0600, David Ahern escreveu:
> On 10/3/13 6:38 AM, Ingo Molnar wrote:
> >
> >* Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> >
> >>+ /* Perform a quick sanity check */
> >>+ if (!is_valid_tracepoint("power:cpu_frequency")) {
> >>+ fprintf(stderr, "Error:\tNo permissions to read $debugfs/tracing/events/power/cpu_frequency\n");
> >>+ fprintf(stderr, "Hint:\tChange the permissions of debugfs: /sys/kernel/debug\n");
> >>+ fprintf(stderr, "\tThe directory will be present if your kernel was compiled with debugfs support.\n");
> >
> >Is missing permissions the only way how is_valid_tracepoint() can fail?
> >
> >What if debugfs has the right permissions but CONFIG_TRACEPOINTS is
> >disabled in the kernel?
>
> There are a number of reasons that function can fail. The complete
> solution is to plumb various error numbers and on failure request a
> string for that failure. Take a look at util/target.[ch] as an
> example.
>
> The comment applies to the perf-trace patch as well, but it gets
> more complicated to handle the error paths from perf_evsel__newtp
> when they dip into the tracepoint code
See the patch I posted, in that case we can use the old errno way, i.e.
do nothing and just look at it in the perf_evsel__newtp/
perf_evlist__add_newtp callers.
And is_valid_tracepoint() is a too big hammer, it traverses the whole
directory looking for a match instead of plain build the path and do an
access, its one of those things I need to ditch at some point. So far I
just try to do a perf_evlist__add_newtp and if it fails, look at errno.
- Arnaldo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] perf tool: report user-friendly error from timechart
2013-10-03 17:08 ` Arnaldo Carvalho de Melo
@ 2013-10-03 17:22 ` David Ahern
0 siblings, 0 replies; 7+ messages in thread
From: David Ahern @ 2013-10-03 17:22 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Ramkumar Ramachandra, LKML, Jiri Olsa
On 10/3/13 11:08 AM, Arnaldo Carvalho de Melo wrote:
> And is_valid_tracepoint() is a too big hammer, it traverses the whole
> directory looking for a match instead of plain build the path and do an
> access, its one of those things I need to ditch at some point. So far I
> just try to do a perf_evlist__add_newtp and if it fails, look at errno.
And a number of tracepoints depend on CONFIG settings so it is more than
just looking at whether debugfs is mounted and accessible/readable.
e.g., look at the message I put into perf-lock
David
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-10-03 17:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-03 9:05 [PATCH] perf tool: report user-friendly error from timechart Ramkumar Ramachandra
2013-10-03 12:38 ` Ingo Molnar
2013-10-03 12:43 ` Ramkumar Ramachandra
2013-10-03 13:09 ` Ingo Molnar
2013-10-03 13:35 ` David Ahern
2013-10-03 17:08 ` Arnaldo Carvalho de Melo
2013-10-03 17:22 ` David Ahern
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.