From: Qais Yousef <Qais.Yousef@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: [RFC][PATCH] Export supported trace features in debugfs
Date: Tue, 12 Mar 2019 11:07:14 +0000 [thread overview]
Message-ID: <20190312110437.5977-1-qais.yousef@arm.com> (raw)
eBPF tools like bcc-tools have hard time figuring out when features like
raw_tracepoint are supported in the kernel on which we are running. At
the moment a fragile mechanism of matching bpf_find_raw_tracepoint()
function in /proc/kallsyms is used to find out whether raw tracepoints
can be used or not. But when this function was renamed recently to
bpf_get_raw_tracepoint() the tool started to fail to use raw
tracepoints.
To help in providing a more reliable way to detect features like
RAW_TRACEPOINT, add a new file in trace debugfs to export the supported
features.
$cat /sys/kernel/debug/tracing/supported_features
RAW_TRACEPOINT
EXAMPLE_FEATURE_1
EXAMPLE_FEATURE_2
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
---
This is a half baked patch to probe the potential of this solution.
The breakage mentioned in the commit message is here:
https://github.com/iovisor/bcc/pull/2241/commits/0f5849187972a50adf0d9eaa8788c11f9fd926ea
I am not sure what else beside raw_tracepoint makes sense to expose right now.
kernel/trace/trace.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c4238b441624..daae09238e62 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6670,6 +6670,28 @@ static const struct file_operations snapshot_raw_fops = {
#endif /* CONFIG_TRACER_SNAPSHOT */
+#define TRACE_FEATURE(feat)__stringify(feat) "\n"
+
+#define TRACE_FEATURES\
+TRACE_FEATURE(RAW_TRACEPOINT)\
+TRACE_FEATURE(EXAMPLE_FEATUTE_1)\
+TRACE_FEATURE(EXAMPLE_FEATUTE_2)
+
+static ssize_t
+tracing_read_trace_features(struct file *filp, char __user *ubuf,
+size_t cnt, loff_t *ppos)
+{
+char *buf = TRACE_FEATURES;
+size_t len = sizeof(TRACE_FEATURES);
+
+return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+}
+
+static const struct file_operations show_trace_features_fops = {
+.read = tracing_read_trace_features,
+.llseek = no_llseek,
+};
+
static int tracing_buffers_open(struct inode *inode, struct file *filp)
{
struct trace_array *tr = inode->i_private;
@@ -8242,6 +8264,9 @@ static __init int tracer_init_tracefs(void)
&ftrace_update_tot_cnt, &tracing_dyn_info_fops);
#endif
+trace_create_file("trace_features", 0444, d_tracer,
+NULL, &show_trace_features_fops);
+
create_trace_instances(d_tracer);
update_tracer_options(&global_trace);
--
2.17.1
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
next reply other threads:[~2019-03-12 11:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-12 11:07 Qais Yousef [this message]
2019-03-12 11:13 ` [RFC][PATCH] Export supported trace features in debugfs Qais Yousef
2019-03-12 15:27 ` Alexei Starovoitov
2019-03-12 16:19 ` Qais Yousef
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=20190312110437.5977-1-qais.yousef@arm.com \
--to=qais.yousef@arm.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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