2020-05-16 16:13:22

by Changbin Du

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

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 <[email protected]>
---
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


2020-05-16 17:17:25

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tracing: do not create option file latency-format

On Sun, 17 May 2020 00:10:17 +0800
Changbin Du <[email protected]> wrote:

> 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 <[email protected]>
> ---

Sorry, I actually do sometimes use that option for things other than
latency tracers. So NACK.

-- Steve

2020-05-17 09:40:28

by Changbin Du

[permalink] [raw]
Subject: Re: [PATCH] tracing: do not create option file latency-format

Hi Steven,

On Sat, May 16, 2020 at 01:15:21PM -0400, Steven Rostedt wrote:
> On Sun, 17 May 2020 00:10:17 +0800
> Changbin Du <[email protected]> wrote:
>
> > 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 <[email protected]>
> > ---
>
> Sorry, I actually do sometimes use that option for things other than
> latency tracers. So NACK.
>
May I know which tracer use this option as well? As far as I know,
besides latency tracers, the fgraph tracer also uses it.

I think 'irq-info' and 'latency-format' is somewhat overlaps. So
my thought is:
1) function and function graph tracers should use irq-info.
2) latency tracers should set latency-format.

I am not quite sure whether this is a good idea. :)

> -- Steve

--
Cheers,
Changbin Du