Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1465023 > unrolled thread
| Started by | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| First post | 2016-08-18 11:10 +0200 |
| Last post | 2016-08-24 11:30 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/6] perf probe: Add supported type casting of running kernel Masami Hiramatsu <mhiramat@kernel.org> - 2016-08-18 11:10 +0200
Re: [PATCH 3/6] perf probe: Add supported type casting of running kernel Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-08-23 21:50 +0200
[tip:perf/core] perf probe: Add supported for type casting by the running kernel tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-08-24 11:30 +0200
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2016-08-18 11:10 +0200 |
| Subject | [PATCH 3/6] perf probe: Add supported type casting of running kernel |
| Message-ID | <s7ruO-66w-33@gated-at.bofh.it> |
Add a checking routine what types are supported by the
running kernel by finding the pattern in
<debugfs>/tracing/README.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/perf/util/probe-file.c | 57 ++++++++++++++++++++++++++++++++++++++++
tools/perf/util/probe-file.h | 10 +++++++
tools/perf/util/probe-finder.c | 1 +
3 files changed, 68 insertions(+)
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 9aed9c3..552e56b 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -855,3 +855,60 @@ int probe_cache__show_all_caches(struct strfilter *filter)
return 0;
}
+
+static struct {
+ const char *pattern;
+ bool avail;
+ bool checked;
+} probe_type_table[] = {
+#define DEFINE_TYPE(idx, pat, def_avail) \
+ [idx] = {.pattern = pat, .avail = (def_avail)}
+ DEFINE_TYPE(PROBE_TYPE_U, "* u8/16/32/64,*", true),
+ DEFINE_TYPE(PROBE_TYPE_S, "* s8/16/32/64,*", true),
+ DEFINE_TYPE(PROBE_TYPE_X, "* x8/16/32/64,*", false),
+ DEFINE_TYPE(PROBE_TYPE_STRING, "* string,*", true),
+ DEFINE_TYPE(PROBE_TYPE_BITFIELD,
+ "* b<bit-width>@<bit-offset>/<container-size>", true),
+};
+
+bool probe_type_is_available(enum probe_type type)
+{
+ FILE *fp;
+ char *buf = NULL;
+ size_t len = 0;
+ bool target_line = false;
+ bool ret = probe_type_table[type].avail;
+
+ if (type < 0 || type >= PROBE_TYPE_END)
+ return false;
+ /* We don't have to check the type which supported by default */
+ if (ret || probe_type_table[type].checked)
+ return ret;
+
+ if (asprintf(&buf, "%s/README", tracing_path) < 0)
+ return ret;
+
+ fp = fopen(buf, "r");
+ if (!fp)
+ goto end;
+
+ zfree(&buf);
+ while (getline(&buf, &len, fp) > 0 && !ret) {
+ if (!target_line) {
+ target_line = !!strstr(buf, " type: ");
+ if (!target_line)
+ continue;
+ } else if (strstr(buf, "\t ") != buf)
+ break;
+ ret = strglobmatch(buf, probe_type_table[type].pattern);
+ }
+ /* Cache the result */
+ probe_type_table[type].checked = true;
+ probe_type_table[type].avail = ret;
+
+ fclose(fp);
+end:
+ free(buf);
+
+ return ret;
+}
diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
index 9577b5c..eba44c3 100644
--- a/tools/perf/util/probe-file.h
+++ b/tools/perf/util/probe-file.h
@@ -19,6 +19,15 @@ struct probe_cache {
struct list_head entries;
};
+enum probe_type {
+ PROBE_TYPE_U = 0,
+ PROBE_TYPE_S,
+ PROBE_TYPE_X,
+ PROBE_TYPE_STRING,
+ PROBE_TYPE_BITFIELD,
+ PROBE_TYPE_END,
+};
+
#define PF_FL_UPROBE 1
#define PF_FL_RW 2
#define for_each_probe_cache_entry(entry, pcache) \
@@ -54,6 +63,7 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
const char *group, const char *event);
int probe_cache__show_all_caches(struct strfilter *filter);
+bool probe_type_is_available(enum probe_type type);
#else /* ! HAVE_LIBELF_SUPPORT */
static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused)
{
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 5c290c6..24dbe23 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -39,6 +39,7 @@
#include "util.h"
#include "symbol.h"
#include "probe-finder.h"
+#include "probe-file.h"
/* Kprobe tracer basic type is up to u64 */
#define MAX_BASIC_TYPE_BITS 64
[toc] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-08-23 21:50 +0200 |
| Subject | Re: [PATCH 3/6] perf probe: Add supported type casting of running kernel |
| Message-ID | <s9pRU-8qt-29@gated-at.bofh.it> |
| In reply to | #1465023 |
Em Thu, Aug 18, 2016 at 05:58:31PM +0900, Masami Hiramatsu escreveu:
> Add a checking routine what types are supported by the
> running kernel by finding the pattern in
> <debugfs>/tracing/README.
Fails in several distros, I'm fixing it:
# time dm
1 67.863552726 alpine:3.4: Ok
2 26.710853767 android-ndk:r12b-arm: Ok
3 72.985361634 archlinux:latest: Ok
4 19.637909096 centos:5: FAIL
CC /tmp/build/perf/util/probe-event.o
cc1: warnings being treated as errors
util/probe-file.c: In function 'probe_type_is_available':
util/probe-file.c:904: warning: comparison of unsigned expression < 0 is always false
mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory
make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1
make[3]: *** Waiting for unfinished jobs....
5 28.720326873 centos:6: FAIL
cc1: warnings being treated as errors
util/probe-file.c: In function 'probe_type_is_available':
util/probe-file.c:904: error: comparison of unsigned expression < 0 is always false
mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory
make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1
make[3]: *** Waiting for unfinished jobs....
6 70.156507794 centos:7: Ok
7 32.013330592 debian:7: FAIL
CC /tmp/build/perf/util/probe-file.o
util/probe-file.c: In function 'probe_type_is_available':
util/probe-file.c:904:2: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
cc1: all warnings being treated as errors
mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory
make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1
make[3]: *** Waiting for unfinished jobs....
8 69.603178590 debian:8: Ok
9 73.783068558 debian:experimental: Ok
10 69.957097133 fedora:20: Ok
11 76.603382387 fedora:21: Ok
12 73.468157842 fedora:22: Ok
13 71.936508182 fedora:23: Ok
14 77.361195679 fedora:24: Ok
15 38.279025856 fedora:24-x-ARC-uClibc: Ok
16 97.249261355 fedora:rawhide: Ok
17 98.245080998 mageia:5: Ok
18 94.932568645 opensuse:13.2: Ok
19 75.037585460 opensuse:42.1: Ok
20 78.874088196 opensuse:tumbleweed: Ok
21 29.516286324 ubuntu:12.04.5: FAIL
CC /tmp/build/perf/util/probe-event.o
util/probe-file.c: In function 'probe_type_is_available':
util/probe-file.c:904:2: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
cc1: all warnings being treated as errors
mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory
make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1
make[3]: *** Waiting for unfinished jobs....
22 67.473466290 ubuntu:14.04.4: Ok
23 70.052930002 ubuntu:15.10: Ok
24 73.910662998 ubuntu:16.04: Ok
25 58.592432948 ubuntu:16.04-x-arm: Ok
26 53.732729132 ubuntu:16.04-x-arm64: Ok
27 53.279460667 ubuntu:16.04-x-powerpc64: Ok
28 53.933970903 ubuntu:16.04-x-powerpc64el: Ok
29 73.724853906 ubuntu:16.10: Ok
30 55.651095622 ubuntu:16.10-x-s390: Ok
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
> tools/perf/util/probe-file.c | 57 ++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/probe-file.h | 10 +++++++
> tools/perf/util/probe-finder.c | 1 +
> 3 files changed, 68 insertions(+)
>
> diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> index 9aed9c3..552e56b 100644
> --- a/tools/perf/util/probe-file.c
> +++ b/tools/perf/util/probe-file.c
> @@ -855,3 +855,60 @@ int probe_cache__show_all_caches(struct strfilter *filter)
>
> return 0;
> }
> +
> +static struct {
> + const char *pattern;
> + bool avail;
> + bool checked;
> +} probe_type_table[] = {
> +#define DEFINE_TYPE(idx, pat, def_avail) \
> + [idx] = {.pattern = pat, .avail = (def_avail)}
> + DEFINE_TYPE(PROBE_TYPE_U, "* u8/16/32/64,*", true),
> + DEFINE_TYPE(PROBE_TYPE_S, "* s8/16/32/64,*", true),
> + DEFINE_TYPE(PROBE_TYPE_X, "* x8/16/32/64,*", false),
> + DEFINE_TYPE(PROBE_TYPE_STRING, "* string,*", true),
> + DEFINE_TYPE(PROBE_TYPE_BITFIELD,
> + "* b<bit-width>@<bit-offset>/<container-size>", true),
> +};
> +
> +bool probe_type_is_available(enum probe_type type)
> +{
> + FILE *fp;
> + char *buf = NULL;
> + size_t len = 0;
> + bool target_line = false;
> + bool ret = probe_type_table[type].avail;
> +
> + if (type < 0 || type >= PROBE_TYPE_END)
> + return false;
> + /* We don't have to check the type which supported by default */
> + if (ret || probe_type_table[type].checked)
> + return ret;
> +
> + if (asprintf(&buf, "%s/README", tracing_path) < 0)
> + return ret;
> +
> + fp = fopen(buf, "r");
> + if (!fp)
> + goto end;
> +
> + zfree(&buf);
> + while (getline(&buf, &len, fp) > 0 && !ret) {
> + if (!target_line) {
> + target_line = !!strstr(buf, " type: ");
> + if (!target_line)
> + continue;
> + } else if (strstr(buf, "\t ") != buf)
> + break;
> + ret = strglobmatch(buf, probe_type_table[type].pattern);
> + }
> + /* Cache the result */
> + probe_type_table[type].checked = true;
> + probe_type_table[type].avail = ret;
> +
> + fclose(fp);
> +end:
> + free(buf);
> +
> + return ret;
> +}
> diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
> index 9577b5c..eba44c3 100644
> --- a/tools/perf/util/probe-file.h
> +++ b/tools/perf/util/probe-file.h
> @@ -19,6 +19,15 @@ struct probe_cache {
> struct list_head entries;
> };
>
> +enum probe_type {
> + PROBE_TYPE_U = 0,
> + PROBE_TYPE_S,
> + PROBE_TYPE_X,
> + PROBE_TYPE_STRING,
> + PROBE_TYPE_BITFIELD,
> + PROBE_TYPE_END,
> +};
> +
> #define PF_FL_UPROBE 1
> #define PF_FL_RW 2
> #define for_each_probe_cache_entry(entry, pcache) \
> @@ -54,6 +63,7 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
> struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
> const char *group, const char *event);
> int probe_cache__show_all_caches(struct strfilter *filter);
> +bool probe_type_is_available(enum probe_type type);
> #else /* ! HAVE_LIBELF_SUPPORT */
> static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused)
> {
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index 5c290c6..24dbe23 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -39,6 +39,7 @@
> #include "util.h"
> #include "symbol.h"
> #include "probe-finder.h"
> +#include "probe-file.h"
>
> /* Kprobe tracer basic type is up to u64 */
> #define MAX_BASIC_TYPE_BITS 64
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Masami Hiramatsu <tipbot@zytor.com> |
|---|---|
| Date | 2016-08-24 11:30 +0200 |
| Subject | [tip:perf/core] perf probe: Add supported for type casting by the running kernel |
| Message-ID | <s9CFt-gj-53@gated-at.bofh.it> |
| In reply to | #1465023 |
Commit-ID: 180b20616ce57e93eb692170c793be94c456b1e2
Gitweb: http://git.kernel.org/tip/180b20616ce57e93eb692170c793be94c456b1e2
Author: Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Thu, 18 Aug 2016 17:58:31 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 23 Aug 2016 17:03:31 -0300
perf probe: Add supported for type casting by the running kernel
Add a checking routine what types are supported by the running kernel by
finding the pattern in <debugfs>/tracing/README.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Naohiro Aota <naohiro.aota@hgst.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/147151071172.12957.3340095690753291085.stgit@devbox
[ 'enum probe_type' has no negative entries, so ends up as 'unsigned', remove '< 0'
test to fix the build on at least centos:5, debian:7 & ubuntu:12.04.5 ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-file.c | 57 ++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/probe-file.h | 10 ++++++++
tools/perf/util/probe-finder.c | 1 +
3 files changed, 68 insertions(+)
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 9c3b9ed..697ef66 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -877,3 +877,60 @@ int probe_cache__show_all_caches(struct strfilter *filter)
return 0;
}
+
+static struct {
+ const char *pattern;
+ bool avail;
+ bool checked;
+} probe_type_table[] = {
+#define DEFINE_TYPE(idx, pat, def_avail) \
+ [idx] = {.pattern = pat, .avail = (def_avail)}
+ DEFINE_TYPE(PROBE_TYPE_U, "* u8/16/32/64,*", true),
+ DEFINE_TYPE(PROBE_TYPE_S, "* s8/16/32/64,*", true),
+ DEFINE_TYPE(PROBE_TYPE_X, "* x8/16/32/64,*", false),
+ DEFINE_TYPE(PROBE_TYPE_STRING, "* string,*", true),
+ DEFINE_TYPE(PROBE_TYPE_BITFIELD,
+ "* b<bit-width>@<bit-offset>/<container-size>", true),
+};
+
+bool probe_type_is_available(enum probe_type type)
+{
+ FILE *fp;
+ char *buf = NULL;
+ size_t len = 0;
+ bool target_line = false;
+ bool ret = probe_type_table[type].avail;
+
+ if (type >= PROBE_TYPE_END)
+ return false;
+ /* We don't have to check the type which supported by default */
+ if (ret || probe_type_table[type].checked)
+ return ret;
+
+ if (asprintf(&buf, "%s/README", tracing_path) < 0)
+ return ret;
+
+ fp = fopen(buf, "r");
+ if (!fp)
+ goto end;
+
+ zfree(&buf);
+ while (getline(&buf, &len, fp) > 0 && !ret) {
+ if (!target_line) {
+ target_line = !!strstr(buf, " type: ");
+ if (!target_line)
+ continue;
+ } else if (strstr(buf, "\t ") != buf)
+ break;
+ ret = strglobmatch(buf, probe_type_table[type].pattern);
+ }
+ /* Cache the result */
+ probe_type_table[type].checked = true;
+ probe_type_table[type].avail = ret;
+
+ fclose(fp);
+end:
+ free(buf);
+
+ return ret;
+}
diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
index 9577b5c..eba44c3 100644
--- a/tools/perf/util/probe-file.h
+++ b/tools/perf/util/probe-file.h
@@ -19,6 +19,15 @@ struct probe_cache {
struct list_head entries;
};
+enum probe_type {
+ PROBE_TYPE_U = 0,
+ PROBE_TYPE_S,
+ PROBE_TYPE_X,
+ PROBE_TYPE_STRING,
+ PROBE_TYPE_BITFIELD,
+ PROBE_TYPE_END,
+};
+
#define PF_FL_UPROBE 1
#define PF_FL_RW 2
#define for_each_probe_cache_entry(entry, pcache) \
@@ -54,6 +63,7 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
const char *group, const char *event);
int probe_cache__show_all_caches(struct strfilter *filter);
+bool probe_type_is_available(enum probe_type type);
#else /* ! HAVE_LIBELF_SUPPORT */
static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused)
{
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 5c290c6..24dbe23 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -39,6 +39,7 @@
#include "util.h"
#include "symbol.h"
#include "probe-finder.h"
+#include "probe-file.h"
/* Kprobe tracer basic type is up to u64 */
#define MAX_BASIC_TYPE_BITS 64
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web