tracing: Add the constant count for branch tracer

The unlikely/likely branch profiler now gets called even if the if statement
is a constant (always goes in one direction without a compare). Add a value
to denote this in the likely/unlikely tracer as well.
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 134e6a03
...@@ -27,7 +27,7 @@ static DEFINE_MUTEX(branch_tracing_mutex); ...@@ -27,7 +27,7 @@ static DEFINE_MUTEX(branch_tracing_mutex);
static struct trace_array *branch_tracer; static struct trace_array *branch_tracer;
static void static void
probe_likely_condition(struct ftrace_branch_data *f, int val, int expect) probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
{ {
struct trace_event_call *call = &event_branch; struct trace_event_call *call = &event_branch;
struct trace_array *tr = branch_tracer; struct trace_array *tr = branch_tracer;
...@@ -68,16 +68,17 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect) ...@@ -68,16 +68,17 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
/* Strip off the path, only save the file */ /* Strip off the path, only save the file */
p = f->file + strlen(f->file); p = f->data.file + strlen(f->data.file);
while (p >= f->file && *p != '/') while (p >= f->data.file && *p != '/')
p--; p--;
p++; p++;
strncpy(entry->func, f->func, TRACE_FUNC_SIZE); strncpy(entry->func, f->data.func, TRACE_FUNC_SIZE);
strncpy(entry->file, p, TRACE_FILE_SIZE); strncpy(entry->file, p, TRACE_FILE_SIZE);
entry->func[TRACE_FUNC_SIZE] = 0; entry->func[TRACE_FUNC_SIZE] = 0;
entry->file[TRACE_FILE_SIZE] = 0; entry->file[TRACE_FILE_SIZE] = 0;
entry->line = f->line; entry->constant = f->constant;
entry->line = f->data.line;
entry->correct = val == expect; entry->correct = val == expect;
if (!call_filter_check_discard(call, entry, buffer, event)) if (!call_filter_check_discard(call, entry, buffer, event))
...@@ -89,7 +90,7 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect) ...@@ -89,7 +90,7 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
} }
static inline static inline
void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect) void trace_likely_condition(struct ftrace_likely_data *f, int val, int expect)
{ {
if (!branch_tracing_enabled) if (!branch_tracing_enabled)
return; return;
...@@ -195,7 +196,7 @@ core_initcall(init_branch_tracer); ...@@ -195,7 +196,7 @@ core_initcall(init_branch_tracer);
#else #else
static inline static inline
void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect) void trace_likely_condition(struct ftrace_likely_data *f, int val, int expect)
{ {
} }
#endif /* CONFIG_BRANCH_TRACER */ #endif /* CONFIG_BRANCH_TRACER */
...@@ -214,7 +215,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ...@@ -214,7 +215,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
* conditions that the recursive nightmare that exists is too * conditions that the recursive nightmare that exists is too
* much to try to get working. At least for now. * much to try to get working. At least for now.
*/ */
trace_likely_condition(&f->data, val, expect); trace_likely_condition(f, val, expect);
/* FIXME: Make this atomic! */ /* FIXME: Make this atomic! */
if (val == expect) if (val == expect)
......
...@@ -328,11 +328,13 @@ FTRACE_ENTRY(branch, trace_branch, ...@@ -328,11 +328,13 @@ FTRACE_ENTRY(branch, trace_branch,
__array( char, func, TRACE_FUNC_SIZE+1 ) __array( char, func, TRACE_FUNC_SIZE+1 )
__array( char, file, TRACE_FILE_SIZE+1 ) __array( char, file, TRACE_FILE_SIZE+1 )
__field( char, correct ) __field( char, correct )
__field( char, constant )
), ),
F_printk("%u:%s:%s (%u)", F_printk("%u:%s:%s (%u)%s",
__entry->line, __entry->line,
__entry->func, __entry->file, __entry->correct), __entry->func, __entry->file, __entry->correct,
__entry->constant ? " CONSTANT" : ""),
FILTER_OTHER FILTER_OTHER
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment