-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing: add a tracer to catch execution time of kernel functions
Impact: add new tracing plugin which can trace full (entry+exit) function calls This tracer uses the low level function return ftrace plugin to measure the execution time of the kernel functions. The first field is the caller of the function, the second is the measured function, and the last one is the execution time in nanoseconds. - v3: - HAVE_FUNCTION_RET_TRACER have been added. Each arch that support ftrace return should enable it. - ftrace_return_stub becomes ftrace_stub. - CONFIG_FUNCTION_RET_TRACER depends now on CONFIG_FUNCTION_TRACER - Return traces printing can be used for other tracers on trace.c - Adapt to the new tracing API (no more ctrl_update callback) - Correct the check of "disabled" during insertion. - Minor changes... Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
- Loading branch information
Frederic Weisbecker
authored and
Ingo Molnar
committed
Nov 11, 2008
1 parent
caf4b32
commit 15e6cb3
Showing
6 changed files
with
205 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* | ||
* Function return tracer. | ||
* Copyright (c) 2008 Frederic Weisbecker <fweisbec@gmail.com> | ||
* Mostly borrowed from function tracer which | ||
* is Copyright (c) Steven Rostedt <srostedt@redhat.com> | ||
* | ||
*/ | ||
#include <linux/debugfs.h> | ||
#include <linux/uaccess.h> | ||
#include <linux/ftrace.h> | ||
#include <linux/fs.h> | ||
|
||
#include "trace.h" | ||
|
||
|
||
static void start_return_trace(struct trace_array *tr) | ||
{ | ||
register_ftrace_return(&trace_function_return); | ||
} | ||
|
||
static void stop_return_trace(struct trace_array *tr) | ||
{ | ||
unregister_ftrace_return(); | ||
} | ||
|
||
static void return_trace_init(struct trace_array *tr) | ||
{ | ||
int cpu; | ||
for_each_online_cpu(cpu) | ||
tracing_reset(tr, cpu); | ||
|
||
start_return_trace(tr); | ||
} | ||
|
||
static void return_trace_reset(struct trace_array *tr) | ||
{ | ||
stop_return_trace(tr); | ||
} | ||
|
||
|
||
enum print_line_t | ||
print_return_function(struct trace_iterator *iter) | ||
{ | ||
struct trace_seq *s = &iter->seq; | ||
struct trace_entry *entry = iter->ent; | ||
struct ftrace_ret_entry *field; | ||
int ret; | ||
|
||
if (entry->type == TRACE_FN_RET) { | ||
trace_assign_type(field, entry); | ||
ret = trace_seq_printf(s, "%pF -> ", (void *)field->parent_ip); | ||
if (!ret) | ||
return TRACE_TYPE_PARTIAL_LINE; | ||
ret = seq_print_ip_sym(s, field->ip, | ||
trace_flags & TRACE_ITER_SYM_MASK); | ||
if (!ret) | ||
return TRACE_TYPE_PARTIAL_LINE; | ||
ret = trace_seq_printf(s, " (%llu ns)\n", | ||
field->rettime - field->calltime); | ||
if (!ret) | ||
return TRACE_TYPE_PARTIAL_LINE; | ||
else | ||
return TRACE_TYPE_HANDLED; | ||
} | ||
return TRACE_TYPE_UNHANDLED; | ||
} | ||
|
||
static struct tracer return_trace __read_mostly = | ||
{ | ||
.name = "return", | ||
.init = return_trace_init, | ||
.reset = return_trace_reset, | ||
.print_line = print_return_function | ||
}; | ||
|
||
static __init int init_return_trace(void) | ||
{ | ||
return register_tracer(&return_trace); | ||
} | ||
|
||
device_initcall(init_return_trace); |