Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1572280 > unrolled thread

[PATCH 1/5] perf/sdt: Show proper hint

Started byRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
First post2017-02-02 12:20 +0100
Last post2017-02-10 08:50 +0100
Articles 10 — 5 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/5] perf/sdt: Show proper hint Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2017-02-02 12:20 +0100
    Re: [PATCH 1/5] perf/sdt: Show proper hint Ingo Molnar <mingo@kernel.org> - 2017-02-02 14:50 +0100
      Re: [PATCH 1/5] perf/sdt: Show proper hint Arnaldo Carvalho de Melo <acme@redhat.com> - 2017-02-02 17:30 +0100
        [PATCH v2] perf/sdt: Show proper hint Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2017-02-03 11:30 +0100
          Re: [PATCH v2] perf/sdt: Show proper hint Arnaldo Carvalho de Melo <acme@redhat.com> - 2017-02-03 16:20 +0100
            Re: [PATCH v2] perf/sdt: Show proper hint Ingo Molnar <mingo@kernel.org> - 2017-02-07 09:00 +0100
              Re: [PATCH v2] perf/sdt: Show proper hint Arnaldo Carvalho de Melo <acme@redhat.com> - 2017-02-07 17:00 +0100
            Re: [PATCH v2] perf/sdt: Show proper hint Ingo Molnar <mingo@kernel.org> - 2017-02-07 09:10 +0100
          Re: [PATCH v2] perf/sdt: Show proper hint Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-07 02:20 +0100
          [tip:perf/core] perf sdt: Show proper hint when event not yet in  place via 'perf probe' tip-bot for Ravi Bangoria <tipbot@zytor.com> - 2017-02-10 08:50 +0100

#1572280 — [PATCH 1/5] perf/sdt: Show proper hint

FromRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Date2017-02-02 12:20 +0100
Subject[PATCH 1/5] perf/sdt: Show proper hint
Message-ID<t6nAJ-3eT-5@gated-at.bofh.it>
All events from 'perf list', except SDT events, can be directly
recorded with 'perf record'. But, the flow is little different
for SDT events. User has to probe on SDT events before recording
them. Perf is showing misleading message when user tries to
record SDT event without probing it. Show proper hint there.

Before patch:
  $ perf record -a -e sdt_glib:idle__add
    event syntax error: 'sdt_glib:idle__add'
                     \___ unknown tracepoint

    Error:  File /sys/kernel/debug/tracing/events/sdt_glib/idle__add ...
    Hint:   Perhaps this kernel misses some CONFIG_ setting to enable...
    ...

After patch:
  $ perf record -e sdt_glib:main__after_check
    event syntax error: 'sdt_glib:idle__add'
                     \___ unknown tracepoint

    Error:  File /sys/kernel/debug/tracing/events/sdt_glib/idle__add ...
    Hint:   SDT event has to be probed before recording it.

Suggested-by: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
 tools/lib/api/fs/tracing_path.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 251b7c3..a0e85df 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -99,10 +99,18 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 		 * - jirka
 		 */
 		if (debugfs__configured() || tracefs__configured()) {
-			snprintf(buf, size,
-				 "Error:\tFile %s/%s not found.\n"
-				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 tracing_events_path, filename);
+			/* sdt markers */
+			if (!strncmp(filename, "sdt_", 4)) {
+				snprintf(buf, size,
+					"Error:\tFile %s/%s not found.\n"
+					"Hint:\tSDT event has to be probed before recording it.\n",
+					tracing_events_path, filename);
+			} else {
+				snprintf(buf, size,
+					 "Error:\tFile %s/%s not found.\n"
+					 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
+					 tracing_events_path, filename);
+			}
 			break;
 		}
 		snprintf(buf, size, "%s",
-- 
2.9.3

[toc] | [next] | [standalone]


#1572372

FromIngo Molnar <mingo@kernel.org>
Date2017-02-02 14:50 +0100
Message-ID<t6pVU-4Ix-1@gated-at.bofh.it>
In reply to#1572280
* Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> wrote:

> After patch:
>   $ perf record -e sdt_glib:main__after_check
>     event syntax error: 'sdt_glib:idle__add'
>                      \___ unknown tracepoint
> 
>     Error:  File /sys/kernel/debug/tracing/events/sdt_glib/idle__add ...
>     Hint:   SDT event has to be probed before recording it.

So what is the command line option to 'probe' an SDT event? Could you give an 
example that would make the above command work?

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1572504

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2017-02-02 17:30 +0100
Message-ID<t6sqK-6kI-21@gated-at.bofh.it>
In reply to#1572372
Em Thu, Feb 02, 2017 at 02:40:48PM +0100, Ingo Molnar escreveu:
> * Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> wrote:
 
> > After patch:
> >   $ perf record -e sdt_glib:main__after_check
> >     event syntax error: 'sdt_glib:idle__add'
> >                      \___ unknown tracepoint

> >     Error:  File /sys/kernel/debug/tracing/events/sdt_glib/idle__add ...
> >     Hint:   SDT event has to be probed before recording it.
> 
> So what is the command line option to 'probe' an SDT event? Could you give an 
> example that would make the above command work?

I also think 'has to be probed' looks confusing, it should be, I
suggest, "put in place using 'perf probe'", what will case it to really
be _probed_ is when it is activated via a tool like 'perf record'.

So yes, I think the message _and_ the example in this commit log must
show what needs to be done, in detail, to overcome the "problem"
mentioned in the message above.

And after that its up to someone to do the logical next step: if it
needs to be put in place, well, do it, automagically.

- Arnaldo

[toc] | [prev] | [next] | [standalone]


#1573004 — [PATCH v2] perf/sdt: Show proper hint

FromRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Date2017-02-03 11:30 +0100
Subject[PATCH v2] perf/sdt: Show proper hint
Message-ID<t6JhT-kD-3@gated-at.bofh.it>
In reply to#1572504
All events from 'perf list', except SDT events, can be directly recorded
with 'perf record'. But, the flow is little different for SDT events.
Probe point for SDT event needs to be created using 'perf probe' before
recording it using 'perf record'. Perf shows misleading hint when user
tries to record SDT event without creating a probe point. Show proper
hint there.

Before patch:
  $ perf record -a -e sdt_glib:idle__add
    event syntax error: 'sdt_glib:idle__add'
                         \___ unknown tracepoint

    Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
    Hint:  Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
    ...

After patch:
  $ perf record -a -e sdt_glib:idle__add
    event syntax error: 'sdt_glib:idle__add'
                         \___ unknown tracepoint

    Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
    Hint:  SDT event cannot be directly recorded on. Please use 'perf probe sdt_glib:idle__add' before recording it.
    ...

  $ perf probe sdt_glib:idle__add
    Added new event:
      sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)

    You can now use it in all perf tools, such as:

        perf record -e sdt_glib:idle__add -aR sleep 1

  $ perf record -a -e sdt_glib:idle__add
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.175 MB perf.data ]

Suggested-by: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
Changes in v2:
  - More precise hint

 tools/lib/api/fs/tracing_path.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 251b7c3..aaafc99 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -86,9 +86,13 @@ void put_tracing_file(char *file)
 	free(file);
 }
 
-static int strerror_open(int err, char *buf, size_t size, const char *filename)
+int tracing_path__strerror_open_tp(int err, char *buf, size_t size,
+				   const char *sys, const char *name)
 {
 	char sbuf[128];
+	char filename[PATH_MAX];
+
+	snprintf(filename, PATH_MAX, "%s/%s", sys, name ?: "*");
 
 	switch (err) {
 	case ENOENT:
@@ -99,10 +103,18 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 		 * - jirka
 		 */
 		if (debugfs__configured() || tracefs__configured()) {
-			snprintf(buf, size,
-				 "Error:\tFile %s/%s not found.\n"
-				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 tracing_events_path, filename);
+			/* sdt markers */
+			if (!strncmp(filename, "sdt_", 4)) {
+				snprintf(buf, size,
+					"Error:\tFile %s/%s not found.\n"
+					"Hint:\tSDT event cannot be directly recorded on. Please use 'perf probe %s:%s' before recording it.\n",
+					tracing_events_path, filename, sys, name);
+			} else {
+				snprintf(buf, size,
+					 "Error:\tFile %s/%s not found.\n"
+					 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
+					 tracing_events_path, filename);
+			}
 			break;
 		}
 		snprintf(buf, size, "%s",
@@ -125,12 +137,3 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
 	return 0;
 }
-
-int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
-{
-	char path[PATH_MAX];
-
-	snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
-
-	return strerror_open(err, buf, size, path);
-}
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1573154 — Re: [PATCH v2] perf/sdt: Show proper hint

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2017-02-03 16:20 +0100
SubjectRe: [PATCH v2] perf/sdt: Show proper hint
Message-ID<t6NOz-3bO-39@gated-at.bofh.it>
In reply to#1573004
Em Fri, Feb 03, 2017 at 03:56:42PM +0530, Ravi Bangoria escreveu:
> After patch:
>   $ perf record -a -e sdt_glib:idle__add
>     event syntax error: 'sdt_glib:idle__add'
>                          \___ unknown tracepoint
> 
>     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
>     Hint:  SDT event cannot be directly recorded on. Please use 'perf probe sdt_glib:idle__add' before recording it.
>     ...
> 
>   $ perf probe sdt_glib:idle__add
>     Added new event:
>       sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)
> 
>     You can now use it in all perf tools, such as:
> 
>         perf record -e sdt_glib:idle__add -aR sleep 1
> 
>   $ perf record -a -e sdt_glib:idle__add
>     [ perf record: Woken up 1 times to write data ]
>     [ perf record: Captured and wrote 0.175 MB perf.data ]

Looks much better! Thanks!

Unsure if we should state somewhere that this needs to be done only once
per boot.

Ingo, are you ok now? Ack?

- Arnaldo

[toc] | [prev] | [next] | [standalone]


#1575436 — Re: [PATCH v2] perf/sdt: Show proper hint

FromIngo Molnar <mingo@kernel.org>
Date2017-02-07 09:00 +0100
SubjectRe: [PATCH v2] perf/sdt: Show proper hint
Message-ID<t88QV-8pr-7@gated-at.bofh.it>
In reply to#1573154
* Arnaldo Carvalho de Melo <acme@redhat.com> wrote:

> Em Fri, Feb 03, 2017 at 03:56:42PM +0530, Ravi Bangoria escreveu:
> > After patch:
> >   $ perf record -a -e sdt_glib:idle__add
> >     event syntax error: 'sdt_glib:idle__add'
> >                          \___ unknown tracepoint
> > 
> >     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
> >     Hint:  SDT event cannot be directly recorded on. Please use 'perf probe sdt_glib:idle__add' before recording it.
> >     ...
> > 
> >   $ perf probe sdt_glib:idle__add
> >     Added new event:
> >       sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)
> > 
> >     You can now use it in all perf tools, such as:
> > 
> >         perf record -e sdt_glib:idle__add -aR sleep 1
> > 
> >   $ perf record -a -e sdt_glib:idle__add
> >     [ perf record: Woken up 1 times to write data ]
> >     [ perf record: Captured and wrote 0.175 MB perf.data ]
> 
> Looks much better! Thanks!
> 
> Unsure if we should state somewhere that this needs to be done only once
> per boot.
> 
> Ingo, are you ok now? Ack?

Yeah, looks perfect to me!

Acked-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1575820 — Re: [PATCH v2] perf/sdt: Show proper hint

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2017-02-07 17:00 +0100
SubjectRe: [PATCH v2] perf/sdt: Show proper hint
Message-ID<t8gls-4NN-35@gated-at.bofh.it>
In reply to#1575436
Em Tue, Feb 07, 2017 at 08:53:56AM +0100, Ingo Molnar escreveu:
> 
> * Arnaldo Carvalho de Melo <acme@redhat.com> wrote:
> 
> > Em Fri, Feb 03, 2017 at 03:56:42PM +0530, Ravi Bangoria escreveu:
> > > After patch:
> > >   $ perf record -a -e sdt_glib:idle__add
> > >     event syntax error: 'sdt_glib:idle__add'
> > >                          \___ unknown tracepoint
> > > 
> > >     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
> > >     Hint:  SDT event cannot be directly recorded on. Please use 'perf probe sdt_glib:idle__add' before recording it.
> > >     ...
> > > 
> > >   $ perf probe sdt_glib:idle__add
> > >     Added new event:
> > >       sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)
> > > 
> > >     You can now use it in all perf tools, such as:
> > > 
> > >         perf record -e sdt_glib:idle__add -aR sleep 1
> > > 
> > >   $ perf record -a -e sdt_glib:idle__add
> > >     [ perf record: Woken up 1 times to write data ]
> > >     [ perf record: Captured and wrote 0.175 MB perf.data ]
> > 
> > Looks much better! Thanks!
> > 
> > Unsure if we should state somewhere that this needs to be done only once
> > per boot.
> > 
> > Ingo, are you ok now? Ack?
> 
> Yeah, looks perfect to me!
> 
> Acked-by: Ingo Molnar <mingo@kernel.org>

Thanks, added that "first" and split the Hint line in two.

Automagically setting it up, doing the perf probe and rendering the
above comment irrelevant remains as a task to be performed.

- Arnaldo

[toc] | [prev] | [next] | [standalone]


#1575441 — Re: [PATCH v2] perf/sdt: Show proper hint

FromIngo Molnar <mingo@kernel.org>
Date2017-02-07 09:10 +0100
SubjectRe: [PATCH v2] perf/sdt: Show proper hint
Message-ID<t890B-gF-7@gated-at.bofh.it>
In reply to#1573154
* Arnaldo Carvalho de Melo <acme@redhat.com> wrote:

> Em Fri, Feb 03, 2017 at 03:56:42PM +0530, Ravi Bangoria escreveu:
> > After patch:
> >   $ perf record -a -e sdt_glib:idle__add
> >     event syntax error: 'sdt_glib:idle__add'
> >                          \___ unknown tracepoint
> > 
> >     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
> >     Hint:  SDT event cannot be directly recorded on. Please use 'perf probe sdt_glib:idle__add' before recording it.
> >     ...
> > 
> >   $ perf probe sdt_glib:idle__add
> >     Added new event:
> >       sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)
> > 
> >     You can now use it in all perf tools, such as:
> > 
> >         perf record -e sdt_glib:idle__add -aR sleep 1
> > 
> >   $ perf record -a -e sdt_glib:idle__add
> >     [ perf record: Woken up 1 times to write data ]
> >     [ perf record: Captured and wrote 0.175 MB perf.data ]
> 
> Looks much better! Thanks!
> 
> Unsure if we should state somewhere that this needs to be done only once
> per boot.

Forgot to reply to your question - indeed I agree that something like this would 
be even better:

   $ perf record -a -e sdt_glib:idle__add
     event syntax error: 'sdt_glib:idle__add'
                          \___ unknown tracepoint
 
     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
     Hint:  SDT event cannot be directly recorded on.
            Please first use 'perf probe sdt_glib:idle__add' before recording it.

BTW., and I think this is fundamental: why is this interim step forced upon the 
user - cannot we just auto-enable it if it's not enabled yet?

If for some reason it's important for the user to know that we enabled a probe we 
could print that we did so:

     Info: enabling not yet enabled 'perf probe sdt_glib:idle__add' SDT event.

... and that would be even more usable.

A tool printing out the perfect thing for the user to type in is a sign that the 
tool should have done this itself.

See for example how Git handles the bisection workflow. Technically the following 
is required to start a bisection:

  triton:~/tip> git bisect start
  triton:~/tip> git bisect bad
  triton:~/tip> 

But you can also do:

  triton:~/tip> git bisect bad
  You need to start by "git bisect start"
  Do you want me to do it for you [Y/n]? 
  triton:~/tip> 

and the user can start the bisection by hitting Enter.

No fuss, no unnecessary resistance from tooling - and the user is fully informed 
all along. Every extra tooling step forced upon users annoys them and shrinks the 
potential userbase.

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1575310 — Re: [PATCH v2] perf/sdt: Show proper hint

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2017-02-07 02:20 +0100
SubjectRe: [PATCH v2] perf/sdt: Show proper hint
Message-ID<t82BQ-4jX-11@gated-at.bofh.it>
In reply to#1573004
On Fri,  3 Feb 2017 15:56:42 +0530
Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> wrote:

> All events from 'perf list', except SDT events, can be directly recorded
> with 'perf record'. But, the flow is little different for SDT events.
> Probe point for SDT event needs to be created using 'perf probe' before
> recording it using 'perf record'. Perf shows misleading hint when user
> tries to record SDT event without creating a probe point. Show proper
> hint there.
> 
> Before patch:
>   $ perf record -a -e sdt_glib:idle__add
>     event syntax error: 'sdt_glib:idle__add'
>                          \___ unknown tracepoint
> 
>     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
>     Hint:  Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
>     ...
> 
> After patch:
>   $ perf record -a -e sdt_glib:idle__add
>     event syntax error: 'sdt_glib:idle__add'
>                          \___ unknown tracepoint
> 
>     Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
>     Hint:  SDT event cannot be directly recorded on. Please use 'perf probe sdt_glib:idle__add' before recording it.
>     ...
> 
>   $ perf probe sdt_glib:idle__add
>     Added new event:
>       sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)
> 
>     You can now use it in all perf tools, such as:
> 
>         perf record -e sdt_glib:idle__add -aR sleep 1
> 
>   $ perf record -a -e sdt_glib:idle__add
>     [ perf record: Woken up 1 times to write data ]
>     [ perf record: Captured and wrote 0.175 MB perf.data ]
> 

Looks good to me:)

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks!

> Suggested-by: Ingo Molnar <mingo@redhat.com>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
> Changes in v2:
>   - More precise hint
> 
>  tools/lib/api/fs/tracing_path.c | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> index 251b7c3..aaafc99 100644
> --- a/tools/lib/api/fs/tracing_path.c
> +++ b/tools/lib/api/fs/tracing_path.c
> @@ -86,9 +86,13 @@ void put_tracing_file(char *file)
>  	free(file);
>  }
>  
> -static int strerror_open(int err, char *buf, size_t size, const char *filename)
> +int tracing_path__strerror_open_tp(int err, char *buf, size_t size,
> +				   const char *sys, const char *name)
>  {
>  	char sbuf[128];
> +	char filename[PATH_MAX];
> +
> +	snprintf(filename, PATH_MAX, "%s/%s", sys, name ?: "*");
>  
>  	switch (err) {
>  	case ENOENT:
> @@ -99,10 +103,18 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
>  		 * - jirka
>  		 */
>  		if (debugfs__configured() || tracefs__configured()) {
> -			snprintf(buf, size,
> -				 "Error:\tFile %s/%s not found.\n"
> -				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
> -				 tracing_events_path, filename);
> +			/* sdt markers */
> +			if (!strncmp(filename, "sdt_", 4)) {
> +				snprintf(buf, size,
> +					"Error:\tFile %s/%s not found.\n"
> +					"Hint:\tSDT event cannot be directly recorded on. Please use 'perf probe %s:%s' before recording it.\n",
> +					tracing_events_path, filename, sys, name);
> +			} else {
> +				snprintf(buf, size,
> +					 "Error:\tFile %s/%s not found.\n"
> +					 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
> +					 tracing_events_path, filename);
> +			}
>  			break;
>  		}
>  		snprintf(buf, size, "%s",
> @@ -125,12 +137,3 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
>  
>  	return 0;
>  }
> -
> -int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
> -{
> -	char path[PATH_MAX];
> -
> -	snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
> -
> -	return strerror_open(err, buf, size, path);
> -}
> -- 
> 2.9.3
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [next] | [standalone]


#1578237 — [tip:perf/core] perf sdt: Show proper hint when event not yet in place via 'perf probe'

Fromtip-bot for Ravi Bangoria <tipbot@zytor.com>
Date2017-02-10 08:50 +0100
Subject[tip:perf/core] perf sdt: Show proper hint when event not yet in place via 'perf probe'
Message-ID<t9e7T-tH-19@gated-at.bofh.it>
In reply to#1573004
Commit-ID:  27cf5706a04e53f6844c71be1cbbf1df665f5d19
Gitweb:     http://git.kernel.org/tip/27cf5706a04e53f6844c71be1cbbf1df665f5d19
Author:     Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
AuthorDate: Fri, 3 Feb 2017 15:56:42 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 8 Feb 2017 09:28:54 -0300

perf sdt: Show proper hint when event not yet in place via 'perf probe'

All events from 'perf list', except SDT events, can be directly recorded
with 'perf record'. But, the flow is little different for SDT events.

Probe points for SDT event needs to be created using 'perf probe' before
recording it using 'perf record'.

Perf shows misleading hint when a user tries to record SDT event without
first creating a probe point. Show proper hint there.

Before patch:

  $ perf record -a -e sdt_glib:idle__add
    event syntax error: 'sdt_glib:idle__add'
                         \___ unknown tracepoint

    Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
    Hint:  Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
    ...

After patch:

  $ perf record -a -e sdt_glib:idle__add
    event syntax error: 'sdt_glib:idle__add'
                         \___ unknown tracepoint

    Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
    Hint:  SDT event cannot be directly recorded on.
           Please first use 'perf probe sdt_glib:idle__add' before recording it.
    ...

  $ perf probe sdt_glib:idle__add
    Added new event:
      sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)

    You can now use it in all perf tools, such as:

        perf record -e sdt_glib:idle__add -aR sleep 1

  $ perf record -a -e sdt_glib:idle__add
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.175 MB perf.data ]

Suggested-and-Acked-by: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170203102642.17258-1-ravi.bangoria@linux.vnet.ibm.com
[ s/Please use/Please first use/ and break the Hint line in two ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/tracing_path.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 251b7c3..3e606b9 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -86,9 +86,13 @@ void put_tracing_file(char *file)
 	free(file);
 }
 
-static int strerror_open(int err, char *buf, size_t size, const char *filename)
+int tracing_path__strerror_open_tp(int err, char *buf, size_t size,
+				   const char *sys, const char *name)
 {
 	char sbuf[128];
+	char filename[PATH_MAX];
+
+	snprintf(filename, PATH_MAX, "%s/%s", sys, name ?: "*");
 
 	switch (err) {
 	case ENOENT:
@@ -99,10 +103,19 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 		 * - jirka
 		 */
 		if (debugfs__configured() || tracefs__configured()) {
-			snprintf(buf, size,
-				 "Error:\tFile %s/%s not found.\n"
-				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 tracing_events_path, filename);
+			/* sdt markers */
+			if (!strncmp(filename, "sdt_", 4)) {
+				snprintf(buf, size,
+					"Error:\tFile %s/%s not found.\n"
+					"Hint:\tSDT event cannot be directly recorded on.\n"
+					"\tPlease first use 'perf probe %s:%s' before recording it.\n",
+					tracing_events_path, filename, sys, name);
+			} else {
+				snprintf(buf, size,
+					 "Error:\tFile %s/%s not found.\n"
+					 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
+					 tracing_events_path, filename);
+			}
 			break;
 		}
 		snprintf(buf, size, "%s",
@@ -125,12 +138,3 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
 	return 0;
 }
-
-int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
-{
-	char path[PATH_MAX];
-
-	snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
-
-	return strerror_open(err, buf, size, path);
-}

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web