Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1441198 > unrolled thread
| Started by | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| First post | 2016-07-12 12:10 +0200 |
| Last post | 2016-07-14 03:40 +0200 |
| Articles | 20 on this page of 26 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH perf/core 00/10] perf-probe --cache and SDT support Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
[PATCH perf/core 03/10] perf-probe: Make --list shows only available cached events Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
Re: [PATCH perf/core 03/10] perf-probe: Make --list shows only available cached events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-13 21:30 +0200
Re: [PATCH perf/core 03/10] perf-probe: Make --list shows only available cached events Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-14 08:20 +0200
[tip:perf/core] perf probe: Make --list show only available cached events tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:10 +0200
[PATCH perf/core 10/10] perf-test: Add a test case for SDT event Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
[tip:perf/core] perf test: Add a test case for SDT event tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:20 +0200
[PATCH perf/core 09/10] perf build: Add sdt feature detection Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
[tip:perf/core] perf build: Add sdt feature detection tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:20 +0200
[PATCH perf/core 01/10] [BUGFIX] perf-probe: Fix to show correct error message for $vars and $params Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
[tip:perf/core] perf probe: Fix to show correct error message for $vars and $params tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:10 +0200
[PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-13 22:00 +0200
Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-14 02:10 +0200
Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-14 02:20 +0200
Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-14 02:30 +0200
Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-14 17:40 +0200
[tip:perf/core] perf probe: Support @BUILDID or @FILE suffix for SDT events tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:10 +0200
[PATCH perf/core 08/10] perf probe: Support a special SDT probe format Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
[tip:perf/core] perf probe: Support a special SDT probe format tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:10 +0200
[PATCH perf/core 05/10] perf probe: Allow wildcard for cached events Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
Re: [PATCH perf/core 05/10] perf probe: Allow wildcard for cached events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-13 21:40 +0200
[tip:perf/core] perf probe: Allow wildcard for cached events tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:10 +0200
[PATCH perf/core 02/10] perf probe: Accept %sdt and %cached event name Masami Hiramatsu <mhiramat@kernel.org> - 2016-07-12 12:10 +0200
[tip:perf/core] perf probe: Accept %sdt and %cached event name tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-07-14 09:10 +0200
Re: [PATCH perf/core 00/10] perf-probe --cache and SDT support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-14 03:40 +0200
Page 1 of 2 [1] 2 Next page →
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 00/10] perf-probe --cache and SDT support |
| Message-ID | <rU2NA-3tA-11@gated-at.bofh.it> |
Hi,
Here is the 14th version of the patchset for probe-cache and
initial SDT support.
Here is the previous v13: https://lkml.org/lkml/2016/7/1/133
This version includes patches which not merged yet. This also
adds a bugfix;
- [1/10] Resend the bugfix patch which was sent 4th July.
(https://lkml.org/lkml/2016/7/3/217)
Thank you,
---
Masami Hiramatsu (10):
[BUGFIX] perf-probe: Fix to show correct error message for $vars and $params
perf probe: Accept %sdt and %cached event name
perf-probe: Make --list shows only available cached events
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-probe.txt | 11 +
tools/perf/Makefile.perf | 3
tools/perf/builtin-probe.c | 2
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 | 76 ++++++++
tools/perf/util/build-id.h | 3
tools/perf/util/probe-event.c | 309 +++++++++++++++++++++++++++----
tools/perf/util/probe-event.h | 1
tools/perf/util/probe-file.c | 57 +++++-
tools/perf/util/probe-file.h | 5 +
15 files changed, 542 insertions(+), 59 deletions(-)
create mode 100644 tools/perf/tests/sdt.c
--
Masami Hiramatsu
[toc] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 03/10] perf-probe: Make --list shows only available cached events |
| Message-ID | <rU2NA-3tA-33@gated-at.bofh.it> |
| In reply to | #1441198 |
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Make "perf probe --cache --list" shows only available cached events
by checking build-id validity.
E.g. without this patch:
----
$ ./perf probe --cache --add oldevent=cmd_probe
$ make #(to update ./perf)
$ ./perf probe --cache --add newevent=cmd_probe
$ ./perf probe --cache --list
/home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
probe_perf:newevent=cmd_probe
/home/mhiramat/ksrc/linux/tools/perf/perf (c2e44d614e33e1
probe_perf:oldevent=cmd_probe
----
It shows both of old and new events but user can not use old one.
With this;
----
$ ./perf probe --cache -l
/home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
probe_perf:newevent=cmd_probe
----
This show only new event which is on the existing binary.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
Changes in v13:
- Instead of the perf-list, apply this change for perf-probe --list
because of avoiding to confuse user.
Changes in v7:
- Validate build-id via sysfs if it is for kallsyms,
Changes in v4:
- Rename a parameter 'valid' to 'validonly' :)
---
tools/perf/builtin-probe.c | 2 +-
tools/perf/util/build-id.c | 33 ++++++++++++++++++++++++++++++++-
tools/perf/util/build-id.h | 2 +-
tools/perf/util/probe-file.c | 2 +-
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index a1a5cd1..de75af5 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -370,7 +370,7 @@ static int del_perf_probe_caches(struct strfilter *filter)
struct str_node *nd;
int ret;
- bidlist = build_id_cache__list_all();
+ bidlist = build_id_cache__list_all(false);
if (!bidlist) {
ret = -errno;
pr_debug("Failed to get buildids: %d\n", ret);
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index e1a1640..8e86a83 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -206,6 +206,31 @@ out:
return ret;
}
+/* Check if the given build_id cache is valid on current running system */
+static bool build_id_cache__valid_id(char *sbuild_id)
+{
+ char real_sbuild_id[SBUILD_ID_SIZE] = "";
+ char *pathname;
+ int ret = 0;
+ bool result = false;
+
+ pathname = build_id_cache__origname(sbuild_id);
+ if (!pathname)
+ return false;
+
+ if (!strcmp(pathname, DSO__NAME_KALLSYMS))
+ ret = sysfs__sprintf_build_id("/", real_sbuild_id);
+ else if (pathname[0] == '/')
+ ret = filename__sprintf_build_id(pathname, real_sbuild_id);
+ else
+ ret = -EINVAL; /* Should we support other special DSO cache? */
+ if (ret >= 0)
+ result = (strcmp(sbuild_id, real_sbuild_id) == 0);
+ free(pathname);
+
+ return result;
+}
+
static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso)
{
return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : "elf");
@@ -433,13 +458,17 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
}
-struct strlist *build_id_cache__list_all(void)
+struct strlist *build_id_cache__list_all(bool validonly)
{
struct strlist *toplist, *linklist = NULL, *bidlist;
struct str_node *nd, *nd2;
char *topdir, *linkdir = NULL;
char sbuild_id[SBUILD_ID_SIZE];
+ /* for filename__ functions */
+ if (validonly)
+ symbol__init(NULL);
+
/* Open the top-level directory */
if (asprintf(&topdir, "%s/.build-id/", buildid_dir) < 0)
return NULL;
@@ -470,6 +499,8 @@ struct strlist *build_id_cache__list_all(void)
if (snprintf(sbuild_id, SBUILD_ID_SIZE, "%s%s",
nd->s, nd2->s) != SBUILD_ID_SIZE - 1)
goto err_out;
+ if (validonly && !build_id_cache__valid_id(sbuild_id))
+ continue;
if (strlist__add(bidlist, sbuild_id) < 0)
goto err_out;
}
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index b742e27..64e740f 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -34,7 +34,7 @@ char *build_id_cache__origname(const char *sbuild_id);
char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso);
-struct strlist *build_id_cache__list_all(void);
+struct strlist *build_id_cache__list_all(bool validonly);
int build_id_cache__list_build_ids(const char *pathname,
struct strlist **result);
bool build_id_cache__cached(const char *sbuild_id);
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index b642d06..b062545 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -806,7 +806,7 @@ int probe_cache__show_all_caches(struct strfilter *filter)
pr_debug("list cache with filter: %s\n", buf);
free(buf);
- bidlist = build_id_cache__list_all();
+ bidlist = build_id_cache__list_all(true);
if (!bidlist) {
pr_debug("Failed to get buildids: %d\n", errno);
return -EINVAL;
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-07-13 21:30 +0200 |
| Subject | Re: [PATCH perf/core 03/10] perf-probe: Make --list shows only available cached events |
| Message-ID | <rUy13-7mK-15@gated-at.bofh.it> |
| In reply to | #1441201 |
Em Tue, Jul 12, 2016 at 07:04:54PM +0900, Masami Hiramatsu escreveu:
> From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>
> Make "perf probe --cache --list" shows only available cached events
> by checking build-id validity.
Something is missing here, I tried following these steps and couldn't
get to the same results, can you retry them at this point in time, i.e.
after applying just the three first patches in this series?
I'm continuing anyway, as I want to check the rest...
- Arnaldo
> E.g. without this patch:
> ----
> $ ./perf probe --cache --add oldevent=cmd_probe
> $ make #(to update ./perf)
> $ ./perf probe --cache --add newevent=cmd_probe
> $ ./perf probe --cache --list
> /home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
> probe_perf:newevent=cmd_probe
> /home/mhiramat/ksrc/linux/tools/perf/perf (c2e44d614e33e1
> probe_perf:oldevent=cmd_probe
> ----
> It shows both of old and new events but user can not use old one.
> With this;
> ----
> $ ./perf probe --cache -l
> /home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
> probe_perf:newevent=cmd_probe
> ----
> This show only new event which is on the existing binary.
>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
> Changes in v13:
> - Instead of the perf-list, apply this change for perf-probe --list
> because of avoiding to confuse user.
> Changes in v7:
> - Validate build-id via sysfs if it is for kallsyms,
> Changes in v4:
> - Rename a parameter 'valid' to 'validonly' :)
> ---
> tools/perf/builtin-probe.c | 2 +-
> tools/perf/util/build-id.c | 33 ++++++++++++++++++++++++++++++++-
> tools/perf/util/build-id.h | 2 +-
> tools/perf/util/probe-file.c | 2 +-
> 4 files changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index a1a5cd1..de75af5 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -370,7 +370,7 @@ static int del_perf_probe_caches(struct strfilter *filter)
> struct str_node *nd;
> int ret;
>
> - bidlist = build_id_cache__list_all();
> + bidlist = build_id_cache__list_all(false);
> if (!bidlist) {
> ret = -errno;
> pr_debug("Failed to get buildids: %d\n", ret);
> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index e1a1640..8e86a83 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -206,6 +206,31 @@ out:
> return ret;
> }
>
> +/* Check if the given build_id cache is valid on current running system */
> +static bool build_id_cache__valid_id(char *sbuild_id)
> +{
> + char real_sbuild_id[SBUILD_ID_SIZE] = "";
> + char *pathname;
> + int ret = 0;
> + bool result = false;
> +
> + pathname = build_id_cache__origname(sbuild_id);
> + if (!pathname)
> + return false;
> +
> + if (!strcmp(pathname, DSO__NAME_KALLSYMS))
> + ret = sysfs__sprintf_build_id("/", real_sbuild_id);
> + else if (pathname[0] == '/')
> + ret = filename__sprintf_build_id(pathname, real_sbuild_id);
> + else
> + ret = -EINVAL; /* Should we support other special DSO cache? */
> + if (ret >= 0)
> + result = (strcmp(sbuild_id, real_sbuild_id) == 0);
> + free(pathname);
> +
> + return result;
> +}
> +
> static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso)
> {
> return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : "elf");
> @@ -433,13 +458,17 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
> return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
> }
>
> -struct strlist *build_id_cache__list_all(void)
> +struct strlist *build_id_cache__list_all(bool validonly)
> {
> struct strlist *toplist, *linklist = NULL, *bidlist;
> struct str_node *nd, *nd2;
> char *topdir, *linkdir = NULL;
> char sbuild_id[SBUILD_ID_SIZE];
>
> + /* for filename__ functions */
> + if (validonly)
> + symbol__init(NULL);
> +
> /* Open the top-level directory */
> if (asprintf(&topdir, "%s/.build-id/", buildid_dir) < 0)
> return NULL;
> @@ -470,6 +499,8 @@ struct strlist *build_id_cache__list_all(void)
> if (snprintf(sbuild_id, SBUILD_ID_SIZE, "%s%s",
> nd->s, nd2->s) != SBUILD_ID_SIZE - 1)
> goto err_out;
> + if (validonly && !build_id_cache__valid_id(sbuild_id))
> + continue;
> if (strlist__add(bidlist, sbuild_id) < 0)
> goto err_out;
> }
> diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
> index b742e27..64e740f 100644
> --- a/tools/perf/util/build-id.h
> +++ b/tools/perf/util/build-id.h
> @@ -34,7 +34,7 @@ char *build_id_cache__origname(const char *sbuild_id);
> char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
> char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
> bool is_kallsyms, bool is_vdso);
> -struct strlist *build_id_cache__list_all(void);
> +struct strlist *build_id_cache__list_all(bool validonly);
> int build_id_cache__list_build_ids(const char *pathname,
> struct strlist **result);
> bool build_id_cache__cached(const char *sbuild_id);
> diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> index b642d06..b062545 100644
> --- a/tools/perf/util/probe-file.c
> +++ b/tools/perf/util/probe-file.c
> @@ -806,7 +806,7 @@ int probe_cache__show_all_caches(struct strfilter *filter)
> pr_debug("list cache with filter: %s\n", buf);
> free(buf);
>
> - bidlist = build_id_cache__list_all();
> + bidlist = build_id_cache__list_all(true);
> if (!bidlist) {
> pr_debug("Failed to get buildids: %d\n", errno);
> return -EINVAL;
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-14 08:20 +0200 |
| Subject | Re: [PATCH perf/core 03/10] perf-probe: Make --list shows only available cached events |
| Message-ID | <rUIa6-5Pz-9@gated-at.bofh.it> |
| In reply to | #1442784 |
On Wed, 13 Jul 2016 16:28:37 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Tue, Jul 12, 2016 at 07:04:54PM +0900, Masami Hiramatsu escreveu:
> > From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> >
> > Make "perf probe --cache --list" shows only available cached events
> > by checking build-id validity.
>
> Something is missing here, I tried following these steps and couldn't
> get to the same results, can you retry them at this point in time, i.e.
> after applying just the three first patches in this series?
Sorry, I missed some steps, see below;
>
> I'm continuing anyway, as I want to check the rest...
>
> - Arnaldo
>
> > E.g. without this patch:
> > ----
> > $ ./perf probe --cache --add oldevent=cmd_probe
Here, you have to change perf source code so that perf binary
build-id is changed.
And make a copy of perf (as perf.old) so that you can get build-id
of both binary.
> > $ make #(to update ./perf)
So, prese ensure that the new perf binary has different build-id.
If both binary has same build-id, you'll see just one cache.
Thank you,
> > $ ./perf probe --cache --add newevent=cmd_probe
> > $ ./perf probe --cache --list
> > /home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
> > probe_perf:newevent=cmd_probe
> > /home/mhiramat/ksrc/linux/tools/perf/perf (c2e44d614e33e1
> > probe_perf:oldevent=cmd_probe
> > ----
> > It shows both of old and new events but user can not use old one.
> > With this;
> > ----
> > $ ./perf probe --cache -l
> > /home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
> > probe_perf:newevent=cmd_probe
> > ----
> > This show only new event which is on the existing binary.
> >
> > Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> > ---
> > Changes in v13:
> > - Instead of the perf-list, apply this change for perf-probe --list
> > because of avoiding to confuse user.
> > Changes in v7:
> > - Validate build-id via sysfs if it is for kallsyms,
> > Changes in v4:
> > - Rename a parameter 'valid' to 'validonly' :)
> > ---
> > tools/perf/builtin-probe.c | 2 +-
> > tools/perf/util/build-id.c | 33 ++++++++++++++++++++++++++++++++-
> > tools/perf/util/build-id.h | 2 +-
> > tools/perf/util/probe-file.c | 2 +-
> > 4 files changed, 35 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> > index a1a5cd1..de75af5 100644
> > --- a/tools/perf/builtin-probe.c
> > +++ b/tools/perf/builtin-probe.c
> > @@ -370,7 +370,7 @@ static int del_perf_probe_caches(struct strfilter *filter)
> > struct str_node *nd;
> > int ret;
> >
> > - bidlist = build_id_cache__list_all();
> > + bidlist = build_id_cache__list_all(false);
> > if (!bidlist) {
> > ret = -errno;
> > pr_debug("Failed to get buildids: %d\n", ret);
> > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> > index e1a1640..8e86a83 100644
> > --- a/tools/perf/util/build-id.c
> > +++ b/tools/perf/util/build-id.c
> > @@ -206,6 +206,31 @@ out:
> > return ret;
> > }
> >
> > +/* Check if the given build_id cache is valid on current running system */
> > +static bool build_id_cache__valid_id(char *sbuild_id)
> > +{
> > + char real_sbuild_id[SBUILD_ID_SIZE] = "";
> > + char *pathname;
> > + int ret = 0;
> > + bool result = false;
> > +
> > + pathname = build_id_cache__origname(sbuild_id);
> > + if (!pathname)
> > + return false;
> > +
> > + if (!strcmp(pathname, DSO__NAME_KALLSYMS))
> > + ret = sysfs__sprintf_build_id("/", real_sbuild_id);
> > + else if (pathname[0] == '/')
> > + ret = filename__sprintf_build_id(pathname, real_sbuild_id);
> > + else
> > + ret = -EINVAL; /* Should we support other special DSO cache? */
> > + if (ret >= 0)
> > + result = (strcmp(sbuild_id, real_sbuild_id) == 0);
> > + free(pathname);
> > +
> > + return result;
> > +}
> > +
> > static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso)
> > {
> > return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : "elf");
> > @@ -433,13 +458,17 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
> > return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
> > }
> >
> > -struct strlist *build_id_cache__list_all(void)
> > +struct strlist *build_id_cache__list_all(bool validonly)
> > {
> > struct strlist *toplist, *linklist = NULL, *bidlist;
> > struct str_node *nd, *nd2;
> > char *topdir, *linkdir = NULL;
> > char sbuild_id[SBUILD_ID_SIZE];
> >
> > + /* for filename__ functions */
> > + if (validonly)
> > + symbol__init(NULL);
> > +
> > /* Open the top-level directory */
> > if (asprintf(&topdir, "%s/.build-id/", buildid_dir) < 0)
> > return NULL;
> > @@ -470,6 +499,8 @@ struct strlist *build_id_cache__list_all(void)
> > if (snprintf(sbuild_id, SBUILD_ID_SIZE, "%s%s",
> > nd->s, nd2->s) != SBUILD_ID_SIZE - 1)
> > goto err_out;
> > + if (validonly && !build_id_cache__valid_id(sbuild_id))
> > + continue;
> > if (strlist__add(bidlist, sbuild_id) < 0)
> > goto err_out;
> > }
> > diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
> > index b742e27..64e740f 100644
> > --- a/tools/perf/util/build-id.h
> > +++ b/tools/perf/util/build-id.h
> > @@ -34,7 +34,7 @@ char *build_id_cache__origname(const char *sbuild_id);
> > char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
> > char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
> > bool is_kallsyms, bool is_vdso);
> > -struct strlist *build_id_cache__list_all(void);
> > +struct strlist *build_id_cache__list_all(bool validonly);
> > int build_id_cache__list_build_ids(const char *pathname,
> > struct strlist **result);
> > bool build_id_cache__cached(const char *sbuild_id);
> > diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> > index b642d06..b062545 100644
> > --- a/tools/perf/util/probe-file.c
> > +++ b/tools/perf/util/probe-file.c
> > @@ -806,7 +806,7 @@ int probe_cache__show_all_caches(struct strfilter *filter)
> > pr_debug("list cache with filter: %s\n", buf);
> > free(buf);
> >
> > - bidlist = build_id_cache__list_all();
> > + bidlist = build_id_cache__list_all(true);
> > if (!bidlist) {
> > pr_debug("Failed to get buildids: %d\n", errno);
> > return -EINVAL;
--
Masami Hiramatsu <mhiramat@kernel.org>
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-07-14 09:10 +0200 |
| Subject | [tip:perf/core] perf probe: Make --list show only available cached events |
| Message-ID | <rUIWv-6o9-51@gated-at.bofh.it> |
| In reply to | #1441201 |
Commit-ID: c3492a3a4e58117f18d96125e67b0bed7c4231e1
Gitweb: http://git.kernel.org/tip/c3492a3a4e58117f18d96125e67b0bed7c4231e1
Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Tue, 12 Jul 2016 19:04:54 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Jul 2016 23:09:05 -0300
perf probe: Make --list show only available cached events
Make "perf probe --cache --list" show only available cached events by
checking build-id validity.
E.g. without this patch:
----
$ ./perf probe --cache --add oldevent=cmd_probe
$ make #(to update ./perf)
$ ./perf probe --cache --add newevent=cmd_probe
$ ./perf probe --cache --list
/home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
probe_perf:newevent=cmd_probe
/home/mhiramat/ksrc/linux/tools/perf/perf (c2e44d614e33e1
probe_perf:oldevent=cmd_probe
----
It shows both of old and new events but user can not use old one.
With this;
----
$ ./perf probe --cache -l
/home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
probe_perf:newevent=cmd_probe
----
This shows only new events which are on the existing binary.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146831789417.17065.17896487479879669610.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-probe.c | 2 +-
tools/perf/util/build-id.c | 33 ++++++++++++++++++++++++++++++++-
tools/perf/util/build-id.h | 2 +-
tools/perf/util/probe-file.c | 2 +-
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c6d890a..ee5b421 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -370,7 +370,7 @@ static int del_perf_probe_caches(struct strfilter *filter)
struct str_node *nd;
int ret;
- bidlist = build_id_cache__list_all();
+ bidlist = build_id_cache__list_all(false);
if (!bidlist) {
ret = -errno;
pr_debug("Failed to get buildids: %d\n", ret);
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 1e504e4..36b4279 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -206,6 +206,31 @@ out:
return ret;
}
+/* Check if the given build_id cache is valid on current running system */
+static bool build_id_cache__valid_id(char *sbuild_id)
+{
+ char real_sbuild_id[SBUILD_ID_SIZE] = "";
+ char *pathname;
+ int ret = 0;
+ bool result = false;
+
+ pathname = build_id_cache__origname(sbuild_id);
+ if (!pathname)
+ return false;
+
+ if (!strcmp(pathname, DSO__NAME_KALLSYMS))
+ ret = sysfs__sprintf_build_id("/", real_sbuild_id);
+ else if (pathname[0] == '/')
+ ret = filename__sprintf_build_id(pathname, real_sbuild_id);
+ else
+ ret = -EINVAL; /* Should we support other special DSO cache? */
+ if (ret >= 0)
+ result = (strcmp(sbuild_id, real_sbuild_id) == 0);
+ free(pathname);
+
+ return result;
+}
+
static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso)
{
return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : "elf");
@@ -433,13 +458,17 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
}
-struct strlist *build_id_cache__list_all(void)
+struct strlist *build_id_cache__list_all(bool validonly)
{
struct strlist *toplist, *linklist = NULL, *bidlist;
struct str_node *nd, *nd2;
char *topdir, *linkdir = NULL;
char sbuild_id[SBUILD_ID_SIZE];
+ /* for filename__ functions */
+ if (validonly)
+ symbol__init(NULL);
+
/* Open the top-level directory */
if (asprintf(&topdir, "%s/.build-id/", buildid_dir) < 0)
return NULL;
@@ -470,6 +499,8 @@ struct strlist *build_id_cache__list_all(void)
if (snprintf(sbuild_id, SBUILD_ID_SIZE, "%s%s",
nd->s, nd2->s) != SBUILD_ID_SIZE - 1)
goto err_out;
+ if (validonly && !build_id_cache__valid_id(sbuild_id))
+ continue;
if (strlist__add(bidlist, sbuild_id) < 0)
goto err_out;
}
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index b742e27..64e740f 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -34,7 +34,7 @@ char *build_id_cache__origname(const char *sbuild_id);
char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso);
-struct strlist *build_id_cache__list_all(void);
+struct strlist *build_id_cache__list_all(bool validonly);
int build_id_cache__list_build_ids(const char *pathname,
struct strlist **result);
bool build_id_cache__cached(const char *sbuild_id);
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index fc16b17..a5059dc 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -808,7 +808,7 @@ int probe_cache__show_all_caches(struct strfilter *filter)
pr_debug("list cache with filter: %s\n", buf);
free(buf);
- bidlist = build_id_cache__list_all();
+ bidlist = build_id_cache__list_all(true);
if (!bidlist) {
pr_debug("Failed to get buildids: %d\n", errno);
return -EINVAL;
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 10/10] perf-test: Add a test case for SDT event |
| Message-ID | <rU2NB-3tA-35@gated-at.bofh.it> |
| In reply to | #1441198 |
Add a basic test case for SDT event support.
This test scans an SDT event in perftools and
check whether the SDT event is correctly stored
into the buildid cache.
Here is an example:
----
$ perf test sdt -v
47: Test SDT event probing :
--- start ---
test child forked, pid 20732
Found 72 SDTs in /home/mhiramat/ksrc/linux/tools/perf/perf
Writing cache: %sdt_perf:test_target=test_target
Cache committed: 0
symbol:test_target file:(null) line:0 offset:0 return:0 lazy:(null)
test child finished with 0
---- end ----
Test SDT event probing: Ok
----
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/perf/tests/Build | 1
tools/perf/tests/builtin-test.c | 4 +
tools/perf/tests/sdt.c | 115 +++++++++++++++++++++++++++++++++++++++
tools/perf/tests/tests.h | 1
4 files changed, 121 insertions(+)
create mode 100644 tools/perf/tests/sdt.c
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 66a2898..4158422 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -39,6 +39,7 @@ perf-y += stat.o
perf-y += event_update.o
perf-y += event-times.o
perf-y += backward-ring-buffer.o
+perf-y += sdt.o
$(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
$(call rule_mkdir)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 07c14e9..74ed9f5 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -218,6 +218,10 @@ static struct test generic_tests[] = {
.func = test__cpu_map_print,
},
{
+ .desc = "Test SDT event probing",
+ .func = test__sdt_event,
+ },
+ {
.func = NULL,
},
};
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
new file mode 100644
index 0000000..f59d210
--- /dev/null
+++ b/tools/perf/tests/sdt.c
@@ -0,0 +1,115 @@
+#include <stdio.h>
+#include <sys/epoll.h>
+#include <util/util.h>
+#include <util/evlist.h>
+#include <linux/filter.h>
+#include "tests.h"
+#include "debug.h"
+#include "probe-file.h"
+#include "build-id.h"
+
+/* To test SDT event, we need libelf support to scan elf binary */
+#if defined(HAVE_SDT_EVENT) && defined(HAVE_LIBELF_SUPPORT)
+
+#include <sys/sdt.h>
+
+static int target_function(void)
+{
+ DTRACE_PROBE(perf, test_target);
+ return TEST_OK;
+}
+
+/* Copied from builtin-buildid-cache.c */
+static int build_id_cache__add_file(const char *filename)
+{
+ char sbuild_id[SBUILD_ID_SIZE];
+ u8 build_id[BUILD_ID_SIZE];
+ int err;
+
+ err = filename__read_build_id(filename, &build_id, sizeof(build_id));
+ if (err < 0) {
+ pr_debug("Failed to read build id of %s\n", filename);
+ return err;
+ }
+
+ build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
+ err = build_id_cache__add_s(sbuild_id, filename, false, false);
+ if (err < 0)
+ pr_debug("Failed to add build id cache of %s\n", filename);
+ return err;
+}
+
+static char *get_self_path(void)
+{
+ char *buf = calloc(PATH_MAX, sizeof(char));
+
+ if (buf && readlink("/proc/self/exe", buf, PATH_MAX) < 0) {
+ pr_debug("Failed to get correct path of perf\n");
+ free(buf);
+ return NULL;
+ }
+ return buf;
+}
+
+static int search_cached_probe(const char *target,
+ const char *group, const char *event)
+{
+ struct probe_cache *cache = probe_cache__new(target);
+ int ret = 0;
+
+ if (!cache) {
+ pr_debug("Failed to open probe cache of %s\n", target);
+ return -EINVAL;
+ }
+
+ if (!probe_cache__find_by_name(cache, group, event)) {
+ pr_debug("Failed to find %s:%s in the cache\n", group, event);
+ ret = -ENOENT;
+ }
+ probe_cache__delete(cache);
+
+ return ret;
+}
+
+int test__sdt_event(int subtests __maybe_unused)
+{
+ int ret = TEST_FAIL;
+ char __tempdir[] = "./test-buildid-XXXXXX";
+ char *tempdir = NULL, *myself = get_self_path();
+
+ if (myself == NULL || mkdtemp(__tempdir) == NULL) {
+ pr_debug("Failed to make a tempdir for build-id cache\n");
+ goto error;
+ }
+ /* Note that buildid_dir must be an absolute path */
+ tempdir = realpath(__tempdir, NULL);
+
+ /* At first, scan itself */
+ set_buildid_dir(tempdir);
+ if (build_id_cache__add_file(myself) < 0)
+ goto error_rmdir;
+
+ /* Open a cache and make sure the SDT is stored */
+ if (search_cached_probe(myself, "sdt_perf", "test_target") < 0)
+ goto error_rmdir;
+
+ /* TBD: probing on the SDT event and collect logs */
+
+ /* Call the target and get an event */
+ ret = target_function();
+
+error_rmdir:
+ /* Cleanup temporary buildid dir */
+ rm_rf(tempdir);
+error:
+ free(tempdir);
+ free(myself);
+ return ret;
+}
+#else
+int test__sdt_event(int subtests __maybe_unused)
+{
+ pr_debug("Skip SDT event test because SDT support is not compiled\n");
+ return TEST_SKIP;
+}
+#endif
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 52f9695..a0288f8 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -88,6 +88,7 @@ int test__event_update(int subtest);
int test__event_times(int subtest);
int test__backward_ring_buffer(int subtest);
int test__cpu_map_print(int subtest);
+int test__sdt_event(int subtest);
#if defined(__arm__) || defined(__aarch64__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-07-14 09:20 +0200 |
| Subject | [tip:perf/core] perf test: Add a test case for SDT event |
| Message-ID | <rUJ69-6rX-1@gated-at.bofh.it> |
| In reply to | #1441204 |
Commit-ID: 8e5dc848356ecf6ea8d27d641c4d7ad8d42fe92b
Gitweb: http://git.kernel.org/tip/8e5dc848356ecf6ea8d27d641c4d7ad8d42fe92b
Author: Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Tue, 12 Jul 2016 19:06:05 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Jul 2016 23:09:10 -0300
perf test: Add a test case for SDT event
Add a basic test case for SDT event support. This test scans an SDT
event in perftools and check whether the SDT event is correctly stored
into the buildid cache.
Here is an example:
----
$ perf test sdt -v
47: Test SDT event probing :
--- start ---
test child forked, pid 20732
Found 72 SDTs in /home/mhiramat/ksrc/linux/tools/perf/perf
Writing cache: %sdt_perf:test_target=test_target
Cache committed: 0
symbol:test_target file:(null) line:0 offset:0 return:0 lazy:(null)
test child finished with 0
---- end ----
Test SDT event probing: Ok
----
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146831796546.17065.1502584370844087537.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/Build | 1 +
tools/perf/tests/builtin-test.c | 4 ++
tools/perf/tests/sdt.c | 115 ++++++++++++++++++++++++++++++++++++++++
tools/perf/tests/tests.h | 1 +
4 files changed, 121 insertions(+)
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 66a2898..4158422 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -39,6 +39,7 @@ perf-y += stat.o
perf-y += event_update.o
perf-y += event-times.o
perf-y += backward-ring-buffer.o
+perf-y += sdt.o
$(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
$(call rule_mkdir)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index c23cbf7..4dd2d05 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -218,6 +218,10 @@ static struct test generic_tests[] = {
.func = test__cpu_map_print,
},
{
+ .desc = "Test SDT event probing",
+ .func = test__sdt_event,
+ },
+ {
.func = NULL,
},
};
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
new file mode 100644
index 0000000..f59d210
--- /dev/null
+++ b/tools/perf/tests/sdt.c
@@ -0,0 +1,115 @@
+#include <stdio.h>
+#include <sys/epoll.h>
+#include <util/util.h>
+#include <util/evlist.h>
+#include <linux/filter.h>
+#include "tests.h"
+#include "debug.h"
+#include "probe-file.h"
+#include "build-id.h"
+
+/* To test SDT event, we need libelf support to scan elf binary */
+#if defined(HAVE_SDT_EVENT) && defined(HAVE_LIBELF_SUPPORT)
+
+#include <sys/sdt.h>
+
+static int target_function(void)
+{
+ DTRACE_PROBE(perf, test_target);
+ return TEST_OK;
+}
+
+/* Copied from builtin-buildid-cache.c */
+static int build_id_cache__add_file(const char *filename)
+{
+ char sbuild_id[SBUILD_ID_SIZE];
+ u8 build_id[BUILD_ID_SIZE];
+ int err;
+
+ err = filename__read_build_id(filename, &build_id, sizeof(build_id));
+ if (err < 0) {
+ pr_debug("Failed to read build id of %s\n", filename);
+ return err;
+ }
+
+ build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
+ err = build_id_cache__add_s(sbuild_id, filename, false, false);
+ if (err < 0)
+ pr_debug("Failed to add build id cache of %s\n", filename);
+ return err;
+}
+
+static char *get_self_path(void)
+{
+ char *buf = calloc(PATH_MAX, sizeof(char));
+
+ if (buf && readlink("/proc/self/exe", buf, PATH_MAX) < 0) {
+ pr_debug("Failed to get correct path of perf\n");
+ free(buf);
+ return NULL;
+ }
+ return buf;
+}
+
+static int search_cached_probe(const char *target,
+ const char *group, const char *event)
+{
+ struct probe_cache *cache = probe_cache__new(target);
+ int ret = 0;
+
+ if (!cache) {
+ pr_debug("Failed to open probe cache of %s\n", target);
+ return -EINVAL;
+ }
+
+ if (!probe_cache__find_by_name(cache, group, event)) {
+ pr_debug("Failed to find %s:%s in the cache\n", group, event);
+ ret = -ENOENT;
+ }
+ probe_cache__delete(cache);
+
+ return ret;
+}
+
+int test__sdt_event(int subtests __maybe_unused)
+{
+ int ret = TEST_FAIL;
+ char __tempdir[] = "./test-buildid-XXXXXX";
+ char *tempdir = NULL, *myself = get_self_path();
+
+ if (myself == NULL || mkdtemp(__tempdir) == NULL) {
+ pr_debug("Failed to make a tempdir for build-id cache\n");
+ goto error;
+ }
+ /* Note that buildid_dir must be an absolute path */
+ tempdir = realpath(__tempdir, NULL);
+
+ /* At first, scan itself */
+ set_buildid_dir(tempdir);
+ if (build_id_cache__add_file(myself) < 0)
+ goto error_rmdir;
+
+ /* Open a cache and make sure the SDT is stored */
+ if (search_cached_probe(myself, "sdt_perf", "test_target") < 0)
+ goto error_rmdir;
+
+ /* TBD: probing on the SDT event and collect logs */
+
+ /* Call the target and get an event */
+ ret = target_function();
+
+error_rmdir:
+ /* Cleanup temporary buildid dir */
+ rm_rf(tempdir);
+error:
+ free(tempdir);
+ free(myself);
+ return ret;
+}
+#else
+int test__sdt_event(int subtests __maybe_unused)
+{
+ pr_debug("Skip SDT event test because SDT support is not compiled\n");
+ return TEST_SKIP;
+}
+#endif
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 52f9695..a0288f8 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -88,6 +88,7 @@ int test__event_update(int subtest);
int test__event_times(int subtest);
int test__backward_ring_buffer(int subtest);
int test__cpu_map_print(int subtest);
+int test__sdt_event(int subtest);
#if defined(__arm__) || defined(__aarch64__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 09/10] perf build: Add sdt feature detection |
| Message-ID | <rU2NB-3tA-39@gated-at.bofh.it> |
| In reply to | #1441198 |
This checks whether sys/sdt.h is available or not,
which is required for DTRACE_PROBE().
We can disable this feature by passing NO_SDT=1 when
building.
This flag will be used for SDT test case and further
SDT events in perftools.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/perf/Makefile.perf | 3 +++
tools/perf/config/Makefile | 10 ++++++++++
tools/perf/tests/make | 3 ++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 3dd529b..a1ec630 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -61,7 +61,8 @@ FEATURE_TESTS_BASIC := \
zlib \
lzma \
get_cpuid \
- bpf
+ bpf \
+ sdt
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
# of all feature tests
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 6747116..8716ab2 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -44,7 +44,8 @@ FILES= \
test-zlib.bin \
test-lzma.bin \
test-bpf.bin \
- test-get_cpuid.bin
+ test-get_cpuid.bin \
+ test-sdt.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
@@ -209,6 +210,9 @@ $(OUTPUT)test-get_cpuid.bin:
$(OUTPUT)test-bpf.bin:
$(BUILD)
+$(OUTPUT)test-sdt.bin:
+ $(BUILD)
+
-include $(OUTPUT)*.d
###############################
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 7433cca..bab33d8 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -141,6 +141,10 @@
# include "test-libcrypto.c"
#undef main
+#define main main_test_sdt
+# include "test-sdt.c"
+#undef main
+
int main(int argc, char *argv[])
{
main_test_libpython();
@@ -173,6 +177,7 @@ int main(int argc, char *argv[])
main_test_get_cpuid();
main_test_bpf();
main_test_libcrypto();
+ main_test_sdt();
return 0;
}
diff --git a/tools/build/feature/test-sdt.c b/tools/build/feature/test-sdt.c
new file mode 100644
index 0000000..e4531a6
--- /dev/null
+++ b/tools/build/feature/test-sdt.c
@@ -0,0 +1,7 @@
+#include <sys/sdt.h>
+
+int main(void)
+{
+ DTRACE_PROBE(provider, name);
+ return 0;
+}
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d0a2cb1..458eaf5 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -81,6 +81,9 @@ include ../scripts/utilities.mak
#
# Define NO_LIBBPF if you do not want BPF support
#
+# Define NO_SDT if you do not want to define SDT event in perf tools,
+# note that it doesn't disable SDT scanning support.
+#
# Define FEATURES_DUMP to provide features detection dump file
# and bypass the feature detection
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c7e269a..b55f9ec 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -349,6 +349,16 @@ ifndef NO_LIBELF
endif # NO_LIBBPF
endif # NO_LIBELF
+ifndef NO_SDT
+ ifneq ($(feature-sdt), 1)
+ msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
+ NO_SDT := 1;
+ else
+ CFLAGS += -DHAVE_SDT_EVENT
+ $(call detected,CONFIG_SDT_EVENT)
+ endif
+endif
+
ifdef PERF_HAVE_JITDUMP
ifndef NO_DWARF
$(call detected,CONFIG_JITDUMP)
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 51966d9..143f4d5 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -82,6 +82,7 @@ make_no_auxtrace := NO_AUXTRACE=1
make_no_libbpf := NO_LIBBPF=1
make_no_libcrypto := NO_LIBCRYPTO=1
make_with_babeltrace:= LIBBABELTRACE=1
+make_no_sdt := NO_SDT=1
make_tags := tags
make_cscope := cscope
make_help := help
@@ -105,7 +106,7 @@ make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
-make_minimal += NO_LIBCRYPTO=1
+make_minimal += NO_LIBCRYPTO=1 NO_SDT=1
# $(run) contains all available tests
run := make_pure
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-07-14 09:20 +0200 |
| Subject | [tip:perf/core] perf build: Add sdt feature detection |
| Message-ID | <rUJ69-6rX-9@gated-at.bofh.it> |
| In reply to | #1441206 |
Commit-ID: e26e63be64a108c1fd12020b93b5b447ffe0532b
Gitweb: http://git.kernel.org/tip/e26e63be64a108c1fd12020b93b5b447ffe0532b
Author: Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Tue, 12 Jul 2016 19:05:56 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Jul 2016 23:09:09 -0300
perf build: Add sdt feature detection
This checks whether sys/sdt.h is available or not, which is required for
DTRACE_PROBE().
We can disable this feature by passing NO_SDT=1 when building.
This flag will be used for SDT test case and further SDT events in
perftools.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146831795615.17065.17513820540591053933.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/build/Makefile.feature | 3 ++-
tools/build/feature/Makefile | 6 +++++-
tools/build/feature/test-all.c | 5 +++++
tools/build/feature/test-sdt.c | 7 +++++++
tools/perf/Makefile.perf | 3 +++
tools/perf/config/Makefile | 10 ++++++++++
tools/perf/tests/make | 3 ++-
7 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index fe12bee..a120c6b 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -62,7 +62,8 @@ FEATURE_TESTS_BASIC := \
zlib \
lzma \
get_cpuid \
- bpf
+ bpf \
+ sdt
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
# of all feature tests
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index d6017c1..a0b29a3 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -45,7 +45,8 @@ FILES= \
test-zlib.bin \
test-lzma.bin \
test-bpf.bin \
- test-get_cpuid.bin
+ test-get_cpuid.bin \
+ test-sdt.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
@@ -213,6 +214,9 @@ $(OUTPUT)test-get_cpuid.bin:
$(OUTPUT)test-bpf.bin:
$(BUILD)
+$(OUTPUT)test-sdt.bin:
+ $(BUILD)
+
-include $(OUTPUT)*.d
###############################
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 843aed0..699e436 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -145,6 +145,10 @@
# include "test-libcrypto.c"
#undef main
+#define main main_test_sdt
+# include "test-sdt.c"
+#undef main
+
int main(int argc, char *argv[])
{
main_test_libpython();
@@ -178,6 +182,7 @@ int main(int argc, char *argv[])
main_test_get_cpuid();
main_test_bpf();
main_test_libcrypto();
+ main_test_sdt();
return 0;
}
diff --git a/tools/build/feature/test-sdt.c b/tools/build/feature/test-sdt.c
new file mode 100644
index 0000000..e4531a6
--- /dev/null
+++ b/tools/build/feature/test-sdt.c
@@ -0,0 +1,7 @@
+#include <sys/sdt.h>
+
+int main(void)
+{
+ DTRACE_PROBE(provider, name);
+ return 0;
+}
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index feb2c66..a129fbc 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -81,6 +81,9 @@ include ../scripts/utilities.mak
#
# Define NO_LIBBPF if you do not want BPF support
#
+# Define NO_SDT if you do not want to define SDT event in perf tools,
+# note that it doesn't disable SDT scanning support.
+#
# Define FEATURES_DUMP to provide features detection dump file
# and bypass the feature detection
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5ac4280..24803c5 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -355,6 +355,16 @@ ifndef NO_LIBELF
endif # NO_LIBBPF
endif # NO_LIBELF
+ifndef NO_SDT
+ ifneq ($(feature-sdt), 1)
+ msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
+ NO_SDT := 1;
+ else
+ CFLAGS += -DHAVE_SDT_EVENT
+ $(call detected,CONFIG_SDT_EVENT)
+ endif
+endif
+
ifdef PERF_HAVE_JITDUMP
ifndef NO_DWARF
$(call detected,CONFIG_JITDUMP)
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 51966d9..143f4d5 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -82,6 +82,7 @@ make_no_auxtrace := NO_AUXTRACE=1
make_no_libbpf := NO_LIBBPF=1
make_no_libcrypto := NO_LIBCRYPTO=1
make_with_babeltrace:= LIBBABELTRACE=1
+make_no_sdt := NO_SDT=1
make_tags := tags
make_cscope := cscope
make_help := help
@@ -105,7 +106,7 @@ make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
-make_minimal += NO_LIBCRYPTO=1
+make_minimal += NO_LIBCRYPTO=1 NO_SDT=1
# $(run) contains all available tests
run := make_pure
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 01/10] [BUGFIX] perf-probe: Fix to show correct error message for $vars and $params |
| Message-ID | <rU2NB-3tA-41@gated-at.bofh.it> |
| In reply to | #1441198 |
Fix to show correct error messages for $vars and $params because
those special variables requires debug information to find the
real variables or function parameters.
E.g. without this fix;
----
# perf probe -x /lib64/libc-2.23.so getaddrinfo \$params
Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature $params
Error: Failed to add events.
----
Perf ends up with an error, but the message is not correct.
With this fix, perf shows correct error message as below.
----
# perf probe -x /lib64/libc-2.23.so getaddrinfo \$params
The /usr/lib64/libc-2.23.so file has no debug information.
Rebuild with -g, or install an appropriate debuginfo package.
Error: Failed to add events.
----
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/perf/util/probe-event.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 0201f66..dff9a54 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1547,7 +1547,9 @@ bool perf_probe_event_need_dwarf(struct perf_probe_event *pev)
return true;
for (i = 0; i < pev->nargs; i++)
- if (is_c_varname(pev->args[i].var))
+ if (is_c_varname(pev->args[i].var) ||
+ !strcmp(pev->args[i].var, "$params") ||
+ !strcmp(pev->args[i].var, "$vars"))
return true;
return false;
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-07-14 09:10 +0200 |
| Subject | [tip:perf/core] perf probe: Fix to show correct error message for $vars and $params |
| Message-ID | <rUIWu-6o9-37@gated-at.bofh.it> |
| In reply to | #1441207 |
Commit-ID: f6eb0518f325ef0d6557fbef5c7ebe48a81e74db
Gitweb: http://git.kernel.org/tip/f6eb0518f325ef0d6557fbef5c7ebe48a81e74db
Author: Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Tue, 12 Jul 2016 19:04:34 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Jul 2016 23:09:04 -0300
perf probe: Fix to show correct error message for $vars and $params
Fix to show correct error messages for $vars and $params because
those special variables requires debug information to find the
real variables or function parameters.
E.g. without this fix;
----
# perf probe -x /lib64/libc-2.23.so getaddrinfo \$params
Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature $params
Error: Failed to add events.
----
Perf ends up with an error, but the message is not correct. With this
fix, perf shows correct error message as below.
----
# perf probe -x /lib64/libc-2.23.so getaddrinfo \$params
The /usr/lib64/libc-2.23.so file has no debug information.
Rebuild with -g, or install an appropriate debuginfo package.
Error: Failed to add events.
----
Reported-and-Tested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146831787438.17065.6152436996780110699.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2b222a7..fef9768 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1547,7 +1547,9 @@ bool perf_probe_event_need_dwarf(struct perf_probe_event *pev)
return true;
for (i = 0; i < pev->nargs; i++)
- if (is_c_varname(pev->args[i].var))
+ if (is_c_varname(pev->args[i].var) ||
+ !strcmp(pev->args[i].var, "$params") ||
+ !strcmp(pev->args[i].var, "$vars"))
return true;
return false;
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rU2NB-3tA-51@gated-at.bofh.it> |
| In reply to | #1441198 |
Support @BUILDID or @FILE suffix for SDT events. This allows
perf to add probes on SDTs/pre-cached events on given FILE
or the file which has given BUILDID (also, this complements
BUILDID.)
For example, both gcc and libstdc++ has same SDTs as below.
If you would like to add a probe on sdt_libstdcxx:catch on gcc,
you can do as below.
----
# perf list sdt | tail -n 6
sdt_libstdcxx:catch@/usr/bin/gcc(0cc207fc4b27) [SDT event]
sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27) [SDT event]
sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27) [SDT event]
sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
# perf probe -a %sdt_libstdcxx:catch@0cc
Added new event:
sdt_libstdcxx:catch (on %catch in /usr/bin/gcc)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch -aR sleep 1
----
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
Changes in v12:
- Rename strlist__for_each to strlist__for_each_entry.
---
tools/perf/util/build-id.c | 43 +++++++++++++++++++++++++++++++++++++++++
tools/perf/util/build-id.h | 1 +
tools/perf/util/probe-event.c | 17 ++++++++++++++--
3 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 8e86a83..e59003e 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -523,6 +523,49 @@ err_out:
goto out_free;
}
+static bool str_is_build_id(const char *maybe_sbuild_id, size_t len)
+{
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (!isxdigit(maybe_sbuild_id[i]))
+ return false;
+ }
+ return true;
+}
+
+/* Return the valid complete build-id */
+char *build_id_cache__complement(const char *incomplete_sbuild_id)
+{
+ struct strlist *bidlist;
+ struct str_node *nd, *cand = NULL;
+ char *sbuild_id = NULL;
+ size_t len = strlen(incomplete_sbuild_id);
+
+ if (len >= SBUILD_ID_SIZE ||
+ !str_is_build_id(incomplete_sbuild_id, len))
+ return NULL;
+
+ bidlist = build_id_cache__list_all(true);
+ if (!bidlist)
+ return NULL;
+
+ strlist__for_each_entry(nd, bidlist) {
+ if (strncmp(nd->s, incomplete_sbuild_id, len) != 0)
+ continue;
+ if (cand) { /* Error: There are more than 2 candidates. */
+ cand = NULL;
+ break;
+ }
+ cand = nd;
+ }
+ if (cand)
+ sbuild_id = strdup(cand->s);
+ strlist__delete(bidlist);
+
+ return sbuild_id;
+}
+
char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso)
{
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 64e740f..d279906 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -35,6 +35,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso);
struct strlist *build_id_cache__list_all(bool validonly);
+char *build_id_cache__complement(const char *incomplete_sbuild_id);
int build_id_cache__list_build_ids(const char *pathname,
struct strlist **result);
bool build_id_cache__cached(const char *sbuild_id);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 679aa6b..0dadaa3 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1251,8 +1251,21 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
ptr = strpbrk(arg, ";=@+%");
if (pev->sdt) {
if (ptr) {
- semantic_error("%s must contain only an SDT event name.\n", arg);
- return -EINVAL;
+ if (*ptr != '@') {
+ semantic_error("%s must be an SDT name.\n",
+ arg);
+ return -EINVAL;
+ }
+ /* This must be a target file name or build id */
+ tmp = build_id_cache__complement(ptr + 1);
+ if (tmp) {
+ pev->target = build_id_cache__origname(tmp);
+ free(tmp);
+ } else
+ pev->target = strdup(ptr + 1);
+ if (!pev->target)
+ return -ENOMEM;
+ *ptr = '\0';
}
ret = parse_perf_probe_event_name(&arg, pev);
if (ret == 0) {
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-07-13 22:00 +0200 |
| Subject | Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rUyu5-7yz-5@gated-at.bofh.it> |
| In reply to | #1441209 |
Em Tue, Jul 12, 2016 at 07:05:37PM +0900, Masami Hiramatsu escreveu:
> Support @BUILDID or @FILE suffix for SDT events. This allows
> perf to add probes on SDTs/pre-cached events on given FILE
> or the file which has given BUILDID (also, this complements
> BUILDID.)
> For example, both gcc and libstdc++ has same SDTs as below.
> If you would like to add a probe on sdt_libstdcxx:catch on gcc,
> you can do as below.
Ok, how to add those entries?
[root@jouet hello_world]# perf probe -x /usr/bin/gcc -a %sdt_gcc:\*
Error: Failed to add events.
[root@jouet hello_world]# perf probe --verbose -x /usr/bin/gcc -a %sdt_gcc:\*
probe-definition(0): %sdt_gcc:*
0 arguments
symbol:throw file:(null) line:0 offset:0 return:0 lazy:(null)
symbol:rethrow file:(null) line:0 offset:0 return:0 lazy:(null)
symbol:catch file:(null) line:0 offset:0 return:0 lazy:(null)
symbol:unwind file:(null) line:0 offset:0 return:0 lazy:(null)
Error: Failed to add events. Reason: No such file or directory (Code: -2)
[root@jouet hello_world]#
Can those messages be improved? What am I missing?
> ----
> # perf list sdt | tail -n 6
> sdt_libstdcxx:catch@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> # perf probe -a %sdt_libstdcxx:catch@0cc
> Added new event:
> sdt_libstdcxx:catch (on %catch in /usr/bin/gcc)
>
> You can now use it in all perf tools, such as:
>
> perf record -e sdt_libstdcxx:catch -aR sleep 1
> ----
>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
> Changes in v12:
> - Rename strlist__for_each to strlist__for_each_entry.
> ---
> tools/perf/util/build-id.c | 43 +++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/build-id.h | 1 +
> tools/perf/util/probe-event.c | 17 ++++++++++++++--
> 3 files changed, 59 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index 8e86a83..e59003e 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -523,6 +523,49 @@ err_out:
> goto out_free;
> }
>
> +static bool str_is_build_id(const char *maybe_sbuild_id, size_t len)
> +{
> + size_t i;
> +
> + for (i = 0; i < len; i++) {
> + if (!isxdigit(maybe_sbuild_id[i]))
> + return false;
> + }
> + return true;
> +}
> +
> +/* Return the valid complete build-id */
> +char *build_id_cache__complement(const char *incomplete_sbuild_id)
> +{
> + struct strlist *bidlist;
> + struct str_node *nd, *cand = NULL;
> + char *sbuild_id = NULL;
> + size_t len = strlen(incomplete_sbuild_id);
> +
> + if (len >= SBUILD_ID_SIZE ||
> + !str_is_build_id(incomplete_sbuild_id, len))
> + return NULL;
> +
> + bidlist = build_id_cache__list_all(true);
> + if (!bidlist)
> + return NULL;
> +
> + strlist__for_each_entry(nd, bidlist) {
> + if (strncmp(nd->s, incomplete_sbuild_id, len) != 0)
> + continue;
> + if (cand) { /* Error: There are more than 2 candidates. */
> + cand = NULL;
> + break;
> + }
> + cand = nd;
> + }
> + if (cand)
> + sbuild_id = strdup(cand->s);
> + strlist__delete(bidlist);
> +
> + return sbuild_id;
> +}
> +
> char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
> bool is_kallsyms, bool is_vdso)
> {
> diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
> index 64e740f..d279906 100644
> --- a/tools/perf/util/build-id.h
> +++ b/tools/perf/util/build-id.h
> @@ -35,6 +35,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
> char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
> bool is_kallsyms, bool is_vdso);
> struct strlist *build_id_cache__list_all(bool validonly);
> +char *build_id_cache__complement(const char *incomplete_sbuild_id);
> int build_id_cache__list_build_ids(const char *pathname,
> struct strlist **result);
> bool build_id_cache__cached(const char *sbuild_id);
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 679aa6b..0dadaa3 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -1251,8 +1251,21 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
> ptr = strpbrk(arg, ";=@+%");
> if (pev->sdt) {
> if (ptr) {
> - semantic_error("%s must contain only an SDT event name.\n", arg);
> - return -EINVAL;
> + if (*ptr != '@') {
> + semantic_error("%s must be an SDT name.\n",
> + arg);
> + return -EINVAL;
> + }
> + /* This must be a target file name or build id */
> + tmp = build_id_cache__complement(ptr + 1);
> + if (tmp) {
> + pev->target = build_id_cache__origname(tmp);
> + free(tmp);
> + } else
> + pev->target = strdup(ptr + 1);
> + if (!pev->target)
> + return -ENOMEM;
> + *ptr = '\0';
> }
> ret = parse_perf_probe_event_name(&arg, pev);
> if (ret == 0) {
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-07-14 02:10 +0200 |
| Subject | Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rUCo2-1X5-15@gated-at.bofh.it> |
| In reply to | #1442798 |
Em Wed, Jul 13, 2016 at 04:50:19PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Jul 12, 2016 at 07:05:37PM +0900, Masami Hiramatsu escreveu:
> > Support @BUILDID or @FILE suffix for SDT events. This allows
> > perf to add probes on SDTs/pre-cached events on given FILE
> > or the file which has given BUILDID (also, this complements
> > BUILDID.)
> > For example, both gcc and libstdc++ has same SDTs as below.
> > If you would like to add a probe on sdt_libstdcxx:catch on gcc,
> > you can do as below.
>
> Ok, how to add those entries?
>
> [root@jouet hello_world]# perf probe -x /usr/bin/gcc -a %sdt_gcc:\*
> Error: Failed to add events.
> [root@jouet hello_world]# perf probe --verbose -x /usr/bin/gcc -a %sdt_gcc:\*
> probe-definition(0): %sdt_gcc:*
> 0 arguments
> symbol:throw file:(null) line:0 offset:0 return:0 lazy:(null)
> symbol:rethrow file:(null) line:0 offset:0 return:0 lazy:(null)
> symbol:catch file:(null) line:0 offset:0 return:0 lazy:(null)
> symbol:unwind file:(null) line:0 offset:0 return:0 lazy:(null)
> Error: Failed to add events. Reason: No such file or directory (Code: -2)
> [root@jouet hello_world]#
So, ok, I managed with:
[root@jouet ~]# perf probe -x /usr/bin/gcc %sdt_libstdcxx:\*
Added new events:
sdt_libstdcxx:throw (on %* in /usr/bin/gcc)
sdt_libstdcxx:rethrow (on %* in /usr/bin/gcc)
sdt_libstdcxx:catch (on %* in /usr/bin/gcc)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch -aR sleep 1
[root@jouet ~]#
I then tried to remove the events just created:
# perf probe -d %sdt_libstdcxx:\*
#
It tells me nothing, cool, probably it removed it all, then I go and
try re-adding them:
[root@jouet ~]# perf probe -x /usr/bin/gcc %sdt_libstdcxx:\*
Error: event "throw" already exists.
Hint: Remove existing event by 'perf probe -d'
or force duplicates by 'perf probe -f'
or set 'force=yes' in BPF source.
Error: Failed to add events.
[root@jouet ~]#
Huh?
Then I tried like you did above, using 'perf list sdt'
[root@jouet ~]# perf list sdt
List of pre-defined events (to be used in -e):
[root@jouet ~]#
But they appear via 'perf probe -l'
[root@jouet ~]# perf probe -l sdt_libs*
sdt_libstdcxx:catch (on execute_cfa_program+1551@../../../libgcc/unwind-dw2.c in /usr/bin/gcc)
sdt_libstdcxx:rethrow (on d_print_subexpr+280@libsupc++/cp-demangle.c in /usr/bin/gcc)
sdt_libstdcxx:throw (on d_print_subexpr+93@libsupc++/cp-demangle.c in /usr/bin/gcc)
[root@jouet ~]#
There is no event, then, guessing, I tried removing that %, since I don't see
it in the 'perf probe -l' output, so it must've been just some distracting
artifact at the time of adding the SDT prove:
[root@jouet ~]# perf probe -d sdt_libstdcxx:\*
Removed event: sdt_libstdcxx:catch
Removed event: sdt_libstdcxx:rethrow
Removed event: sdt_libstdcxx:throw
[root@jouet ~]# perf probe -l sdt_libs*
[root@jouet ~]#
Ok, now it works, but then if I try having both the gcc and libstdc++ ones, I can't:
[root@jouet ~]# perf probe -x /usr/lib64/libstdc++.so.6 %sdt_libstdcxx:\*
Error: event "catch" already exists.
Hint: Remove existing event by 'perf probe -d'
or force duplicates by 'perf probe -f'
or set 'force=yes' in BPF source.
Error: Failed to add events.
So I forced it:
[root@jouet ~]# perf probe -f -x /usr/lib64/libstdc++.so.6 %sdt_libstdcxx:\*
Added new events:
sdt_libstdcxx:catch_1 (on %* in /usr/lib64/libstdc++.so.6.0.22)
sdt_libstdcxx:throw_1 (on %* in /usr/lib64/libstdc++.so.6.0.22)
sdt_libstdcxx:rethrow_1 (on %* in /usr/lib64/libstdc++.so.6.0.22)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:rethrow_1 -aR sleep 1
[root@jouet ~]#
If it will rename it, why require -f? Where is the duplicity?
If I go and re-read all the discussion on the thread that lead to these
patches, I may figure out all those questions, but then, that would be a lot
of info to have in mind :-\
I.e. I would suggest that no -f should be needed, that that "Error: event
"catch" already exists" shouldn't be even emitted, since those will be
different events, i.e. one is named "sdt_libstdcxx:catch" and the other
"sdt_libstdcxx:catch_1"...
But that becomes an usability problem, couldn't it have the basename in it?
I.e.:
sdt_gcc_libstdcxx:catch and sdt_libstdc++:catch?
I'm going to look my inbox for patches I overlook that added 'perf list sdt'...
- Arnaldo
> Can those messages be improved? What am I missing?
>
> > ----
> > # perf list sdt | tail -n 6
> > sdt_libstdcxx:catch@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> > sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> > sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> > sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> > sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> > sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> > # perf probe -a %sdt_libstdcxx:catch@0cc
> > Added new event:
> > sdt_libstdcxx:catch (on %catch in /usr/bin/gcc)
> >
> > You can now use it in all perf tools, such as:
> >
> > perf record -e sdt_libstdcxx:catch -aR sleep 1
> > ----
> >
> > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> > ---
> > Changes in v12:
> > - Rename strlist__for_each to strlist__for_each_entry.
> > ---
> > tools/perf/util/build-id.c | 43 +++++++++++++++++++++++++++++++++++++++++
> > tools/perf/util/build-id.h | 1 +
> > tools/perf/util/probe-event.c | 17 ++++++++++++++--
> > 3 files changed, 59 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> > index 8e86a83..e59003e 100644
> > --- a/tools/perf/util/build-id.c
> > +++ b/tools/perf/util/build-id.c
> > @@ -523,6 +523,49 @@ err_out:
> > goto out_free;
> > }
> >
> > +static bool str_is_build_id(const char *maybe_sbuild_id, size_t len)
> > +{
> > + size_t i;
> > +
> > + for (i = 0; i < len; i++) {
> > + if (!isxdigit(maybe_sbuild_id[i]))
> > + return false;
> > + }
> > + return true;
> > +}
> > +
> > +/* Return the valid complete build-id */
> > +char *build_id_cache__complement(const char *incomplete_sbuild_id)
> > +{
> > + struct strlist *bidlist;
> > + struct str_node *nd, *cand = NULL;
> > + char *sbuild_id = NULL;
> > + size_t len = strlen(incomplete_sbuild_id);
> > +
> > + if (len >= SBUILD_ID_SIZE ||
> > + !str_is_build_id(incomplete_sbuild_id, len))
> > + return NULL;
> > +
> > + bidlist = build_id_cache__list_all(true);
> > + if (!bidlist)
> > + return NULL;
> > +
> > + strlist__for_each_entry(nd, bidlist) {
> > + if (strncmp(nd->s, incomplete_sbuild_id, len) != 0)
> > + continue;
> > + if (cand) { /* Error: There are more than 2 candidates. */
> > + cand = NULL;
> > + break;
> > + }
> > + cand = nd;
> > + }
> > + if (cand)
> > + sbuild_id = strdup(cand->s);
> > + strlist__delete(bidlist);
> > +
> > + return sbuild_id;
> > +}
> > +
> > char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
> > bool is_kallsyms, bool is_vdso)
> > {
> > diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
> > index 64e740f..d279906 100644
> > --- a/tools/perf/util/build-id.h
> > +++ b/tools/perf/util/build-id.h
> > @@ -35,6 +35,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
> > char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
> > bool is_kallsyms, bool is_vdso);
> > struct strlist *build_id_cache__list_all(bool validonly);
> > +char *build_id_cache__complement(const char *incomplete_sbuild_id);
> > int build_id_cache__list_build_ids(const char *pathname,
> > struct strlist **result);
> > bool build_id_cache__cached(const char *sbuild_id);
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 679aa6b..0dadaa3 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -1251,8 +1251,21 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
> > ptr = strpbrk(arg, ";=@+%");
> > if (pev->sdt) {
> > if (ptr) {
> > - semantic_error("%s must contain only an SDT event name.\n", arg);
> > - return -EINVAL;
> > + if (*ptr != '@') {
> > + semantic_error("%s must be an SDT name.\n",
> > + arg);
> > + return -EINVAL;
> > + }
> > + /* This must be a target file name or build id */
> > + tmp = build_id_cache__complement(ptr + 1);
> > + if (tmp) {
> > + pev->target = build_id_cache__origname(tmp);
> > + free(tmp);
> > + } else
> > + pev->target = strdup(ptr + 1);
> > + if (!pev->target)
> > + return -ENOMEM;
> > + *ptr = '\0';
> > }
> > ret = parse_perf_probe_event_name(&arg, pev);
> > if (ret == 0) {
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-07-14 02:20 +0200 |
| Subject | Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rUCxH-20Y-7@gated-at.bofh.it> |
| In reply to | #1442951 |
Em Wed, Jul 13, 2016 at 09:07:19PM -0300, Arnaldo Carvalho de Melo escreveu: > I'm going to look my inbox for patches I overlook that added 'perf list sdt'... So it is here: -> 976 T 06/24 Masami Hiramats (7.2K) [PATCH perf/core v12 08/16] perf-list: Show SDT and pre-cached events June, 24, you forgot to rebase it for this new cset series, I'm doing that now. - Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-07-14 02:30 +0200 |
| Subject | Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rUCHn-24M-1@gated-at.bofh.it> |
| In reply to | #1442953 |
Em Wed, Jul 13, 2016 at 09:16:32PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Wed, Jul 13, 2016 at 09:07:19PM -0300, Arnaldo Carvalho de Melo escreveu: > > I'm going to look my inbox for patches I overlook that added 'perf list sdt'... > > So it is here: > > -> 976 T 06/24 Masami Hiramats (7.2K) [PATCH perf/core v12 08/16] perf-list: Show SDT and pre-cached events > > June, 24, you forgot to rebase it for this new cset series, I'm doing > that now. Ok, now it works: [root@jouet ~]# perf list sdt List of pre-defined events (to be used in -e): sdt_libc:lll_lock_wait_private [SDT event] sdt_libc:longjmp [SDT event] sdt_libc:longjmp_target [SDT event] sdt_libc:memory_arena_new [SDT event] sdt_libc:memory_arena_retry [SDT event] sdt_libc:memory_arena_reuse [SDT event] sdt_libc:memory_arena_reuse_free_list [SDT event] sdt_libc:memory_arena_reuse_wait [SDT event] sdt_libc:memory_calloc_retry [SDT event] sdt_libc:memory_heap_free [SDT event] sdt_libc:memory_heap_less [SDT event] sdt_libc:memory_heap_more [SDT event] sdt_libc:memory_heap_new [SDT event] sdt_libc:memory_malloc_retry [SDT event] sdt_libc:memory_mallopt [SDT event] sdt_libc:memory_mallopt_arena_max [SDT event] sdt_libc:memory_mallopt_arena_test [SDT event] sdt_libc:memory_mallopt_check_action [SDT event] sdt_libc:memory_mallopt_free_dyn_thresholds [SDT event] sdt_libc:memory_mallopt_mmap_max [SDT event] sdt_libc:memory_mallopt_mmap_threshold [SDT event] sdt_libc:memory_mallopt_mxfast [SDT event] sdt_libc:memory_mallopt_perturb [SDT event] sdt_libc:memory_mallopt_top_pad [SDT event] sdt_libc:memory_mallopt_trim_threshold [SDT event] sdt_libc:memory_memalign_retry [SDT event] sdt_libc:memory_realloc_retry [SDT event] sdt_libc:memory_sbrk_less [SDT event] sdt_libc:memory_sbrk_more [SDT event] sdt_libc:setjmp [SDT event] sdt_libgcc:unwind [SDT event] sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6) [SDT event] sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event] sdt_libstdcxx:rethrow@/usr/bin/gcc(9a0730e2bcc6) [SDT event] sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event] sdt_libstdcxx:throw@/usr/bin/gcc(9a0730e2bcc6) [SDT event] sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event] [root@jouet ~]#
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-14 17:40 +0200 |
| Subject | Re: [PATCH perf/core 07/10] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rUQU1-31t-19@gated-at.bofh.it> |
| In reply to | #1442954 |
On Wed, 13 Jul 2016 21:20:48 -0300 Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > Em Wed, Jul 13, 2016 at 09:16:32PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Wed, Jul 13, 2016 at 09:07:19PM -0300, Arnaldo Carvalho de Melo escreveu: > > > I'm going to look my inbox for patches I overlook that added 'perf list sdt'... > > > > So it is here: > > > > -> 976 T 06/24 Masami Hiramats (7.2K) [PATCH perf/core v12 08/16] perf-list: Show SDT and pre-cached events > > > > June, 24, you forgot to rebase it for this new cset series, I'm doing > > that now. Ah, I just dropped it because this series still not support direct recording yet. If we show the below SDTs by perf-list, we have to support it on perf-record which is under developed now. Thank you, > > Ok, now it works: > > > [root@jouet ~]# perf list sdt > > List of pre-defined events (to be used in -e): > > sdt_libc:lll_lock_wait_private [SDT event] > sdt_libc:longjmp [SDT event] > sdt_libc:longjmp_target [SDT event] > sdt_libc:memory_arena_new [SDT event] > sdt_libc:memory_arena_retry [SDT event] > sdt_libc:memory_arena_reuse [SDT event] > sdt_libc:memory_arena_reuse_free_list [SDT event] > sdt_libc:memory_arena_reuse_wait [SDT event] > sdt_libc:memory_calloc_retry [SDT event] > sdt_libc:memory_heap_free [SDT event] > sdt_libc:memory_heap_less [SDT event] > sdt_libc:memory_heap_more [SDT event] > sdt_libc:memory_heap_new [SDT event] > sdt_libc:memory_malloc_retry [SDT event] > sdt_libc:memory_mallopt [SDT event] > sdt_libc:memory_mallopt_arena_max [SDT event] > sdt_libc:memory_mallopt_arena_test [SDT event] > sdt_libc:memory_mallopt_check_action [SDT event] > sdt_libc:memory_mallopt_free_dyn_thresholds [SDT event] > sdt_libc:memory_mallopt_mmap_max [SDT event] > sdt_libc:memory_mallopt_mmap_threshold [SDT event] > sdt_libc:memory_mallopt_mxfast [SDT event] > sdt_libc:memory_mallopt_perturb [SDT event] > sdt_libc:memory_mallopt_top_pad [SDT event] > sdt_libc:memory_mallopt_trim_threshold [SDT event] > sdt_libc:memory_memalign_retry [SDT event] > sdt_libc:memory_realloc_retry [SDT event] > sdt_libc:memory_sbrk_less [SDT event] > sdt_libc:memory_sbrk_more [SDT event] > sdt_libc:setjmp [SDT event] > sdt_libgcc:unwind [SDT event] > sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6) [SDT event] > sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event] > sdt_libstdcxx:rethrow@/usr/bin/gcc(9a0730e2bcc6) [SDT event] > sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event] > sdt_libstdcxx:throw@/usr/bin/gcc(9a0730e2bcc6) [SDT event] > sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event] > [root@jouet ~]# -- Masami Hiramatsu <mhiramat@kernel.org>
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-07-14 09:10 +0200 |
| Subject | [tip:perf/core] perf probe: Support @BUILDID or @FILE suffix for SDT events |
| Message-ID | <rUIWv-6o9-59@gated-at.bofh.it> |
| In reply to | #1441209 |
Commit-ID: a598180aa1279bac4d24dfc85cd2d78553c4210d
Gitweb: http://git.kernel.org/tip/a598180aa1279bac4d24dfc85cd2d78553c4210d
Author: Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Tue, 12 Jul 2016 19:05:37 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Jul 2016 23:09:08 -0300
perf probe: Support @BUILDID or @FILE suffix for SDT events
Support @BUILDID or @FILE suffix for SDT events. This allows perf to add
probes on SDTs/pre-cached events on given FILE or the file which has
given BUILDID (also, this complements BUILDID.)
For example, both gcc and libstdc++ has same SDTs as below. If you
would like to add a probe on sdt_libstdcxx:catch on gcc, you can do as
below.
----
# perf list sdt | tail -n 6
sdt_libstdcxx:catch@/usr/bin/gcc(0cc207fc4b27) [SDT event]
sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27) [SDT event]
sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27) [SDT event]
sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
# perf probe -a %sdt_libstdcxx:catch@0cc
Added new event:
sdt_libstdcxx:catch (on %catch in /usr/bin/gcc)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch -aR sleep 1
----
Committer note:
Doing the full sequence of steps to get the results above:
With a clean build-id cache:
[root@jouet ~]# rm -rf ~/.debug/
[root@jouet ~]# perf list sdt
List of pre-defined events (to be used in -e):
[root@jouet ~]#
No events whatsoever, then, we can add all events in gcc to the build-id
cache, doing a --add + --dry-run:
[root@jouet ~]# perf probe --dry-run --cache -x /usr/bin/gcc --add %sdt_libstdcxx:\*
Added new events:
sdt_libstdcxx:throw (on %* in /usr/bin/gcc)
sdt_libstdcxx:rethrow (on %* in /usr/bin/gcc)
sdt_libstdcxx:catch (on %* in /usr/bin/gcc)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch -aR sleep 1
[root@jouet ~]#
It really didn't add any events, it just cached them:
[root@jouet ~]# perf probe -l
[root@jouet ~]#
We can see that it was cached as:
[root@jouet ~]# ls -la ~/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/
total 976
drwxr-xr-x. 2 root root 4096 Jul 13 21:47 .
drwxr-xr-x. 3 root root 4096 Jul 13 21:47 ..
-rwxr-xr-x. 4 root root 985912 Jun 22 18:52 elf
-rw-r--r--. 1 root root 303 Jul 13 21:47 probes
[root@jouet ~]# file ~/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/elf
/root/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/elf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2, stripped
[root@jouet ~]# cat ~/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/probes
%sdt_libstdcxx:throw=throw
p:sdt_libstdcxx/throw /usr/bin/gcc:0x71ffd
%sdt_libstdcxx:rethrow=rethrow
p:sdt_libstdcxx/rethrow /usr/bin/gcc:0x720b8
%sdt_libstdcxx:catch=catch
p:sdt_libstdcxx/catch /usr/bin/gcc:0x7307f
%sdt_libgcc:unwind=unwind
p:sdt_libgcc/unwind /usr/bin/gcc:0x7eec0
#sdt_libstdcxx:*=%*
[root@jouet ~]#
Ok, now we can use 'perf probe' to refer to those cached entries as:
Humm, nope, doing as above we end up with:
[root@jouet ~]# perf probe -a %sdt_libstdcxx:catch
Semantic error :* is bad for event name -it must follow C symbol-naming rule.
Error: Failed to add events.
[root@jouet ~]#
But it worked at some point, lets try not using --dry-run:
Resetting everything:
# rm -rf ~/.debug/
# perf probe -d *:*
# perf probe -l
# perf list sdt
List of pre-defined events (to be used in -e):
#
Ok, now it cached everything, even things we haven't asked it to
(sdt_libgcc:unwind):
[root@jouet ~]# perf probe -x /usr/bin/gcc --add %sdt_libstdcxx:\*
Added new events:
sdt_libstdcxx:throw (on %* in /usr/bin/gcc)
sdt_libstdcxx:rethrow (on %* in /usr/bin/gcc)
sdt_libstdcxx:catch (on %* in /usr/bin/gcc)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch -aR sleep 1
[root@jouet ~]# perf list sdt
List of pre-defined events (to be used in -e):
sdt_libgcc:unwind [SDT event]
sdt_libstdcxx:catch [SDT event]
sdt_libstdcxx:rethrow [SDT event]
sdt_libstdcxx:throw [SDT event]
[root@jouet ~]#
And we have the events in place:
[root@jouet ~]# perf probe -l
sdt_libstdcxx:catch (on execute_cfa_program+1551@../../../libgcc/unwind-dw2.c in /usr/bin/gcc)
sdt_libstdcxx:rethrow (on d_print_subexpr+280@libsupc++/cp-demangle.c in /usr/bin/gcc)
sdt_libstdcxx:throw (on d_print_subexpr+93@libsupc++/cp-demangle.c in /usr/bin/gcc)
[root@jouet ~]#
And trying to use them at least has 'perf trace --event sdt*:*' working.
Then, if we try to add the ones in libstdc++:
[root@jouet ~]# perf probe -x /usr/lib64/libstdc++.so.6 -a %sdt_libstdcxx:\*
Error: event "catch" already exists.
Hint: Remove existing event by 'perf probe -d'
or force duplicates by 'perf probe -f'
or set 'force=yes' in BPF source.
Error: Failed to add events.
[root@jouet ~]#
Doesn't work, dups, but at least this served to, unbeknownst to the user, add
the SDT probes in /usr/lib64/libstdc++.so.6!
[root@jouet ~]# perf list sdt
List of pre-defined events (to be used in -e):
sdt_libgcc:unwind [SDT event]
sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6) [SDT event]
sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
sdt_libstdcxx:rethrow@/usr/bin/gcc(9a0730e2bcc6) [SDT event]
sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
sdt_libstdcxx:throw@/usr/bin/gcc(9a0730e2bcc6) [SDT event]
sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
[root@jouet ~]#
Now we should be able to get to the original cset comment, if we remove all
SDTs events in place, not from the cache, from the kernel, where it was set up as:
[root@jouet ~]# ls -la /sys/kernel/debug/tracing/events/sdt_libstdcxx/
total 0
drwxr-xr-x. 5 root root 0 Jul 13 22:00 .
drwxr-xr-x. 80 root root 0 Jul 13 21:56 ..
drwxr-xr-x. 2 root root 0 Jul 13 22:00 catch
-rw-r--r--. 1 root root 0 Jul 13 22:00 enable
-rw-r--r--. 1 root root 0 Jul 13 22:00 filter
drwxr-xr-x. 2 root root 0 Jul 13 22:00 rethrow
drwxr-xr-x. 2 root root 0 Jul 13 22:00 throw
[root@jouet ~]#
[root@jouet ~]# head -2 /sys/kernel/debug/tracing/events/sdt_libstdcxx/throw/format
name: throw
ID: 2059
[root@jouet ~]#
Now to remove it:
[root@jouet ~]# perf probe -d sdt_libstdc*:*
Removed event: sdt_libstdcxx:catch
Removed event: sdt_libstdcxx:rethrow
Removed event: sdt_libstdcxx:throw
[root@jouet ~]#
Which caused:
[root@jouet ~]# ls -la /sys/kernel/debug/tracing/events/sdt_libstdcxx/
ls: cannot access '/sys/kernel/debug/tracing/events/sdt_libstdcxx/': No such file or directory
[root@jouet ~]#
Ok, now we can do:
[root@jouet ~]# perf list sdt_libstdcxx:catch
List of pre-defined events (to be used in -e):
sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6) [SDT event]
sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
[root@jouet ~]#
So, these are not really 'pre-defined events', i.e. we can't use them with
'perf record --event':
[root@jouet ~]# perf record --event sdt_libstdcxx:catch*
event syntax error: 'sdt_libstdcxx:catch*'
\___ unknown tracepoint
Error: File /sys/kernel/debug/tracing/events/sdt_libstdcxx/catch* not found.
Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
<SNIP>
[root@jouet ~]#
To have it really pre-defined we must use perf probe to get its definition from
the cache and set it up in the kernel, creating the tracepoint to _then_ use it
with 'perf record --event':
[root@jouet ~]# perf probe -a sdt_libstdcxx:catch
Semantic error :There is non-digit char in line number.
<SNIP>
Oops, there is another gotcha here, we need that pesky '%' character:
[root@jouet ~]# perf probe -a %sdt_libstdcxx:catch
Added new events:
sdt_libstdcxx:catch (on %catch in /usr/bin/gcc)
sdt_libstdcxx:catch_1 (on %catch in /usr/lib64/libstdc++.so.6.0.22)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch_1 -aR sleep 1
[root@jouet ~]#
But then we added _two_ events, one with the name we expected, the other one
with a _ added, when doing the analysis we need to pay attention to who maps to
who.
And here is where we get to the point of this patch, which is to be able to
disambiguate those definitions for 'catch' in the build-id cache, but first we need
remove those events we just added:
[root@jouet ~]# perf probe -d %sdt_libstdcxx:catch
Oops, that didn't remove anything, we need to _remove_ that % char in this case:
[root@jouet ~]# perf probe -d sdt_libstdcxx:catch
Removed event: sdt_libstdcxx:catch
And we need to remove the other event added, i.e. I forgot to add a * at the end:
[root@jouet ~]# perf probe -d sdt_libstdcxx:catch*
Removed event: sdt_libstdcxx:catch_1
[root@jouet ~]#
Ok, disambiguating it using what is in this patch:
[root@jouet ~]# perf list sdt_libstdcxx:catch
List of pre-defined events (to be used in -e):
sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6) [SDT event]
sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
[root@jouet ~]#
[root@jouet ~]# perf probe -a %sdt_libstdcxx:catch@9a07
Added new event:
sdt_libstdcxx:catch (on %catch in /usr/bin/gcc)
You can now use it in all perf tools, such as:
perf record -e sdt_libstdcxx:catch -aR sleep 1
[root@jouet ~]# perf probe -l
sdt_libstdcxx:catch (on execute_cfa_program+1551@../../../libgcc/unwind-dw2.c in /usr/bin/gcc)
[root@jouet ~]#
Yeah, it works! But we need to try and simplify this :-)
Update: Some aspects of this simplification take place in the following
patches.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146831793746.17065.13065062753978236612.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/build-id.c | 43 +++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/build-id.h | 1 +
tools/perf/util/probe-event.c | 17 +++++++++++++++--
3 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 36b4279..5651f3c 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -523,6 +523,49 @@ err_out:
goto out_free;
}
+static bool str_is_build_id(const char *maybe_sbuild_id, size_t len)
+{
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (!isxdigit(maybe_sbuild_id[i]))
+ return false;
+ }
+ return true;
+}
+
+/* Return the valid complete build-id */
+char *build_id_cache__complement(const char *incomplete_sbuild_id)
+{
+ struct strlist *bidlist;
+ struct str_node *nd, *cand = NULL;
+ char *sbuild_id = NULL;
+ size_t len = strlen(incomplete_sbuild_id);
+
+ if (len >= SBUILD_ID_SIZE ||
+ !str_is_build_id(incomplete_sbuild_id, len))
+ return NULL;
+
+ bidlist = build_id_cache__list_all(true);
+ if (!bidlist)
+ return NULL;
+
+ strlist__for_each_entry(nd, bidlist) {
+ if (strncmp(nd->s, incomplete_sbuild_id, len) != 0)
+ continue;
+ if (cand) { /* Error: There are more than 2 candidates. */
+ cand = NULL;
+ break;
+ }
+ cand = nd;
+ }
+ if (cand)
+ sbuild_id = strdup(cand->s);
+ strlist__delete(bidlist);
+
+ return sbuild_id;
+}
+
char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso)
{
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 64e740f..d279906 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -35,6 +35,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso);
struct strlist *build_id_cache__list_all(bool validonly);
+char *build_id_cache__complement(const char *incomplete_sbuild_id);
int build_id_cache__list_build_ids(const char *pathname,
struct strlist **result);
bool build_id_cache__cached(const char *sbuild_id);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index c63e3b8..f12081e 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1251,8 +1251,21 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
ptr = strpbrk(arg, ";=@+%");
if (pev->sdt) {
if (ptr) {
- semantic_error("%s must contain only an SDT event name.\n", arg);
- return -EINVAL;
+ if (*ptr != '@') {
+ semantic_error("%s must be an SDT name.\n",
+ arg);
+ return -EINVAL;
+ }
+ /* This must be a target file name or build id */
+ tmp = build_id_cache__complement(ptr + 1);
+ if (tmp) {
+ pev->target = build_id_cache__origname(tmp);
+ free(tmp);
+ } else
+ pev->target = strdup(ptr + 1);
+ if (!pev->target)
+ return -ENOMEM;
+ *ptr = '\0';
}
ret = parse_perf_probe_event_name(&arg, pev);
if (ret == 0) {
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH perf/core 08/10] perf probe: Support a special SDT probe format |
| Message-ID | <rU2NB-3tA-55@gated-at.bofh.it> |
| In reply to | #1441198 |
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 0dadaa3..e12e3b0 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]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-07-14 09:10 +0200 |
| Subject | [tip:perf/core] perf probe: Support a special SDT probe format |
| Message-ID | <rUIWu-6o9-31@gated-at.bofh.it> |
| In reply to | #1441212 |
Commit-ID: 7e9fca51fbf8430e27fb6b29299eda575e3f00cf
Gitweb: http://git.kernel.org/tip/7e9fca51fbf8430e27fb6b29299eda575e3f00cf
Author: Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Tue, 12 Jul 2016 19:05:46 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Jul 2016 23:09:09 -0300
perf probe: Support a special SDT probe format
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>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146831794674.17065.13359473252168740430.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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 f12081e..d4f8835 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]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web