Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing: Do not enable function event with enable

With the adding of function tracing event to perf, it caused a
side effect that produces the following warning when enabling all
events in ftrace:

# echo 1 > /sys/kernel/debug/tracing/events/enable

[console]
event trace: Could not enable event function

This is because when enabling all events via the debugfs system
it ignores events that do not have a ->reg() function assigned.
This was to skip over the ftrace internal events (as they are
not TRACE_EVENTs). But as the ftrace function event now has
a ->reg() function attached to it for use with perf, it is no
longer ignored.

Worse yet, this ->reg() function is being called when it should
not be. It returns an error and causes the above warning to
be printed.

By adding a new event_call flag (TRACE_EVENT_FL_IGNORE_ENABLE)
and have all ftrace internel event structures have it set,
setting the events/enable will no longe try to incorrectly enable
the function event and does not warn.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Steven Rostedt and committed by
Steven Rostedt
9b63776f 20d23aaa

+7 -1
+2
include/linux/ftrace_event.h
··· 179 179 TRACE_EVENT_FL_RECORDED_CMD_BIT, 180 180 TRACE_EVENT_FL_CAP_ANY_BIT, 181 181 TRACE_EVENT_FL_NO_SET_FILTER_BIT, 182 + TRACE_EVENT_FL_IGNORE_ENABLE_BIT, 182 183 }; 183 184 184 185 enum { ··· 188 187 TRACE_EVENT_FL_RECORDED_CMD = (1 << TRACE_EVENT_FL_RECORDED_CMD_BIT), 189 188 TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT), 190 189 TRACE_EVENT_FL_NO_SET_FILTER = (1 << TRACE_EVENT_FL_NO_SET_FILTER_BIT), 190 + TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT), 191 191 }; 192 192 193 193 struct ftrace_event_call {
+4 -1
kernel/trace/trace_events.c
··· 294 294 if (!call->name || !call->class || !call->class->reg) 295 295 continue; 296 296 297 + if (call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) 298 + continue; 299 + 297 300 if (match && 298 301 strcmp(match, call->name) != 0 && 299 302 strcmp(match, call->class->system) != 0) ··· 1167 1164 return -1; 1168 1165 } 1169 1166 1170 - if (call->class->reg) 1167 + if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) 1171 1168 trace_create_file("enable", 0644, call->dir, call, 1172 1169 enable); 1173 1170
+1
kernel/trace/trace_export.c
··· 180 180 .event.type = etype, \ 181 181 .class = &event_class_ftrace_##call, \ 182 182 .print_fmt = print, \ 183 + .flags = TRACE_EVENT_FL_IGNORE_ENABLE, \ 183 184 }; \ 184 185 struct ftrace_event_call __used \ 185 186 __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;