diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-11-11 01:14:25 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-11 04:29:12 -0500 |
commit | 15e6cb3673ea6277999642802406a764b49391b0 (patch) | |
tree | d0a46a918caa64d5fb1ed37be3e026b30e94fe77 /kernel/trace/trace.h | |
parent | caf4b323b02a16c92fba449952ac6515ddc76d7a (diff) |
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>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 978145088fb8..e40ce0c14690 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -22,6 +22,7 @@ enum trace_type { | |||
22 | TRACE_MMIO_RW, | 22 | TRACE_MMIO_RW, |
23 | TRACE_MMIO_MAP, | 23 | TRACE_MMIO_MAP, |
24 | TRACE_BOOT, | 24 | TRACE_BOOT, |
25 | TRACE_FN_RET, | ||
25 | 26 | ||
26 | __TRACE_LAST_TYPE | 27 | __TRACE_LAST_TYPE |
27 | }; | 28 | }; |
@@ -48,6 +49,15 @@ struct ftrace_entry { | |||
48 | unsigned long ip; | 49 | unsigned long ip; |
49 | unsigned long parent_ip; | 50 | unsigned long parent_ip; |
50 | }; | 51 | }; |
52 | |||
53 | /* Function return entry */ | ||
54 | struct ftrace_ret_entry { | ||
55 | struct trace_entry ent; | ||
56 | unsigned long ip; | ||
57 | unsigned long parent_ip; | ||
58 | unsigned long long calltime; | ||
59 | unsigned long long rettime; | ||
60 | }; | ||
51 | extern struct tracer boot_tracer; | 61 | extern struct tracer boot_tracer; |
52 | 62 | ||
53 | /* | 63 | /* |
@@ -218,6 +228,7 @@ extern void __ftrace_bad_type(void); | |||
218 | IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \ | 228 | IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \ |
219 | TRACE_MMIO_MAP); \ | 229 | TRACE_MMIO_MAP); \ |
220 | IF_ASSIGN(var, ent, struct trace_boot, TRACE_BOOT); \ | 230 | IF_ASSIGN(var, ent, struct trace_boot, TRACE_BOOT); \ |
231 | IF_ASSIGN(var, ent, struct ftrace_ret_entry, TRACE_FN_RET); \ | ||
221 | __ftrace_bad_type(); \ | 232 | __ftrace_bad_type(); \ |
222 | } while (0) | 233 | } while (0) |
223 | 234 | ||
@@ -321,6 +332,8 @@ void trace_function(struct trace_array *tr, | |||
321 | unsigned long ip, | 332 | unsigned long ip, |
322 | unsigned long parent_ip, | 333 | unsigned long parent_ip, |
323 | unsigned long flags, int pc); | 334 | unsigned long flags, int pc); |
335 | void | ||
336 | trace_function_return(struct ftrace_retfunc *trace); | ||
324 | 337 | ||
325 | void tracing_start_cmdline_record(void); | 338 | void tracing_start_cmdline_record(void); |
326 | void tracing_stop_cmdline_record(void); | 339 | void tracing_stop_cmdline_record(void); |
@@ -393,6 +406,10 @@ extern void *head_page(struct trace_array_cpu *data); | |||
393 | extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); | 406 | extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); |
394 | extern void trace_seq_print_cont(struct trace_seq *s, | 407 | extern void trace_seq_print_cont(struct trace_seq *s, |
395 | struct trace_iterator *iter); | 408 | struct trace_iterator *iter); |
409 | |||
410 | extern int | ||
411 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, | ||
412 | unsigned long sym_flags); | ||
396 | extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, | 413 | extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, |
397 | size_t cnt); | 414 | size_t cnt); |
398 | extern long ns2usecs(cycle_t nsec); | 415 | extern long ns2usecs(cycle_t nsec); |
@@ -400,6 +417,17 @@ extern int trace_vprintk(unsigned long ip, const char *fmt, va_list args); | |||
400 | 417 | ||
401 | extern unsigned long trace_flags; | 418 | extern unsigned long trace_flags; |
402 | 419 | ||
420 | /* Standard output formatting function used for function return traces */ | ||
421 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
422 | extern enum print_line_t print_return_function(struct trace_iterator *iter); | ||
423 | #else | ||
424 | static inline enum print_line_t | ||
425 | print_return_function(struct trace_iterator *iter) | ||
426 | { | ||
427 | return TRACE_TYPE_UNHANDLED; | ||
428 | } | ||
429 | #endif | ||
430 | |||
403 | /* | 431 | /* |
404 | * trace_iterator_flags is an enumeration that defines bit | 432 | * trace_iterator_flags is an enumeration that defines bit |
405 | * positions into trace_flags that controls the output. | 433 | * positions into trace_flags that controls the output. |
@@ -422,6 +450,13 @@ enum trace_iterator_flags { | |||
422 | TRACE_ITER_PREEMPTONLY = 0x800, | 450 | TRACE_ITER_PREEMPTONLY = 0x800, |
423 | }; | 451 | }; |
424 | 452 | ||
453 | /* | ||
454 | * TRACE_ITER_SYM_MASK masks the options in trace_flags that | ||
455 | * control the output of kernel symbols. | ||
456 | */ | ||
457 | #define TRACE_ITER_SYM_MASK \ | ||
458 | (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR) | ||
459 | |||
425 | extern struct tracer nop_trace; | 460 | extern struct tracer nop_trace; |
426 | 461 | ||
427 | /** | 462 | /** |