From: "tip-bot for Naveen N. Rao" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: naveen.n.rao@linux.vnet.ibm.com, mhiramat@kernel.org,
mpe@ellerman.id.au, acme@redhat.com, ananth@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org, mingo@kernel.org,
rostedt@goodmis.org, hpa@zytor.com, tglx@linutronix.de
Subject: [tip:perf/core] perf probe: Factor out the ftrace README scanning
Date: Wed, 15 Mar 2017 11:42:31 -0700 [thread overview]
Message-ID: <tip-3da3ea7a8e205edc24b9491a459b46527c70b5b1@git.kernel.org> (raw)
In-Reply-To: <6dc30edc747ba82a236593be6cf3a046fa9453b5.1488961018.git.naveen.n.rao@linux.vnet.ibm.com>
Commit-ID: 3da3ea7a8e205edc24b9491a459b46527c70b5b1
Gitweb: http://git.kernel.org/tip/3da3ea7a8e205edc24b9491a459b46527c70b5b1
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Wed, 8 Mar 2017 13:56:08 +0530
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 14 Mar 2017 15:17:38 -0300
perf probe: Factor out the ftrace README scanning
Simplify and separate out the ftrace README scanning logic into a
separate helper. This is used subsequently to scan for all patterns of
interest and to cache the result.
Since we are only interested in availability of probe argument type x,
we will only scan for that.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/6dc30edc747ba82a236593be6cf3a046fa9453b5.1488961018.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-file.c | 70 +++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 33 deletions(-)
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 1a62dac..8a219cd 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -877,35 +877,31 @@ int probe_cache__show_all_caches(struct strfilter *filter)
return 0;
}
+enum ftrace_readme {
+ FTRACE_README_PROBE_TYPE_X = 0,
+ FTRACE_README_END,
+};
+
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 avail;
+} ftrace_readme_table[] = {
+#define DEFINE_TYPE(idx, pat) \
+ [idx] = {.pattern = pat, .avail = false}
+ DEFINE_TYPE(FTRACE_README_PROBE_TYPE_X, "*type: * x8/16/32/64,*"),
};
-bool probe_type_is_available(enum probe_type type)
+static bool scan_ftrace_readme(enum ftrace_readme type)
{
+ int fd;
FILE *fp;
char *buf = NULL;
size_t len = 0;
- bool target_line = false;
- bool ret = probe_type_table[type].avail;
- int fd;
+ bool ret = false;
+ static bool scanned = false;
- 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 (scanned)
+ goto result;
fd = open_trace_file("README", false);
if (fd < 0)
@@ -917,21 +913,29 @@ bool probe_type_is_available(enum probe_type type)
return ret;
}
- 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;
+ while (getline(&buf, &len, fp) > 0)
+ for (enum ftrace_readme i = 0; i < FTRACE_README_END; i++)
+ if (!ftrace_readme_table[i].avail)
+ ftrace_readme_table[i].avail =
+ strglobmatch(buf, ftrace_readme_table[i].pattern);
+ scanned = true;
fclose(fp);
free(buf);
- return ret;
+result:
+ if (type >= FTRACE_README_END)
+ return false;
+
+ return ftrace_readme_table[type].avail;
+}
+
+bool probe_type_is_available(enum probe_type type)
+{
+ if (type >= PROBE_TYPE_END)
+ return false;
+ else if (type == PROBE_TYPE_X)
+ return scan_ftrace_readme(FTRACE_README_PROBE_TYPE_X);
+
+ return true;
}
next prev parent reply other threads:[~2017-03-15 18:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 8:26 [PATCH v5 0/5] kretprobe fixes Naveen N. Rao
2017-03-08 8:26 ` [PATCH v5 1/5] trace/kprobes: fix check for kretprobe offset within function entry Naveen N. Rao
2017-03-16 16:34 ` [tip:perf/core] trace/kprobes: Fix " tip-bot for Naveen N. Rao
2017-03-08 8:26 ` [PATCH v5 2/5] powerpc: kretprobes: override default function entry offset Naveen N. Rao
2017-03-08 10:43 ` Michael Ellerman
2017-03-08 14:24 ` Naveen N. Rao
2017-03-08 14:29 ` Arnaldo Carvalho de Melo
2017-03-08 16:46 ` Naveen N. Rao
2017-03-09 6:37 ` Michael Ellerman
2017-03-09 8:03 ` Naveen N. Rao
2017-03-14 13:18 ` Arnaldo Carvalho de Melo
2017-03-15 9:15 ` Naveen N. Rao
2017-04-24 22:47 ` [v5,2/5] " Michael Ellerman
2017-03-08 8:26 ` [PATCH v5 3/5] perf: probe: factor out the ftrace README scanning Naveen N. Rao
2017-03-15 18:42 ` tip-bot for Naveen N. Rao [this message]
2017-03-08 8:26 ` [PATCH v5 4/5] perf: kretprobes: offset from reloc_sym if kernel supports it Naveen N. Rao
2017-03-15 18:43 ` [tip:perf/core] perf kretprobes: Offset " tip-bot for Naveen N. Rao
2017-03-08 8:26 ` [PATCH v5 5/5] perf: powerpc: choose local entry point with kretprobes Naveen N. Rao
2017-03-08 10:31 ` Masami Hiramatsu
2017-03-08 11:39 ` Naveen N. Rao
2017-03-15 18:43 ` [tip:perf/core] perf powerpc: Choose " tip-bot for Naveen N. Rao
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-3da3ea7a8e205edc24b9491a459b46527c70b5b1@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ananth@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=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome