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


Groups > linux.kernel > #1430498 > unrolled thread

[PATCH perf/core v12 00/16] perf-probe --cache and SDT support

Started byMasami Hiramatsu <mhiramat@kernel.org>
First post2016-06-24 11:10 +0200
Last post2016-06-25 01:50 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH perf/core v12 00/16] perf-probe --cache and SDT support Masami Hiramatsu <mhiramat@kernel.org> - 2016-06-24 11:10 +0200
    [PATCH perf/core v12 14/16] perf probe: Support a special SDT probe format Masami Hiramatsu <mhiramat@kernel.org> - 2016-06-24 11:10 +0200
    Re: [PATCH perf/core v12 00/16] perf-probe --cache and SDT support Brendan Gregg <brendan.d.gregg@gmail.com> - 2016-06-24 22:30 +0200
      Re: [PATCH perf/core v12 00/16] perf-probe --cache and SDT support Masami Hiramatsu <mhiramat@kernel.org> - 2016-06-25 01:50 +0200

#1430498 — [PATCH perf/core v12 00/16] perf-probe --cache and SDT support

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-06-24 11:10 +0200
Subject[PATCH perf/core v12 00/16] perf-probe --cache and SDT support
Message-ID<rNvhD-6a1-5@gated-at.bofh.it>
Hi,

Here is the 12th version of the patchset for probe-cache and 
initial SDT support.

Here is the previous v11: https://lkml.org/lkml/2016/6/14/1041

In this version I just rename strlist__for_each to
strlist__for_each_entry, and change some patch description.

Thank you,

---

Hemant Kumar (1):
      perf/sdt: ELF support for SDT

Masami Hiramatsu (15):
      perf probe: Use cache entry if possible
      perf probe: Show all cached probes
      perf probe: Remove caches when --cache is given
      perf probe: Add group name support
      perf buildid-cache: Scan and import user SDT events to probe cache
      perf probe: Accept %sdt and %cached event name
      perf-list: Show SDT and pre-cached events
      perf-list: Skip SDTs placed in invalid binaries
      perf: probe-cache: Add for_each_probe_cache_entry() wrapper
      perf probe: Allow wildcard for cached events
      perf probe: Search SDT/cached event from all probe caches
      perf probe: Support @BUILDID or @FILE suffix for SDT events
      perf probe: Support a special SDT probe format
      perf build: Add sdt feature detection
      perf-test: Add a test case for SDT event


 tools/perf/Documentation/perf-buildid-cache.txt |    3 
 tools/perf/Documentation/perf-probe.txt         |   30 +-
 tools/perf/Makefile.perf                        |    3 
 tools/perf/builtin-list.c                       |    6 
 tools/perf/builtin-probe.c                      |   31 ++
 tools/perf/config/Makefile                      |   10 +
 tools/perf/tests/Build                          |    1 
 tools/perf/tests/builtin-test.c                 |    4 
 tools/perf/tests/make                           |    3 
 tools/perf/tests/sdt.c                          |  115 +++++++
 tools/perf/tests/tests.h                        |    1 
 tools/perf/util/build-id.c                      |  212 +++++++++++++
 tools/perf/util/build-id.h                      |    4 
 tools/perf/util/parse-events.c                  |   82 +++++
 tools/perf/util/parse-events.h                  |    2 
 tools/perf/util/probe-event.c                   |  366 +++++++++++++++++++++--
 tools/perf/util/probe-event.h                   |    1 
 tools/perf/util/probe-file.c                    |  226 +++++++++++++-
 tools/perf/util/probe-file.h                    |   24 +-
 tools/perf/util/symbol-elf.c                    |  252 ++++++++++++++++
 tools/perf/util/symbol.h                        |   22 +
 21 files changed, 1333 insertions(+), 65 deletions(-)
 create mode 100644 tools/perf/tests/sdt.c

--
Masami Hiramatsu

[toc] | [next] | [standalone]


#1430499 — [PATCH perf/core v12 14/16] perf probe: Support a special SDT probe format

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-06-24 11:10 +0200
Subject[PATCH perf/core v12 14/16] perf probe: Support a special SDT probe format
Message-ID<rNvhF-6a1-63@gated-at.bofh.it>
In reply to#1430498
Support a special SDT probe format which can omit the '%' prefix
only if the SDT group name starts with "sdt_". So, for example
both of "%sdt_libc:setjump" and "sdt_libc:setjump" are acceptable
for perf probe --add.

E.g. without this:
  ----
  # perf probe -a sdt_libc:setjmp
  Semantic error :There is non-digit char in line number.
  ...
  ----
With this:
  ----
  # perf probe -a sdt_libc:setjmp
  Added new event:
    sdt_libc:setjmp      (on %setjmp in /usr/lib64/libc-2.20.so)

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

  	perf record -e sdt_libc:setjmp -aR sleep 1
  ----

Suggested-by: Brendan Gregg <brendan.d.gregg@gmail.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/Documentation/perf-probe.txt |    4 +++-
 tools/perf/util/probe-event.c           |   12 ++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index 39e3870..736da44 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -152,7 +152,9 @@ Probe points are defined by following syntax.
      [[GROUP:]EVENT=]SRC;PTN [ARG ...]
 
     4) Pre-defined SDT events or cached event with name
-     %[PROVIDER:]SDTEVENT
+     %[sdt_PROVIDER:]SDTEVENT
+     or,
+     sdt_PROVIDER:SDTEVENT
 
 'EVENT' specifies the name of new event, if omitted, it will be set the name of the probed function. You can also specify a group name by 'GROUP', if omitted, set 'probe' is used for kprobe and 'probe_<bin>' is used for uprobe.
 Note that using existing group name can conflict with other events. Especially, using the group name reserved for kernel modules can hide embedded events in the
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b38548c..8b4fb63 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1243,9 +1243,17 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
 	if (!arg)
 		return -EINVAL;
 
-	if (arg[0] == '%') {
+	/*
+	 * If the probe point starts with '%',
+	 * or starts with "sdt_" and has a ':' but no '=',
+	 * then it should be a SDT/cached probe point.
+	 */
+	if (arg[0] == '%' ||
+	    (!strncmp(arg, "sdt_", 4) &&
+	     !!strchr(arg, ':') && !strchr(arg, '='))) {
 		pev->sdt = true;
-		arg++;
+		if (arg[0] == '%')
+			arg++;
 	}
 
 	ptr = strpbrk(arg, ";=@+%");

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


#1430928

FromBrendan Gregg <brendan.d.gregg@gmail.com>
Date2016-06-24 22:30 +0200
Message-ID<rNFTI-4ti-21@gated-at.bofh.it>
In reply to#1430498
On Fri, Jun 24, 2016 at 2:05 AM, Masami Hiramatsu <mhiramat@kernel.org> wrote:
> Hi,
>
> Here is the 12th version of the patchset for probe-cache and
> initial SDT support.
>
> Here is the previous v11: https://lkml.org/lkml/2016/6/14/1041
>
> In this version I just rename strlist__for_each to
> strlist__for_each_entry, and change some patch description.
>

I tested it on Node.js (and applied to acme's perf/core), and it works. Thanks!

# perf script
            node 36750 [006]  3080.761533:
sdt_node:http__server__request: (da8b0c)
            node 36750 [006]  3081.368771:
sdt_node:http__server__request: (da8b0c)
            node 36750 [006]  3081.592925:
sdt_node:http__server__request: (da8b0c)
            node 36750 [006]  3081.976802:
sdt_node:http__server__request: (da8b0c)
            node 36750 [006]  3082.296709:
sdt_node:http__server__request: (da8b0c)

Since it doesn't set the is-enabled semaphore yet, I had to do that
manually for the probes that use it. I know that will be a latter
addition.

# perf list | grep sdt
  sdt_node:http__client__request                     [Tracepoint event]
  sdt_node:http__server__request                     [Tracepoint event]
  sdt_node:gc__done                                  [SDT event]
  sdt_node:gc__start                                 [SDT event]
  sdt_node:http__client__request                     [SDT event]
  sdt_node:http__client__response                    [SDT event]
  sdt_node:http__server__request                     [SDT event]
  sdt_node:http__server__response                    [SDT event]
  sdt_node:net__server__connection                   [SDT event]
  sdt_node:net__stream__end                          [SDT event]

It's also a bit weird to see these listed twice, but I understand
what's happening. If this continues to prove confusing, I guess later
on we could change it to exclude listing SDT events that have been
promoted to Tracepoint events, or not list SDT events in "perf list"
at all, leaving them for "perf probe --cache --list".

Anyway, this is great as is, and thanks again.

Brendan


> Thank you,
>
> ---
>
> Hemant Kumar (1):
>       perf/sdt: ELF support for SDT
>
> Masami Hiramatsu (15):
>       perf probe: Use cache entry if possible
>       perf probe: Show all cached probes
>       perf probe: Remove caches when --cache is given
>       perf probe: Add group name support
>       perf buildid-cache: Scan and import user SDT events to probe cache
>       perf probe: Accept %sdt and %cached event name
>       perf-list: Show SDT and pre-cached events
>       perf-list: Skip SDTs placed in invalid binaries
>       perf: probe-cache: Add for_each_probe_cache_entry() wrapper
>       perf probe: Allow wildcard for cached events
>       perf probe: Search SDT/cached event from all probe caches
>       perf probe: Support @BUILDID or @FILE suffix for SDT events
>       perf probe: Support a special SDT probe format
>       perf build: Add sdt feature detection
>       perf-test: Add a test case for SDT event
>
>
>  tools/perf/Documentation/perf-buildid-cache.txt |    3
>  tools/perf/Documentation/perf-probe.txt         |   30 +-
>  tools/perf/Makefile.perf                        |    3
>  tools/perf/builtin-list.c                       |    6
>  tools/perf/builtin-probe.c                      |   31 ++
>  tools/perf/config/Makefile                      |   10 +
>  tools/perf/tests/Build                          |    1
>  tools/perf/tests/builtin-test.c                 |    4
>  tools/perf/tests/make                           |    3
>  tools/perf/tests/sdt.c                          |  115 +++++++
>  tools/perf/tests/tests.h                        |    1
>  tools/perf/util/build-id.c                      |  212 +++++++++++++
>  tools/perf/util/build-id.h                      |    4
>  tools/perf/util/parse-events.c                  |   82 +++++
>  tools/perf/util/parse-events.h                  |    2
>  tools/perf/util/probe-event.c                   |  366 +++++++++++++++++++++--
>  tools/perf/util/probe-event.h                   |    1
>  tools/perf/util/probe-file.c                    |  226 +++++++++++++-
>  tools/perf/util/probe-file.h                    |   24 +-
>  tools/perf/util/symbol-elf.c                    |  252 ++++++++++++++++
>  tools/perf/util/symbol.h                        |   22 +
>  21 files changed, 1333 insertions(+), 65 deletions(-)
>  create mode 100644 tools/perf/tests/sdt.c
>
> --
> Masami Hiramatsu

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


#1431005

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-06-25 01:50 +0200
Message-ID<rNJ1f-6kc-3@gated-at.bofh.it>
In reply to#1430928
On Fri, 24 Jun 2016 13:25:20 -0700
Brendan Gregg <brendan.d.gregg@gmail.com> wrote:

> On Fri, Jun 24, 2016 at 2:05 AM, Masami Hiramatsu <mhiramat@kernel.org> wrote:
> > Hi,
> >
> > Here is the 12th version of the patchset for probe-cache and
> > initial SDT support.
> >
> > Here is the previous v11: https://lkml.org/lkml/2016/6/14/1041
> >
> > In this version I just rename strlist__for_each to
> > strlist__for_each_entry, and change some patch description.
> >
> 
> I tested it on Node.js (and applied to acme's perf/core), and it works. Thanks!
> 
> # perf script
>             node 36750 [006]  3080.761533:
> sdt_node:http__server__request: (da8b0c)
>             node 36750 [006]  3081.368771:
> sdt_node:http__server__request: (da8b0c)
>             node 36750 [006]  3081.592925:
> sdt_node:http__server__request: (da8b0c)
>             node 36750 [006]  3081.976802:
> sdt_node:http__server__request: (da8b0c)
>             node 36750 [006]  3082.296709:
> sdt_node:http__server__request: (da8b0c)
> 
> Since it doesn't set the is-enabled semaphore yet, I had to do that
> manually for the probes that use it. I know that will be a latter
> addition.

Yes, I'd like to support it. However, the question is who should enable it.

To enable it from perf, perf must attach the target running processes
and change the semaphore. If we run "perf record -a", it has to check
all the running process and tweak it. Moreover, it may have to hook
the execve syscall.

To enable it from kernel, hooking the target process is easier, since
we already did it in uprobes. However, it means we'll introduce a
special functionality to tweak user binary, and of course it may
need to understand SDT section to find out the semaphore.

So, one possible solution is, adding a semaphore option(like an address)
to uprobe events and enable it via ftrace. On this way, perf just
analyzes SDT and pass the semaphore address to ftrace when defining
a probe, and ftrace set 1 to the semaphre address.

> 
> # perf list | grep sdt
>   sdt_node:http__client__request                     [Tracepoint event]
>   sdt_node:http__server__request                     [Tracepoint event]
>   sdt_node:gc__done                                  [SDT event]
>   sdt_node:gc__start                                 [SDT event]
>   sdt_node:http__client__request                     [SDT event]
>   sdt_node:http__client__response                    [SDT event]
>   sdt_node:http__server__request                     [SDT event]
>   sdt_node:http__server__response                    [SDT event]
>   sdt_node:net__server__connection                   [SDT event]
>   sdt_node:net__stream__end                          [SDT event]
> 
> It's also a bit weird to see these listed twice, but I understand
> what's happening. If this continues to prove confusing, I guess later
> on we could change it to exclude listing SDT events that have been
> promoted to Tracepoint events, or not list SDT events in "perf list"
> at all, leaving them for "perf probe --cache --list".

Ah, right. Hmm, at this point, I'd like latter method, since perf
record doesn't support SDT directly yet. So we just need to drop
08/16 and 09/16. It should be implemented with perf-record support.

Thank you!

> 
> Anyway, this is great as is, and thanks again.
> 
> Brendan
> 
> 
> > Thank you,
> >
> > ---
> >
> > Hemant Kumar (1):
> >       perf/sdt: ELF support for SDT
> >
> > Masami Hiramatsu (15):
> >       perf probe: Use cache entry if possible
> >       perf probe: Show all cached probes
> >       perf probe: Remove caches when --cache is given
> >       perf probe: Add group name support
> >       perf buildid-cache: Scan and import user SDT events to probe cache
> >       perf probe: Accept %sdt and %cached event name
> >       perf-list: Show SDT and pre-cached events
> >       perf-list: Skip SDTs placed in invalid binaries
> >       perf: probe-cache: Add for_each_probe_cache_entry() wrapper
> >       perf probe: Allow wildcard for cached events
> >       perf probe: Search SDT/cached event from all probe caches
> >       perf probe: Support @BUILDID or @FILE suffix for SDT events
> >       perf probe: Support a special SDT probe format
> >       perf build: Add sdt feature detection
> >       perf-test: Add a test case for SDT event
> >
> >
> >  tools/perf/Documentation/perf-buildid-cache.txt |    3
> >  tools/perf/Documentation/perf-probe.txt         |   30 +-
> >  tools/perf/Makefile.perf                        |    3
> >  tools/perf/builtin-list.c                       |    6
> >  tools/perf/builtin-probe.c                      |   31 ++
> >  tools/perf/config/Makefile                      |   10 +
> >  tools/perf/tests/Build                          |    1
> >  tools/perf/tests/builtin-test.c                 |    4
> >  tools/perf/tests/make                           |    3
> >  tools/perf/tests/sdt.c                          |  115 +++++++
> >  tools/perf/tests/tests.h                        |    1
> >  tools/perf/util/build-id.c                      |  212 +++++++++++++
> >  tools/perf/util/build-id.h                      |    4
> >  tools/perf/util/parse-events.c                  |   82 +++++
> >  tools/perf/util/parse-events.h                  |    2
> >  tools/perf/util/probe-event.c                   |  366 +++++++++++++++++++++--
> >  tools/perf/util/probe-event.h                   |    1
> >  tools/perf/util/probe-file.c                    |  226 +++++++++++++-
> >  tools/perf/util/probe-file.h                    |   24 +-
> >  tools/perf/util/symbol-elf.c                    |  252 ++++++++++++++++
> >  tools/perf/util/symbol.h                        |   22 +
> >  21 files changed, 1333 insertions(+), 65 deletions(-)
> >  create mode 100644 tools/perf/tests/sdt.c
> >
> > --
> > Masami Hiramatsu


-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web