[GIT PULL] tracing: Fix showing function event in available_events

From: Steven Rostedt
Date: Thu Feb 25 2016 - 09:45:09 EST



Linus,

Another small bug reported to me by Chunyu Hu.

When perf added a "reg" function to the function tracing event (not a
tracepoint), it caused that event to be displayed as a tracepoint and
could cause errors in tracepoint handling. That was solved by adding a
flag to ignore ftrace non-tracepoint events. But that flag was missed
when displaying events in available_events, which should only contain
tracepoint events.

This broke a documented way to enable all events with:

cat available_events > set_event

As the function non-tracepoint event would cause that to error out.
The commit here fixes that by having the available_events file not list
events that have the ignore flag set.


Please pull the latest trace-fixes-v4.5-rc5-2 tree, which can be found at:


git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-fixes-v4.5-rc5-2

Tag SHA1: ddf22628d221550da62d6969b24d6b9d197bf66f
Head SHA1: d045437a169f899dfb0f6f7ede24cc042543ced9


Steven Rostedt (Red Hat) (1):
tracing: Fix showing function event in available_events

----
kernel/trace/trace_events.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---------------------------
commit d045437a169f899dfb0f6f7ede24cc042543ced9
Author: Steven Rostedt (Red Hat) <rostedt@xxxxxxxxxxx>
Date: Wed Feb 24 09:04:24 2016 -0500

tracing: Fix showing function event in available_events

The ftrace:function event is only displayed for parsing the function tracer
data. It is not used to enable function tracing, and does not include an
"enable" file in its event directory.

Originally, this event was kept separate from other events because it did
not have a ->reg parameter. But perf added a "reg" parameter for its use
which caused issues, because it made the event available to functions where
it was not compatible for.

Commit 9b63776fa3ca9 "tracing: Do not enable function event with enable"
added a TRACE_EVENT_FL_IGNORE_ENABLE flag that prevented the function event
from being enabled by normal trace events. But this commit missed keeping
the function event from being displayed by the "available_events" directory,
which is used to show what events can be enabled by set_event.

One documented way to enable all events is to:

cat available_events > set_event

But because the function event is displayed in the available_events, this
now causes an INVALID error:

cat: write error: Invalid argument

Reported-by: Chunyu Hu <chuhu@xxxxxxxxxx>
Fixes: 9b63776fa3ca9 "tracing: Do not enable function event with enable"
Cc: stable@xxxxxxxxxxxxxxx # 3.4+
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index f333e57c4614..ab09829d3b97 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -869,7 +869,8 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
* The ftrace subsystem is for showing formats only.
* They can not be enabled or disabled via the event files.
*/
- if (call->class && call->class->reg)
+ if (call->class && call->class->reg &&
+ !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE))
return file;
}