[PATCH] tracing: do not create option file latency-format

From: Changbin Du
Date: Sat May 16 2020 - 12:12:35 EST


The flag LATENCY_FMT actually is usually set by latency tracers internally.
So I think we should not export it to userspace. This patch removes the
option file 'latency-format' but keep the flag defined as usual.

Signed-off-by: Changbin Du <changbin.du@xxxxxxxxx>
---
kernel/trace/trace.c | 4 ++++
kernel/trace/trace.h | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 29615f15a820..0d190e0021d5 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4733,6 +4733,8 @@ static int tracing_trace_options_show(struct seq_file *m, void *v)
trace_opts = tr->current_trace->flags->opts;

for (i = 0; trace_options[i]; i++) {
+ if (strlen(trace_options[i]) == 0)
+ continue;
if (tr->trace_flags & (1 << i))
seq_printf(m, "%s\n", trace_options[i]);
else
@@ -8359,6 +8361,8 @@ static void create_trace_options_dir(struct trace_array *tr)
return;

for (i = 0; trace_options[i]; i++) {
+ if (strlen(trace_options[i]) == 0)
+ continue;
if (top_level ||
!((1 << i) & TOP_LEVEL_TRACE_FLAGS))
create_trace_option_core_file(tr, trace_options[i], i);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 4eb1d004d5f2..6d9f0bba09c3 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1264,6 +1264,8 @@ extern void trace_parser_put(struct trace_parser *parser);
extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
size_t cnt, loff_t *ppos);

+#define TRACE_OPTION_HIDE_NAME ""
+
/*
* Only create function graph options if function graph is configured.
*/
@@ -1321,7 +1323,7 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
C(SYM_USEROBJ, "sym-userobj"), \
C(PRINTK_MSGONLY, "printk-msg-only"), \
C(CONTEXT_INFO, "context-info"), /* Print pid/cpu/time */ \
- C(LATENCY_FMT, "latency-format"), \
+ C(LATENCY_FMT, TRACE_OPTION_HIDE_NAME),\
C(RECORD_CMD, "record-cmd"), \
C(RECORD_TGID, "record-tgid"), \
C(OVERWRITE, "overwrite"), \
--
2.25.1