From: tip-bot for Masami Hiramatsu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, peterz@infradead.org, wangnan0@huawei.com,
mingo@kernel.org, hpa@zytor.com, mhiramat@kernel.org,
alexander.shishkin@linux.intel.com, hemant@linux.vnet.ibm.com,
rostedt@goodmis.org, naohiro.aota@hgst.com,
linux-kernel@vger.kernel.org, tglx@linutronix.de
Subject: [tip:perf/core] perf probe: Add supported for type casting by the running kernel
Date: Wed, 24 Aug 2016 02:26:20 -0700 [thread overview]
Message-ID: <tip-180b20616ce57e93eb692170c793be94c456b1e2@git.kernel.org> (raw)
In-Reply-To: <147151071172.12957.3340095690753291085.stgit@devbox>
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
next prev parent reply other threads:[~2016-08-24 9:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 8:57 [PATCH 0/6] perf/ftrace: Introduce hexadecimal type casting Masami Hiramatsu
2016-08-18 8:57 ` [PATCH 1/6] ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types Masami Hiramatsu
2016-08-18 15:38 ` Steven Rostedt
2016-08-24 9:25 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 8:58 ` [PATCH 2/6] ftrace: probe: Add README entries for k/uprobe-events Masami Hiramatsu
2016-08-18 15:40 ` Steven Rostedt
2016-08-24 9:25 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 8:58 ` [PATCH 3/6] perf probe: Add supported type casting of running kernel Masami Hiramatsu
2016-08-23 19:45 ` Arnaldo Carvalho de Melo
2016-08-24 9:26 ` tip-bot for Masami Hiramatsu [this message]
2016-08-18 8:58 ` [PATCH 4/6] perf probe: Support hexadecimal casting Masami Hiramatsu
2016-08-24 9:26 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 8:59 ` [PATCH 5/6] perf-probe: Use hexadecimal type by default if possible Masami Hiramatsu
2016-08-24 9:27 ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2016-08-18 8:59 ` [PATCH 6/6] ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal Masami Hiramatsu
2016-08-18 15:41 ` Steven Rostedt
2016-08-24 9:27 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 14:14 ` [PATCH 0/6] perf/ftrace: Introduce hexadecimal type casting Arnaldo Carvalho de Melo
2016-08-18 16:01 ` Masami Hiramatsu
2016-08-18 16:13 ` Arnaldo Carvalho de Melo
2016-08-20 3:40 ` Masami Hiramatsu
2016-08-18 16:03 ` Steven Rostedt
2016-08-18 16:08 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-180b20616ce57e93eb692170c793be94c456b1e2@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=naohiro.aota@hgst.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox