Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Function graph tracer. |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 4 | * Copyright (c) 2008-2009 Frederic Weisbecker <fweisbec@gmail.com> |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 5 | * Mostly borrowed from function tracer which |
| 6 | * is Copyright (c) Steven Rostedt <srostedt@redhat.com> |
| 7 | * |
| 8 | */ |
| 9 | #include <linux/debugfs.h> |
| 10 | #include <linux/uaccess.h> |
| 11 | #include <linux/ftrace.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 13 | #include <linux/fs.h> |
| 14 | |
| 15 | #include "trace.h" |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 16 | #include "trace_output.h" |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 17 | |
Steven Rostedt | b304d04 | 2010-09-14 18:58:33 -0400 | [diff] [blame] | 18 | /* When set, irq functions will be ignored */ |
| 19 | static int ftrace_graph_skip_irqs; |
| 20 | |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 21 | struct fgraph_cpu_data { |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 22 | pid_t last_pid; |
| 23 | int depth; |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 24 | int depth_irq; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 25 | int ignore; |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 26 | unsigned long enter_funcs[FTRACE_RETFUNC_DEPTH]; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | struct fgraph_data { |
Namhyung Kim | 6016ee1 | 2010-08-11 12:47:59 +0900 | [diff] [blame] | 30 | struct fgraph_cpu_data __percpu *cpu_data; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 31 | |
| 32 | /* Place to preserve last processed entry. */ |
| 33 | struct ftrace_graph_ent_entry ent; |
| 34 | struct ftrace_graph_ret_entry ret; |
| 35 | int failed; |
| 36 | int cpu; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 37 | }; |
| 38 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 39 | #define TRACE_GRAPH_INDENT 2 |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 40 | |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 41 | /* Flag options */ |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 42 | #define TRACE_GRAPH_PRINT_OVERRUN 0x1 |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 43 | #define TRACE_GRAPH_PRINT_CPU 0x2 |
| 44 | #define TRACE_GRAPH_PRINT_OVERHEAD 0x4 |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 45 | #define TRACE_GRAPH_PRINT_PROC 0x8 |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 46 | #define TRACE_GRAPH_PRINT_DURATION 0x10 |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 47 | #define TRACE_GRAPH_PRINT_ABS_TIME 0x20 |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 48 | #define TRACE_GRAPH_PRINT_IRQS 0x40 |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 49 | |
Steven Rostedt | 8741db5 | 2013-01-16 10:49:37 -0500 | [diff] [blame] | 50 | static unsigned int max_depth; |
| 51 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 52 | static struct tracer_opt trace_opts[] = { |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 53 | /* Display overruns? (for self-debug purpose) */ |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 54 | { TRACER_OPT(funcgraph-overrun, TRACE_GRAPH_PRINT_OVERRUN) }, |
| 55 | /* Display CPU ? */ |
| 56 | { TRACER_OPT(funcgraph-cpu, TRACE_GRAPH_PRINT_CPU) }, |
| 57 | /* Display Overhead ? */ |
| 58 | { TRACER_OPT(funcgraph-overhead, TRACE_GRAPH_PRINT_OVERHEAD) }, |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 59 | /* Display proc name/pid */ |
| 60 | { TRACER_OPT(funcgraph-proc, TRACE_GRAPH_PRINT_PROC) }, |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 61 | /* Display duration of execution */ |
| 62 | { TRACER_OPT(funcgraph-duration, TRACE_GRAPH_PRINT_DURATION) }, |
| 63 | /* Display absolute time of an entry */ |
| 64 | { TRACER_OPT(funcgraph-abstime, TRACE_GRAPH_PRINT_ABS_TIME) }, |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 65 | /* Display interrupts */ |
| 66 | { TRACER_OPT(funcgraph-irqs, TRACE_GRAPH_PRINT_IRQS) }, |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 67 | { } /* Empty entry */ |
| 68 | }; |
| 69 | |
| 70 | static struct tracer_flags tracer_flags = { |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 71 | /* Don't display overruns and proc by default */ |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 72 | .val = TRACE_GRAPH_PRINT_CPU | TRACE_GRAPH_PRINT_OVERHEAD | |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 73 | TRACE_GRAPH_PRINT_DURATION | TRACE_GRAPH_PRINT_IRQS, |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 74 | .opts = trace_opts |
| 75 | }; |
| 76 | |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 77 | static struct trace_array *graph_array; |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 78 | |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 79 | /* |
| 80 | * DURATION column is being also used to display IRQ signs, |
| 81 | * following values are used by print_graph_irq and others |
| 82 | * to fill in space into DURATION column. |
| 83 | */ |
| 84 | enum { |
| 85 | DURATION_FILL_FULL = -1, |
| 86 | DURATION_FILL_START = -2, |
| 87 | DURATION_FILL_END = -3, |
| 88 | }; |
| 89 | |
| 90 | static enum print_line_t |
| 91 | print_graph_duration(unsigned long long duration, struct trace_seq *s, |
| 92 | u32 flags); |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 93 | |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 94 | /* Add a function return address to the trace stack on thread info.*/ |
| 95 | int |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 96 | ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth, |
| 97 | unsigned long frame_pointer) |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 98 | { |
Steven Rostedt | 5d1a03d | 2009-03-23 23:38:49 -0400 | [diff] [blame] | 99 | unsigned long long calltime; |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 100 | int index; |
| 101 | |
| 102 | if (!current->ret_stack) |
| 103 | return -EBUSY; |
| 104 | |
Steven Rostedt | 82310a3 | 2009-06-02 12:26:07 -0400 | [diff] [blame] | 105 | /* |
| 106 | * We must make sure the ret_stack is tested before we read |
| 107 | * anything else. |
| 108 | */ |
| 109 | smp_rmb(); |
| 110 | |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 111 | /* The return trace stack is full */ |
| 112 | if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) { |
| 113 | atomic_inc(¤t->trace_overrun); |
| 114 | return -EBUSY; |
| 115 | } |
| 116 | |
Steven Rostedt | 5d1a03d | 2009-03-23 23:38:49 -0400 | [diff] [blame] | 117 | calltime = trace_clock_local(); |
| 118 | |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 119 | index = ++current->curr_ret_stack; |
| 120 | barrier(); |
| 121 | current->ret_stack[index].ret = ret; |
| 122 | current->ret_stack[index].func = func; |
Steven Rostedt | 5d1a03d | 2009-03-23 23:38:49 -0400 | [diff] [blame] | 123 | current->ret_stack[index].calltime = calltime; |
Steven Rostedt | a2a16d6 | 2009-03-24 23:17:58 -0400 | [diff] [blame] | 124 | current->ret_stack[index].subtime = 0; |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 125 | current->ret_stack[index].fp = frame_pointer; |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 126 | *depth = index; |
| 127 | |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | /* Retrieve a function return address to the trace stack on thread info.*/ |
Steven Rostedt | a2a16d6 | 2009-03-24 23:17:58 -0400 | [diff] [blame] | 132 | static void |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 133 | ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret, |
| 134 | unsigned long frame_pointer) |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 135 | { |
| 136 | int index; |
| 137 | |
| 138 | index = current->curr_ret_stack; |
| 139 | |
| 140 | if (unlikely(index < 0)) { |
| 141 | ftrace_graph_stop(); |
| 142 | WARN_ON(1); |
| 143 | /* Might as well panic, otherwise we have no where to go */ |
| 144 | *ret = (unsigned long)panic; |
| 145 | return; |
| 146 | } |
| 147 | |
Steven Rostedt | 781d062 | 2011-02-09 13:27:22 -0500 | [diff] [blame] | 148 | #if defined(CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST) && !defined(CC_USING_FENTRY) |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 149 | /* |
| 150 | * The arch may choose to record the frame pointer used |
| 151 | * and check it here to make sure that it is what we expect it |
| 152 | * to be. If gcc does not set the place holder of the return |
| 153 | * address in the frame pointer, and does a copy instead, then |
| 154 | * the function graph trace will fail. This test detects this |
| 155 | * case. |
| 156 | * |
| 157 | * Currently, x86_32 with optimize for size (-Os) makes the latest |
| 158 | * gcc do the above. |
Steven Rostedt | 781d062 | 2011-02-09 13:27:22 -0500 | [diff] [blame] | 159 | * |
| 160 | * Note, -mfentry does not use frame pointers, and this test |
| 161 | * is not needed if CC_USING_FENTRY is set. |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 162 | */ |
| 163 | if (unlikely(current->ret_stack[index].fp != frame_pointer)) { |
| 164 | ftrace_graph_stop(); |
| 165 | WARN(1, "Bad frame pointer: expected %lx, received %lx\n" |
Steven Rostedt | b375a11 | 2009-09-17 00:05:58 -0400 | [diff] [blame] | 166 | " from func %ps return to %lx\n", |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 167 | current->ret_stack[index].fp, |
| 168 | frame_pointer, |
| 169 | (void *)current->ret_stack[index].func, |
| 170 | current->ret_stack[index].ret); |
| 171 | *ret = (unsigned long)panic; |
| 172 | return; |
| 173 | } |
| 174 | #endif |
| 175 | |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 176 | *ret = current->ret_stack[index].ret; |
| 177 | trace->func = current->ret_stack[index].func; |
| 178 | trace->calltime = current->ret_stack[index].calltime; |
| 179 | trace->overrun = atomic_read(¤t->trace_overrun); |
| 180 | trace->depth = index; |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /* |
| 184 | * Send the trace to the ring-buffer. |
| 185 | * @return the original return address. |
| 186 | */ |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 187 | unsigned long ftrace_return_to_handler(unsigned long frame_pointer) |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 188 | { |
| 189 | struct ftrace_graph_ret trace; |
| 190 | unsigned long ret; |
| 191 | |
Steven Rostedt | 71e308a | 2009-06-18 12:45:08 -0400 | [diff] [blame] | 192 | ftrace_pop_return_trace(&trace, &ret, frame_pointer); |
Frederic Weisbecker | 0012693 | 2009-03-05 01:49:22 +0100 | [diff] [blame] | 193 | trace.rettime = trace_clock_local(); |
Steven Rostedt | a2a16d6 | 2009-03-24 23:17:58 -0400 | [diff] [blame] | 194 | barrier(); |
| 195 | current->curr_ret_stack--; |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 196 | |
Steven Rostedt (Red Hat) | 03274a3 | 2013-01-29 17:30:31 -0500 | [diff] [blame] | 197 | /* |
| 198 | * The trace should run after decrementing the ret counter |
| 199 | * in case an interrupt were to come in. We don't want to |
| 200 | * lose the interrupt if max_depth is set. |
| 201 | */ |
| 202 | ftrace_graph_return(&trace); |
| 203 | |
Steven Rostedt | 712406a | 2009-02-09 10:54:03 -0800 | [diff] [blame] | 204 | if (unlikely(!ret)) { |
| 205 | ftrace_graph_stop(); |
| 206 | WARN_ON(1); |
| 207 | /* Might as well panic. What else to do? */ |
| 208 | ret = (unsigned long)panic; |
| 209 | } |
| 210 | |
| 211 | return ret; |
| 212 | } |
| 213 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 214 | int __trace_graph_entry(struct trace_array *tr, |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 215 | struct ftrace_graph_ent *trace, |
| 216 | unsigned long flags, |
| 217 | int pc) |
| 218 | { |
| 219 | struct ftrace_event_call *call = &event_funcgraph_entry; |
| 220 | struct ring_buffer_event *event; |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 221 | struct ring_buffer *buffer = tr->buffer; |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 222 | struct ftrace_graph_ent_entry *entry; |
| 223 | |
Rusty Russell | dd17c8f | 2009-10-29 22:34:15 +0900 | [diff] [blame] | 224 | if (unlikely(__this_cpu_read(ftrace_cpu_disabled))) |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 225 | return 0; |
| 226 | |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 227 | event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT, |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 228 | sizeof(*entry), flags, pc); |
| 229 | if (!event) |
| 230 | return 0; |
| 231 | entry = ring_buffer_event_data(event); |
| 232 | entry->graph_ent = *trace; |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 233 | if (!filter_current_check_discard(buffer, call, entry, event)) |
Steven Rostedt | 7ffbd48 | 2012-10-11 12:14:25 -0400 | [diff] [blame] | 234 | __buffer_unlock_commit(buffer, event); |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 235 | |
| 236 | return 1; |
| 237 | } |
| 238 | |
Steven Rostedt | b304d04 | 2010-09-14 18:58:33 -0400 | [diff] [blame] | 239 | static inline int ftrace_graph_ignore_irqs(void) |
| 240 | { |
Steven Rostedt | e4a3f54 | 2011-06-14 19:02:29 -0400 | [diff] [blame] | 241 | if (!ftrace_graph_skip_irqs || trace_recursion_test(TRACE_IRQ_BIT)) |
Steven Rostedt | b304d04 | 2010-09-14 18:58:33 -0400 | [diff] [blame] | 242 | return 0; |
| 243 | |
| 244 | return in_irq(); |
| 245 | } |
| 246 | |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 247 | int trace_graph_entry(struct ftrace_graph_ent *trace) |
| 248 | { |
| 249 | struct trace_array *tr = graph_array; |
| 250 | struct trace_array_cpu *data; |
| 251 | unsigned long flags; |
| 252 | long disabled; |
| 253 | int ret; |
| 254 | int cpu; |
| 255 | int pc; |
| 256 | |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 257 | if (!ftrace_trace_task(current)) |
| 258 | return 0; |
| 259 | |
Lai Jiangshan | ea2c68a | 2010-01-13 19:38:30 +0800 | [diff] [blame] | 260 | /* trace it when it is-nested-in or is a function enabled. */ |
Steven Rostedt | 8741db5 | 2013-01-16 10:49:37 -0500 | [diff] [blame] | 261 | if ((!(trace->depth || ftrace_graph_addr(trace->func)) || |
| 262 | ftrace_graph_ignore_irqs()) || |
| 263 | (max_depth && trace->depth >= max_depth)) |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 264 | return 0; |
| 265 | |
| 266 | local_irq_save(flags); |
| 267 | cpu = raw_smp_processor_id(); |
| 268 | data = tr->data[cpu]; |
| 269 | disabled = atomic_inc_return(&data->disabled); |
| 270 | if (likely(disabled == 1)) { |
| 271 | pc = preempt_count(); |
| 272 | ret = __trace_graph_entry(tr, trace, flags, pc); |
| 273 | } else { |
| 274 | ret = 0; |
| 275 | } |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 276 | |
| 277 | atomic_dec(&data->disabled); |
| 278 | local_irq_restore(flags); |
| 279 | |
| 280 | return ret; |
| 281 | } |
| 282 | |
Tim Bird | 0e95017 | 2010-02-25 15:36:43 -0800 | [diff] [blame] | 283 | int trace_graph_thresh_entry(struct ftrace_graph_ent *trace) |
| 284 | { |
| 285 | if (tracing_thresh) |
| 286 | return 1; |
| 287 | else |
| 288 | return trace_graph_entry(trace); |
| 289 | } |
| 290 | |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 291 | static void |
| 292 | __trace_graph_function(struct trace_array *tr, |
| 293 | unsigned long ip, unsigned long flags, int pc) |
| 294 | { |
| 295 | u64 time = trace_clock_local(); |
| 296 | struct ftrace_graph_ent ent = { |
| 297 | .func = ip, |
| 298 | .depth = 0, |
| 299 | }; |
| 300 | struct ftrace_graph_ret ret = { |
| 301 | .func = ip, |
| 302 | .depth = 0, |
| 303 | .calltime = time, |
| 304 | .rettime = time, |
| 305 | }; |
| 306 | |
| 307 | __trace_graph_entry(tr, &ent, flags, pc); |
| 308 | __trace_graph_return(tr, &ret, flags, pc); |
| 309 | } |
| 310 | |
| 311 | void |
| 312 | trace_graph_function(struct trace_array *tr, |
| 313 | unsigned long ip, unsigned long parent_ip, |
| 314 | unsigned long flags, int pc) |
| 315 | { |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 316 | __trace_graph_function(tr, ip, flags, pc); |
| 317 | } |
| 318 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 319 | void __trace_graph_return(struct trace_array *tr, |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 320 | struct ftrace_graph_ret *trace, |
| 321 | unsigned long flags, |
| 322 | int pc) |
| 323 | { |
| 324 | struct ftrace_event_call *call = &event_funcgraph_exit; |
| 325 | struct ring_buffer_event *event; |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 326 | struct ring_buffer *buffer = tr->buffer; |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 327 | struct ftrace_graph_ret_entry *entry; |
| 328 | |
Rusty Russell | dd17c8f | 2009-10-29 22:34:15 +0900 | [diff] [blame] | 329 | if (unlikely(__this_cpu_read(ftrace_cpu_disabled))) |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 330 | return; |
| 331 | |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 332 | event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET, |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 333 | sizeof(*entry), flags, pc); |
| 334 | if (!event) |
| 335 | return; |
| 336 | entry = ring_buffer_event_data(event); |
| 337 | entry->ret = *trace; |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 338 | if (!filter_current_check_discard(buffer, call, entry, event)) |
Steven Rostedt | 7ffbd48 | 2012-10-11 12:14:25 -0400 | [diff] [blame] | 339 | __buffer_unlock_commit(buffer, event); |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | void trace_graph_return(struct ftrace_graph_ret *trace) |
| 343 | { |
| 344 | struct trace_array *tr = graph_array; |
| 345 | struct trace_array_cpu *data; |
| 346 | unsigned long flags; |
| 347 | long disabled; |
| 348 | int cpu; |
| 349 | int pc; |
| 350 | |
| 351 | local_irq_save(flags); |
| 352 | cpu = raw_smp_processor_id(); |
| 353 | data = tr->data[cpu]; |
| 354 | disabled = atomic_inc_return(&data->disabled); |
| 355 | if (likely(disabled == 1)) { |
| 356 | pc = preempt_count(); |
| 357 | __trace_graph_return(tr, trace, flags, pc); |
| 358 | } |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 359 | atomic_dec(&data->disabled); |
| 360 | local_irq_restore(flags); |
| 361 | } |
| 362 | |
Frederic Weisbecker | 24a5365 | 2010-01-14 08:23:15 +0100 | [diff] [blame] | 363 | void set_graph_array(struct trace_array *tr) |
| 364 | { |
| 365 | graph_array = tr; |
| 366 | |
| 367 | /* Make graph_array visible before we start tracing */ |
| 368 | |
| 369 | smp_mb(); |
| 370 | } |
| 371 | |
Tim Bird | 0e95017 | 2010-02-25 15:36:43 -0800 | [diff] [blame] | 372 | void trace_graph_thresh_return(struct ftrace_graph_ret *trace) |
| 373 | { |
| 374 | if (tracing_thresh && |
| 375 | (trace->rettime - trace->calltime < tracing_thresh)) |
| 376 | return; |
| 377 | else |
| 378 | trace_graph_return(trace); |
| 379 | } |
| 380 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 381 | static int graph_trace_init(struct trace_array *tr) |
| 382 | { |
Frederic Weisbecker | 1a0799a | 2009-07-29 18:59:58 +0200 | [diff] [blame] | 383 | int ret; |
| 384 | |
Frederic Weisbecker | 24a5365 | 2010-01-14 08:23:15 +0100 | [diff] [blame] | 385 | set_graph_array(tr); |
Tim Bird | 0e95017 | 2010-02-25 15:36:43 -0800 | [diff] [blame] | 386 | if (tracing_thresh) |
| 387 | ret = register_ftrace_graph(&trace_graph_thresh_return, |
| 388 | &trace_graph_thresh_entry); |
| 389 | else |
| 390 | ret = register_ftrace_graph(&trace_graph_return, |
| 391 | &trace_graph_entry); |
Steven Rostedt | 660c7f9 | 2008-11-26 00:16:26 -0500 | [diff] [blame] | 392 | if (ret) |
| 393 | return ret; |
| 394 | tracing_start_cmdline_record(); |
| 395 | |
| 396 | return 0; |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | static void graph_trace_reset(struct trace_array *tr) |
| 400 | { |
Steven Rostedt | 660c7f9 | 2008-11-26 00:16:26 -0500 | [diff] [blame] | 401 | tracing_stop_cmdline_record(); |
| 402 | unregister_ftrace_graph(); |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 403 | } |
| 404 | |
Lai Jiangshan | 0c9e6f6 | 2009-07-28 20:26:06 +0800 | [diff] [blame] | 405 | static int max_bytes_for_cpu; |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 406 | |
| 407 | static enum print_line_t |
| 408 | print_graph_cpu(struct trace_seq *s, int cpu) |
| 409 | { |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 410 | int ret; |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 411 | |
Ingo Molnar | d51090b | 2008-11-28 09:55:16 +0100 | [diff] [blame] | 412 | /* |
| 413 | * Start with a space character - to make it stand out |
| 414 | * to the right a bit when trace output is pasted into |
| 415 | * email: |
| 416 | */ |
Lai Jiangshan | 0c9e6f6 | 2009-07-28 20:26:06 +0800 | [diff] [blame] | 417 | ret = trace_seq_printf(s, " %*d) ", max_bytes_for_cpu, cpu); |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 418 | if (!ret) |
Ingo Molnar | d51090b | 2008-11-28 09:55:16 +0100 | [diff] [blame] | 419 | return TRACE_TYPE_PARTIAL_LINE; |
| 420 | |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 421 | return TRACE_TYPE_HANDLED; |
| 422 | } |
| 423 | |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 424 | #define TRACE_GRAPH_PROCINFO_LENGTH 14 |
| 425 | |
| 426 | static enum print_line_t |
| 427 | print_graph_proc(struct trace_seq *s, pid_t pid) |
| 428 | { |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 429 | char comm[TASK_COMM_LEN]; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 430 | /* sign + log10(MAX_INT) + '\0' */ |
| 431 | char pid_str[11]; |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 432 | int spaces = 0; |
| 433 | int ret; |
| 434 | int len; |
| 435 | int i; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 436 | |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 437 | trace_find_cmdline(pid, comm); |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 438 | comm[7] = '\0'; |
| 439 | sprintf(pid_str, "%d", pid); |
| 440 | |
| 441 | /* 1 stands for the "-" character */ |
| 442 | len = strlen(comm) + strlen(pid_str) + 1; |
| 443 | |
| 444 | if (len < TRACE_GRAPH_PROCINFO_LENGTH) |
| 445 | spaces = TRACE_GRAPH_PROCINFO_LENGTH - len; |
| 446 | |
| 447 | /* First spaces to align center */ |
| 448 | for (i = 0; i < spaces / 2; i++) { |
| 449 | ret = trace_seq_printf(s, " "); |
| 450 | if (!ret) |
| 451 | return TRACE_TYPE_PARTIAL_LINE; |
| 452 | } |
| 453 | |
| 454 | ret = trace_seq_printf(s, "%s-%s", comm, pid_str); |
| 455 | if (!ret) |
| 456 | return TRACE_TYPE_PARTIAL_LINE; |
| 457 | |
| 458 | /* Last spaces to align center */ |
| 459 | for (i = 0; i < spaces - (spaces / 2); i++) { |
| 460 | ret = trace_seq_printf(s, " "); |
| 461 | if (!ret) |
| 462 | return TRACE_TYPE_PARTIAL_LINE; |
| 463 | } |
| 464 | return TRACE_TYPE_HANDLED; |
| 465 | } |
| 466 | |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 467 | |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 468 | static enum print_line_t |
| 469 | print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry) |
| 470 | { |
Steven Rostedt | f81c972 | 2009-09-11 14:24:13 -0400 | [diff] [blame] | 471 | if (!trace_seq_putc(s, ' ')) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 472 | return 0; |
| 473 | |
Steven Rostedt | f81c972 | 2009-09-11 14:24:13 -0400 | [diff] [blame] | 474 | return trace_print_lat_fmt(s, entry); |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 475 | } |
| 476 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 477 | /* If the pid changed since the last trace, output this event */ |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 478 | static enum print_line_t |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 479 | verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data) |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 480 | { |
Ingo Molnar | d51090b | 2008-11-28 09:55:16 +0100 | [diff] [blame] | 481 | pid_t prev_pid; |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 482 | pid_t *last_pid; |
Ingo Molnar | d51090b | 2008-11-28 09:55:16 +0100 | [diff] [blame] | 483 | int ret; |
Steven Rostedt | 660c7f9 | 2008-11-26 00:16:26 -0500 | [diff] [blame] | 484 | |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 485 | if (!data) |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 486 | return TRACE_TYPE_HANDLED; |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 487 | |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 488 | last_pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid); |
Steven Rostedt | 660c7f9 | 2008-11-26 00:16:26 -0500 | [diff] [blame] | 489 | |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 490 | if (*last_pid == pid) |
| 491 | return TRACE_TYPE_HANDLED; |
| 492 | |
| 493 | prev_pid = *last_pid; |
| 494 | *last_pid = pid; |
| 495 | |
| 496 | if (prev_pid == -1) |
| 497 | return TRACE_TYPE_HANDLED; |
Ingo Molnar | d51090b | 2008-11-28 09:55:16 +0100 | [diff] [blame] | 498 | /* |
| 499 | * Context-switch trace line: |
| 500 | |
| 501 | ------------------------------------------ |
| 502 | | 1) migration/0--1 => sshd-1755 |
| 503 | ------------------------------------------ |
| 504 | |
| 505 | */ |
| 506 | ret = trace_seq_printf(s, |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 507 | " ------------------------------------------\n"); |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 508 | if (!ret) |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 509 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 510 | |
| 511 | ret = print_graph_cpu(s, cpu); |
| 512 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 513 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 514 | |
| 515 | ret = print_graph_proc(s, prev_pid); |
| 516 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 517 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 518 | |
| 519 | ret = trace_seq_printf(s, " => "); |
| 520 | if (!ret) |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 521 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 522 | |
| 523 | ret = print_graph_proc(s, pid); |
| 524 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 525 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 526 | |
| 527 | ret = trace_seq_printf(s, |
| 528 | "\n ------------------------------------------\n\n"); |
| 529 | if (!ret) |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 530 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 531 | |
Wenji Huang | 810dc73 | 2009-02-10 01:03:05 -0500 | [diff] [blame] | 532 | return TRACE_TYPE_HANDLED; |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 533 | } |
| 534 | |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 535 | static struct ftrace_graph_ret_entry * |
| 536 | get_return_for_leaf(struct trace_iterator *iter, |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 537 | struct ftrace_graph_ent_entry *curr) |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 538 | { |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 539 | struct fgraph_data *data = iter->private; |
| 540 | struct ring_buffer_iter *ring_iter = NULL; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 541 | struct ring_buffer_event *event; |
| 542 | struct ftrace_graph_ret_entry *next; |
| 543 | |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 544 | /* |
| 545 | * If the previous output failed to write to the seq buffer, |
| 546 | * then we just reuse the data from before. |
| 547 | */ |
| 548 | if (data && data->failed) { |
| 549 | curr = &data->ent; |
| 550 | next = &data->ret; |
| 551 | } else { |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 552 | |
Steven Rostedt | 6d158a8 | 2012-06-27 20:46:14 -0400 | [diff] [blame] | 553 | ring_iter = trace_buffer_iter(iter, iter->cpu); |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 554 | |
| 555 | /* First peek to compare current entry and the next one */ |
| 556 | if (ring_iter) |
| 557 | event = ring_buffer_iter_peek(ring_iter, NULL); |
| 558 | else { |
| 559 | /* |
| 560 | * We need to consume the current entry to see |
| 561 | * the next one. |
| 562 | */ |
Steven Rostedt | 66a8cb9 | 2010-03-31 13:21:56 -0400 | [diff] [blame] | 563 | ring_buffer_consume(iter->tr->buffer, iter->cpu, |
| 564 | NULL, NULL); |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 565 | event = ring_buffer_peek(iter->tr->buffer, iter->cpu, |
Steven Rostedt | 66a8cb9 | 2010-03-31 13:21:56 -0400 | [diff] [blame] | 566 | NULL, NULL); |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | if (!event) |
| 570 | return NULL; |
| 571 | |
| 572 | next = ring_buffer_event_data(event); |
| 573 | |
| 574 | if (data) { |
| 575 | /* |
| 576 | * Save current and next entries for later reference |
| 577 | * if the output fails. |
| 578 | */ |
| 579 | data->ent = *curr; |
Shaohua Li | 575570f | 2010-07-27 16:06:34 +0800 | [diff] [blame] | 580 | /* |
| 581 | * If the next event is not a return type, then |
| 582 | * we only care about what type it is. Otherwise we can |
| 583 | * safely copy the entire event. |
| 584 | */ |
| 585 | if (next->ent.type == TRACE_GRAPH_RET) |
| 586 | data->ret = *next; |
| 587 | else |
| 588 | data->ret.ent.type = next->ent.type; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 589 | } |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 590 | } |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 591 | |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 592 | if (next->ent.type != TRACE_GRAPH_RET) |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 593 | return NULL; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 594 | |
| 595 | if (curr->ent.pid != next->ent.pid || |
| 596 | curr->graph_ent.func != next->ret.func) |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 597 | return NULL; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 598 | |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 599 | /* this is a leaf, now advance the iterator */ |
| 600 | if (ring_iter) |
| 601 | ring_buffer_read(ring_iter, NULL); |
| 602 | |
| 603 | return next; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 604 | } |
| 605 | |
Frederic Weisbecker | d1f9cbd | 2009-02-18 04:25:25 +0100 | [diff] [blame] | 606 | static int print_graph_abs_time(u64 t, struct trace_seq *s) |
| 607 | { |
| 608 | unsigned long usecs_rem; |
| 609 | |
| 610 | usecs_rem = do_div(t, NSEC_PER_SEC); |
| 611 | usecs_rem /= 1000; |
| 612 | |
| 613 | return trace_seq_printf(s, "%5lu.%06lu | ", |
| 614 | (unsigned long)t, usecs_rem); |
| 615 | } |
| 616 | |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 617 | static enum print_line_t |
Frederic Weisbecker | d1f9cbd | 2009-02-18 04:25:25 +0100 | [diff] [blame] | 618 | print_graph_irq(struct trace_iterator *iter, unsigned long addr, |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 619 | enum trace_type type, int cpu, pid_t pid, u32 flags) |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 620 | { |
| 621 | int ret; |
Frederic Weisbecker | d1f9cbd | 2009-02-18 04:25:25 +0100 | [diff] [blame] | 622 | struct trace_seq *s = &iter->seq; |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 623 | |
| 624 | if (addr < (unsigned long)__irqentry_text_start || |
| 625 | addr >= (unsigned long)__irqentry_text_end) |
| 626 | return TRACE_TYPE_UNHANDLED; |
| 627 | |
Jiri Olsa | 749230b | 2011-06-03 16:58:51 +0200 | [diff] [blame] | 628 | if (trace_flags & TRACE_ITER_CONTEXT_INFO) { |
| 629 | /* Absolute time */ |
| 630 | if (flags & TRACE_GRAPH_PRINT_ABS_TIME) { |
| 631 | ret = print_graph_abs_time(iter->ts, s); |
| 632 | if (!ret) |
| 633 | return TRACE_TYPE_PARTIAL_LINE; |
| 634 | } |
Frederic Weisbecker | d1f9cbd | 2009-02-18 04:25:25 +0100 | [diff] [blame] | 635 | |
Jiri Olsa | 749230b | 2011-06-03 16:58:51 +0200 | [diff] [blame] | 636 | /* Cpu */ |
| 637 | if (flags & TRACE_GRAPH_PRINT_CPU) { |
| 638 | ret = print_graph_cpu(s, cpu); |
| 639 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 640 | return TRACE_TYPE_PARTIAL_LINE; |
| 641 | } |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 642 | |
Jiri Olsa | 749230b | 2011-06-03 16:58:51 +0200 | [diff] [blame] | 643 | /* Proc */ |
| 644 | if (flags & TRACE_GRAPH_PRINT_PROC) { |
| 645 | ret = print_graph_proc(s, pid); |
| 646 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 647 | return TRACE_TYPE_PARTIAL_LINE; |
| 648 | ret = trace_seq_printf(s, " | "); |
| 649 | if (!ret) |
| 650 | return TRACE_TYPE_PARTIAL_LINE; |
| 651 | } |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | /* No overhead */ |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 655 | ret = print_graph_duration(DURATION_FILL_START, s, flags); |
| 656 | if (ret != TRACE_TYPE_HANDLED) |
| 657 | return ret; |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 658 | |
| 659 | if (type == TRACE_GRAPH_ENT) |
| 660 | ret = trace_seq_printf(s, "==========>"); |
| 661 | else |
| 662 | ret = trace_seq_printf(s, "<=========="); |
| 663 | |
| 664 | if (!ret) |
| 665 | return TRACE_TYPE_PARTIAL_LINE; |
| 666 | |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 667 | ret = print_graph_duration(DURATION_FILL_END, s, flags); |
| 668 | if (ret != TRACE_TYPE_HANDLED) |
| 669 | return ret; |
| 670 | |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 671 | ret = trace_seq_printf(s, "\n"); |
| 672 | |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 673 | if (!ret) |
| 674 | return TRACE_TYPE_PARTIAL_LINE; |
| 675 | return TRACE_TYPE_HANDLED; |
| 676 | } |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 677 | |
Steven Rostedt | 0706f1c | 2009-03-23 23:12:58 -0400 | [diff] [blame] | 678 | enum print_line_t |
| 679 | trace_print_graph_duration(unsigned long long duration, struct trace_seq *s) |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 680 | { |
| 681 | unsigned long nsecs_rem = do_div(duration, 1000); |
Frederic Weisbecker | 166d3c7 | 2008-12-03 02:32:12 +0100 | [diff] [blame] | 682 | /* log10(ULONG_MAX) + '\0' */ |
| 683 | char msecs_str[21]; |
| 684 | char nsecs_str[5]; |
| 685 | int ret, len; |
| 686 | int i; |
| 687 | |
| 688 | sprintf(msecs_str, "%lu", (unsigned long) duration); |
| 689 | |
| 690 | /* Print msecs */ |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 691 | ret = trace_seq_printf(s, "%s", msecs_str); |
Frederic Weisbecker | 166d3c7 | 2008-12-03 02:32:12 +0100 | [diff] [blame] | 692 | if (!ret) |
| 693 | return TRACE_TYPE_PARTIAL_LINE; |
| 694 | |
| 695 | len = strlen(msecs_str); |
| 696 | |
| 697 | /* Print nsecs (we don't want to exceed 7 numbers) */ |
| 698 | if (len < 7) { |
Borislav Petkov | 14cae9b | 2010-09-29 10:08:23 +0200 | [diff] [blame] | 699 | size_t slen = min_t(size_t, sizeof(nsecs_str), 8UL - len); |
| 700 | |
| 701 | snprintf(nsecs_str, slen, "%03lu", nsecs_rem); |
Frederic Weisbecker | 166d3c7 | 2008-12-03 02:32:12 +0100 | [diff] [blame] | 702 | ret = trace_seq_printf(s, ".%s", nsecs_str); |
| 703 | if (!ret) |
| 704 | return TRACE_TYPE_PARTIAL_LINE; |
| 705 | len += strlen(nsecs_str); |
| 706 | } |
| 707 | |
| 708 | ret = trace_seq_printf(s, " us "); |
| 709 | if (!ret) |
| 710 | return TRACE_TYPE_PARTIAL_LINE; |
| 711 | |
| 712 | /* Print remaining spaces to fit the row's width */ |
| 713 | for (i = len; i < 7; i++) { |
| 714 | ret = trace_seq_printf(s, " "); |
| 715 | if (!ret) |
| 716 | return TRACE_TYPE_PARTIAL_LINE; |
| 717 | } |
Steven Rostedt | 0706f1c | 2009-03-23 23:12:58 -0400 | [diff] [blame] | 718 | return TRACE_TYPE_HANDLED; |
| 719 | } |
| 720 | |
| 721 | static enum print_line_t |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 722 | print_graph_duration(unsigned long long duration, struct trace_seq *s, |
| 723 | u32 flags) |
Steven Rostedt | 0706f1c | 2009-03-23 23:12:58 -0400 | [diff] [blame] | 724 | { |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 725 | int ret = -1; |
| 726 | |
Jiri Olsa | 749230b | 2011-06-03 16:58:51 +0200 | [diff] [blame] | 727 | if (!(flags & TRACE_GRAPH_PRINT_DURATION) || |
| 728 | !(trace_flags & TRACE_ITER_CONTEXT_INFO)) |
| 729 | return TRACE_TYPE_HANDLED; |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 730 | |
| 731 | /* No real adata, just filling the column with spaces */ |
| 732 | switch (duration) { |
| 733 | case DURATION_FILL_FULL: |
| 734 | ret = trace_seq_printf(s, " | "); |
| 735 | return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; |
| 736 | case DURATION_FILL_START: |
| 737 | ret = trace_seq_printf(s, " "); |
| 738 | return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; |
| 739 | case DURATION_FILL_END: |
| 740 | ret = trace_seq_printf(s, " |"); |
| 741 | return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; |
| 742 | } |
| 743 | |
| 744 | /* Signal a overhead of time execution to the output */ |
| 745 | if (flags & TRACE_GRAPH_PRINT_OVERHEAD) { |
| 746 | /* Duration exceeded 100 msecs */ |
| 747 | if (duration > 100000ULL) |
| 748 | ret = trace_seq_printf(s, "! "); |
| 749 | /* Duration exceeded 10 msecs */ |
| 750 | else if (duration > 10000ULL) |
| 751 | ret = trace_seq_printf(s, "+ "); |
| 752 | } |
| 753 | |
| 754 | /* |
| 755 | * The -1 means we either did not exceed the duration tresholds |
| 756 | * or we dont want to print out the overhead. Either way we need |
| 757 | * to fill out the space. |
| 758 | */ |
| 759 | if (ret == -1) |
| 760 | ret = trace_seq_printf(s, " "); |
| 761 | |
| 762 | /* Catching here any failure happenned above */ |
| 763 | if (!ret) |
| 764 | return TRACE_TYPE_PARTIAL_LINE; |
Steven Rostedt | 0706f1c | 2009-03-23 23:12:58 -0400 | [diff] [blame] | 765 | |
| 766 | ret = trace_print_graph_duration(duration, s); |
| 767 | if (ret != TRACE_TYPE_HANDLED) |
| 768 | return ret; |
Frederic Weisbecker | 166d3c7 | 2008-12-03 02:32:12 +0100 | [diff] [blame] | 769 | |
| 770 | ret = trace_seq_printf(s, "| "); |
| 771 | if (!ret) |
| 772 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 166d3c7 | 2008-12-03 02:32:12 +0100 | [diff] [blame] | 773 | |
Steven Rostedt | 0706f1c | 2009-03-23 23:12:58 -0400 | [diff] [blame] | 774 | return TRACE_TYPE_HANDLED; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 775 | } |
| 776 | |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 777 | /* Case of a leaf function on its call entry */ |
| 778 | static enum print_line_t |
| 779 | print_graph_entry_leaf(struct trace_iterator *iter, |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 780 | struct ftrace_graph_ent_entry *entry, |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 781 | struct ftrace_graph_ret_entry *ret_entry, |
| 782 | struct trace_seq *s, u32 flags) |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 783 | { |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 784 | struct fgraph_data *data = iter->private; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 785 | struct ftrace_graph_ret *graph_ret; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 786 | struct ftrace_graph_ent *call; |
| 787 | unsigned long long duration; |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 788 | int ret; |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 789 | int i; |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 790 | |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 791 | graph_ret = &ret_entry->ret; |
| 792 | call = &entry->graph_ent; |
| 793 | duration = graph_ret->rettime - graph_ret->calltime; |
Steven Rostedt | 437f24fb | 2008-11-26 00:16:27 -0500 | [diff] [blame] | 794 | |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 795 | if (data) { |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 796 | struct fgraph_cpu_data *cpu_data; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 797 | int cpu = iter->cpu; |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 798 | |
| 799 | cpu_data = per_cpu_ptr(data->cpu_data, cpu); |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 800 | |
| 801 | /* |
| 802 | * Comments display at + 1 to depth. Since |
| 803 | * this is a leaf function, keep the comments |
| 804 | * equal to this depth. |
| 805 | */ |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 806 | cpu_data->depth = call->depth - 1; |
| 807 | |
| 808 | /* No need to keep this function around for this depth */ |
| 809 | if (call->depth < FTRACE_RETFUNC_DEPTH) |
| 810 | cpu_data->enter_funcs[call->depth] = 0; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 811 | } |
| 812 | |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 813 | /* Overhead and duration */ |
| 814 | ret = print_graph_duration(duration, s, flags); |
| 815 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 816 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 817 | |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 818 | /* Function */ |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 819 | for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { |
| 820 | ret = trace_seq_printf(s, " "); |
| 821 | if (!ret) |
| 822 | return TRACE_TYPE_PARTIAL_LINE; |
| 823 | } |
| 824 | |
Steven Rostedt | b375a11 | 2009-09-17 00:05:58 -0400 | [diff] [blame] | 825 | ret = trace_seq_printf(s, "%ps();\n", (void *)call->func); |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 826 | if (!ret) |
| 827 | return TRACE_TYPE_PARTIAL_LINE; |
| 828 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 829 | return TRACE_TYPE_HANDLED; |
| 830 | } |
| 831 | |
| 832 | static enum print_line_t |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 833 | print_graph_entry_nested(struct trace_iterator *iter, |
| 834 | struct ftrace_graph_ent_entry *entry, |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 835 | struct trace_seq *s, int cpu, u32 flags) |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 836 | { |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 837 | struct ftrace_graph_ent *call = &entry->graph_ent; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 838 | struct fgraph_data *data = iter->private; |
| 839 | int ret; |
| 840 | int i; |
| 841 | |
| 842 | if (data) { |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 843 | struct fgraph_cpu_data *cpu_data; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 844 | int cpu = iter->cpu; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 845 | |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 846 | cpu_data = per_cpu_ptr(data->cpu_data, cpu); |
| 847 | cpu_data->depth = call->depth; |
| 848 | |
| 849 | /* Save this function pointer to see if the exit matches */ |
| 850 | if (call->depth < FTRACE_RETFUNC_DEPTH) |
| 851 | cpu_data->enter_funcs[call->depth] = call->func; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 852 | } |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 853 | |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 854 | /* No time */ |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 855 | ret = print_graph_duration(DURATION_FILL_FULL, s, flags); |
| 856 | if (ret != TRACE_TYPE_HANDLED) |
| 857 | return ret; |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 858 | |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 859 | /* Function */ |
| 860 | for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { |
| 861 | ret = trace_seq_printf(s, " "); |
| 862 | if (!ret) |
| 863 | return TRACE_TYPE_PARTIAL_LINE; |
| 864 | } |
| 865 | |
Steven Rostedt | b375a11 | 2009-09-17 00:05:58 -0400 | [diff] [blame] | 866 | ret = trace_seq_printf(s, "%ps() {\n", (void *)call->func); |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 867 | if (!ret) |
| 868 | return TRACE_TYPE_PARTIAL_LINE; |
| 869 | |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 870 | /* |
| 871 | * we already consumed the current entry to check the next one |
| 872 | * and see if this is a leaf. |
| 873 | */ |
| 874 | return TRACE_TYPE_NO_CONSUME; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | static enum print_line_t |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 878 | print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s, |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 879 | int type, unsigned long addr, u32 flags) |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 880 | { |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 881 | struct fgraph_data *data = iter->private; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 882 | struct trace_entry *ent = iter->ent; |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 883 | int cpu = iter->cpu; |
| 884 | int ret; |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 885 | |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 886 | /* Pid */ |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 887 | if (verif_pid(s, ent->pid, cpu, data) == TRACE_TYPE_PARTIAL_LINE) |
Steven Rostedt | 437f24fb | 2008-11-26 00:16:27 -0500 | [diff] [blame] | 888 | return TRACE_TYPE_PARTIAL_LINE; |
| 889 | |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 890 | if (type) { |
| 891 | /* Interrupt */ |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 892 | ret = print_graph_irq(iter, addr, type, cpu, ent->pid, flags); |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 893 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 894 | return TRACE_TYPE_PARTIAL_LINE; |
| 895 | } |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 896 | |
Jiri Olsa | 749230b | 2011-06-03 16:58:51 +0200 | [diff] [blame] | 897 | if (!(trace_flags & TRACE_ITER_CONTEXT_INFO)) |
| 898 | return 0; |
| 899 | |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 900 | /* Absolute time */ |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 901 | if (flags & TRACE_GRAPH_PRINT_ABS_TIME) { |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 902 | ret = print_graph_abs_time(iter->ts, s); |
| 903 | if (!ret) |
| 904 | return TRACE_TYPE_PARTIAL_LINE; |
| 905 | } |
| 906 | |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 907 | /* Cpu */ |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 908 | if (flags & TRACE_GRAPH_PRINT_CPU) { |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 909 | ret = print_graph_cpu(s, cpu); |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 910 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 911 | return TRACE_TYPE_PARTIAL_LINE; |
| 912 | } |
| 913 | |
| 914 | /* Proc */ |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 915 | if (flags & TRACE_GRAPH_PRINT_PROC) { |
Ingo Molnar | 00a8bf8 | 2009-02-19 13:01:37 +0100 | [diff] [blame] | 916 | ret = print_graph_proc(s, ent->pid); |
Frederic Weisbecker | 11e84ac | 2008-12-03 02:30:37 +0100 | [diff] [blame] | 917 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 918 | return TRACE_TYPE_PARTIAL_LINE; |
| 919 | |
| 920 | ret = trace_seq_printf(s, " | "); |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 921 | if (!ret) |
| 922 | return TRACE_TYPE_PARTIAL_LINE; |
| 923 | } |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 924 | |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 925 | /* Latency format */ |
| 926 | if (trace_flags & TRACE_ITER_LATENCY_FMT) { |
| 927 | ret = print_graph_lat_fmt(s, ent); |
| 928 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 929 | return TRACE_TYPE_PARTIAL_LINE; |
| 930 | } |
| 931 | |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 932 | return 0; |
| 933 | } |
| 934 | |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 935 | /* |
| 936 | * Entry check for irq code |
| 937 | * |
| 938 | * returns 1 if |
| 939 | * - we are inside irq code |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 940 | * - we just entered irq code |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 941 | * |
| 942 | * retunns 0 if |
| 943 | * - funcgraph-interrupts option is set |
| 944 | * - we are not inside irq code |
| 945 | */ |
| 946 | static int |
| 947 | check_irq_entry(struct trace_iterator *iter, u32 flags, |
| 948 | unsigned long addr, int depth) |
| 949 | { |
| 950 | int cpu = iter->cpu; |
Jiri Olsa | a9d6117 | 2010-09-24 17:41:02 +0200 | [diff] [blame] | 951 | int *depth_irq; |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 952 | struct fgraph_data *data = iter->private; |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 953 | |
Jiri Olsa | a9d6117 | 2010-09-24 17:41:02 +0200 | [diff] [blame] | 954 | /* |
| 955 | * If we are either displaying irqs, or we got called as |
| 956 | * a graph event and private data does not exist, |
| 957 | * then we bypass the irq check. |
| 958 | */ |
| 959 | if ((flags & TRACE_GRAPH_PRINT_IRQS) || |
| 960 | (!data)) |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 961 | return 0; |
| 962 | |
Jiri Olsa | a9d6117 | 2010-09-24 17:41:02 +0200 | [diff] [blame] | 963 | depth_irq = &(per_cpu_ptr(data->cpu_data, cpu)->depth_irq); |
| 964 | |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 965 | /* |
| 966 | * We are inside the irq code |
| 967 | */ |
| 968 | if (*depth_irq >= 0) |
| 969 | return 1; |
| 970 | |
| 971 | if ((addr < (unsigned long)__irqentry_text_start) || |
| 972 | (addr >= (unsigned long)__irqentry_text_end)) |
| 973 | return 0; |
| 974 | |
| 975 | /* |
| 976 | * We are entering irq code. |
| 977 | */ |
| 978 | *depth_irq = depth; |
| 979 | return 1; |
| 980 | } |
| 981 | |
| 982 | /* |
| 983 | * Return check for irq code |
| 984 | * |
| 985 | * returns 1 if |
| 986 | * - we are inside irq code |
| 987 | * - we just left irq code |
| 988 | * |
| 989 | * returns 0 if |
| 990 | * - funcgraph-interrupts option is set |
| 991 | * - we are not inside irq code |
| 992 | */ |
| 993 | static int |
| 994 | check_irq_return(struct trace_iterator *iter, u32 flags, int depth) |
| 995 | { |
| 996 | int cpu = iter->cpu; |
Jiri Olsa | a9d6117 | 2010-09-24 17:41:02 +0200 | [diff] [blame] | 997 | int *depth_irq; |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 998 | struct fgraph_data *data = iter->private; |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 999 | |
Jiri Olsa | a9d6117 | 2010-09-24 17:41:02 +0200 | [diff] [blame] | 1000 | /* |
| 1001 | * If we are either displaying irqs, or we got called as |
| 1002 | * a graph event and private data does not exist, |
| 1003 | * then we bypass the irq check. |
| 1004 | */ |
| 1005 | if ((flags & TRACE_GRAPH_PRINT_IRQS) || |
| 1006 | (!data)) |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 1007 | return 0; |
| 1008 | |
Jiri Olsa | a9d6117 | 2010-09-24 17:41:02 +0200 | [diff] [blame] | 1009 | depth_irq = &(per_cpu_ptr(data->cpu_data, cpu)->depth_irq); |
| 1010 | |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 1011 | /* |
| 1012 | * We are not inside the irq code. |
| 1013 | */ |
| 1014 | if (*depth_irq == -1) |
| 1015 | return 0; |
| 1016 | |
| 1017 | /* |
| 1018 | * We are inside the irq code, and this is returning entry. |
| 1019 | * Let's not trace it and clear the entry depth, since |
| 1020 | * we are out of irq code. |
| 1021 | * |
| 1022 | * This condition ensures that we 'leave the irq code' once |
| 1023 | * we are out of the entry depth. Thus protecting us from |
| 1024 | * the RETURN entry loss. |
| 1025 | */ |
| 1026 | if (*depth_irq >= depth) { |
| 1027 | *depth_irq = -1; |
| 1028 | return 1; |
| 1029 | } |
| 1030 | |
| 1031 | /* |
| 1032 | * We are inside the irq code, and this is not the entry. |
| 1033 | */ |
| 1034 | return 1; |
| 1035 | } |
| 1036 | |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 1037 | static enum print_line_t |
| 1038 | print_graph_entry(struct ftrace_graph_ent_entry *field, struct trace_seq *s, |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1039 | struct trace_iterator *iter, u32 flags) |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 1040 | { |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1041 | struct fgraph_data *data = iter->private; |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 1042 | struct ftrace_graph_ent *call = &field->graph_ent; |
| 1043 | struct ftrace_graph_ret_entry *leaf_ret; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1044 | static enum print_line_t ret; |
| 1045 | int cpu = iter->cpu; |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 1046 | |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 1047 | if (check_irq_entry(iter, flags, call->func, call->depth)) |
| 1048 | return TRACE_TYPE_HANDLED; |
| 1049 | |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1050 | if (print_graph_prologue(iter, s, TRACE_GRAPH_ENT, call->func, flags)) |
Steven Rostedt | ac5f6c9 | 2009-03-19 11:29:23 -0400 | [diff] [blame] | 1051 | return TRACE_TYPE_PARTIAL_LINE; |
| 1052 | |
Frederic Weisbecker | b91facc | 2009-02-06 18:30:44 +0100 | [diff] [blame] | 1053 | leaf_ret = get_return_for_leaf(iter, field); |
| 1054 | if (leaf_ret) |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1055 | ret = print_graph_entry_leaf(iter, field, leaf_ret, s, flags); |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1056 | else |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1057 | ret = print_graph_entry_nested(iter, field, s, cpu, flags); |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1058 | |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1059 | if (data) { |
| 1060 | /* |
| 1061 | * If we failed to write our output, then we need to make |
| 1062 | * note of it. Because we already consumed our entry. |
| 1063 | */ |
| 1064 | if (s->full) { |
| 1065 | data->failed = 1; |
| 1066 | data->cpu = cpu; |
| 1067 | } else |
| 1068 | data->failed = 0; |
| 1069 | } |
| 1070 | |
| 1071 | return ret; |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | static enum print_line_t |
| 1075 | print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1076 | struct trace_entry *ent, struct trace_iterator *iter, |
| 1077 | u32 flags) |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1078 | { |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1079 | unsigned long long duration = trace->rettime - trace->calltime; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1080 | struct fgraph_data *data = iter->private; |
| 1081 | pid_t pid = ent->pid; |
| 1082 | int cpu = iter->cpu; |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 1083 | int func_match = 1; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1084 | int ret; |
| 1085 | int i; |
| 1086 | |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 1087 | if (check_irq_return(iter, flags, trace->depth)) |
| 1088 | return TRACE_TYPE_HANDLED; |
| 1089 | |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1090 | if (data) { |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 1091 | struct fgraph_cpu_data *cpu_data; |
| 1092 | int cpu = iter->cpu; |
| 1093 | |
| 1094 | cpu_data = per_cpu_ptr(data->cpu_data, cpu); |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1095 | |
| 1096 | /* |
| 1097 | * Comments display at + 1 to depth. This is the |
| 1098 | * return from a function, we now want the comments |
| 1099 | * to display at the same level of the bracket. |
| 1100 | */ |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 1101 | cpu_data->depth = trace->depth - 1; |
| 1102 | |
| 1103 | if (trace->depth < FTRACE_RETFUNC_DEPTH) { |
| 1104 | if (cpu_data->enter_funcs[trace->depth] != trace->func) |
| 1105 | func_match = 0; |
| 1106 | cpu_data->enter_funcs[trace->depth] = 0; |
| 1107 | } |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1108 | } |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1109 | |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1110 | if (print_graph_prologue(iter, s, 0, 0, flags)) |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1111 | return TRACE_TYPE_PARTIAL_LINE; |
| 1112 | |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 1113 | /* Overhead and duration */ |
| 1114 | ret = print_graph_duration(duration, s, flags); |
| 1115 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1116 | return TRACE_TYPE_PARTIAL_LINE; |
Frederic Weisbecker | 1a05615 | 2008-11-28 00:42:46 +0100 | [diff] [blame] | 1117 | |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1118 | /* Closing brace */ |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1119 | for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) { |
| 1120 | ret = trace_seq_printf(s, " "); |
| 1121 | if (!ret) |
| 1122 | return TRACE_TYPE_PARTIAL_LINE; |
| 1123 | } |
| 1124 | |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 1125 | /* |
| 1126 | * If the return function does not have a matching entry, |
| 1127 | * then the entry was lost. Instead of just printing |
| 1128 | * the '}' and letting the user guess what function this |
| 1129 | * belongs to, write out the function name. |
| 1130 | */ |
| 1131 | if (func_match) { |
| 1132 | ret = trace_seq_printf(s, "}\n"); |
| 1133 | if (!ret) |
| 1134 | return TRACE_TYPE_PARTIAL_LINE; |
| 1135 | } else { |
Steven Rostedt | a094fe0 | 2010-03-05 20:08:58 -0500 | [diff] [blame] | 1136 | ret = trace_seq_printf(s, "} /* %ps */\n", (void *)trace->func); |
Steven Rostedt | f1c7f51 | 2010-02-26 17:08:16 -0500 | [diff] [blame] | 1137 | if (!ret) |
| 1138 | return TRACE_TYPE_PARTIAL_LINE; |
| 1139 | } |
Frederic Weisbecker | 83a8df6 | 2008-11-27 01:46:33 +0100 | [diff] [blame] | 1140 | |
| 1141 | /* Overrun */ |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1142 | if (flags & TRACE_GRAPH_PRINT_OVERRUN) { |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1143 | ret = trace_seq_printf(s, " (Overruns: %lu)\n", |
| 1144 | trace->overrun); |
| 1145 | if (!ret) |
| 1146 | return TRACE_TYPE_PARTIAL_LINE; |
| 1147 | } |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 1148 | |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1149 | ret = print_graph_irq(iter, trace->func, TRACE_GRAPH_RET, |
| 1150 | cpu, pid, flags); |
Frederic Weisbecker | f8b755a | 2008-12-09 23:55:25 +0100 | [diff] [blame] | 1151 | if (ret == TRACE_TYPE_PARTIAL_LINE) |
| 1152 | return TRACE_TYPE_PARTIAL_LINE; |
| 1153 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1154 | return TRACE_TYPE_HANDLED; |
| 1155 | } |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1156 | |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1157 | static enum print_line_t |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1158 | print_graph_comment(struct trace_seq *s, struct trace_entry *ent, |
| 1159 | struct trace_iterator *iter, u32 flags) |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1160 | { |
Steven Rostedt | 5087f8d | 2009-03-19 15:14:46 -0400 | [diff] [blame] | 1161 | unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1162 | struct fgraph_data *data = iter->private; |
Steven Rostedt | 5087f8d | 2009-03-19 15:14:46 -0400 | [diff] [blame] | 1163 | struct trace_event *event; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1164 | int depth = 0; |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1165 | int ret; |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1166 | int i; |
| 1167 | |
| 1168 | if (data) |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1169 | depth = per_cpu_ptr(data->cpu_data, iter->cpu)->depth; |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1170 | |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1171 | if (print_graph_prologue(iter, s, 0, 0, flags)) |
Frederic Weisbecker | d1f9cbd | 2009-02-18 04:25:25 +0100 | [diff] [blame] | 1172 | return TRACE_TYPE_PARTIAL_LINE; |
| 1173 | |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1174 | /* No time */ |
Jiri Olsa | ffeb80f | 2011-06-03 16:58:48 +0200 | [diff] [blame] | 1175 | ret = print_graph_duration(DURATION_FILL_FULL, s, flags); |
| 1176 | if (ret != TRACE_TYPE_HANDLED) |
| 1177 | return ret; |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1178 | |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1179 | /* Indentation */ |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1180 | if (depth > 0) |
| 1181 | for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) { |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1182 | ret = trace_seq_printf(s, " "); |
| 1183 | if (!ret) |
| 1184 | return TRACE_TYPE_PARTIAL_LINE; |
| 1185 | } |
| 1186 | |
| 1187 | /* The comment */ |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1188 | ret = trace_seq_printf(s, "/* "); |
| 1189 | if (!ret) |
| 1190 | return TRACE_TYPE_PARTIAL_LINE; |
| 1191 | |
Steven Rostedt | 5087f8d | 2009-03-19 15:14:46 -0400 | [diff] [blame] | 1192 | switch (iter->ent->type) { |
| 1193 | case TRACE_BPRINT: |
| 1194 | ret = trace_print_bprintk_msg_only(iter); |
| 1195 | if (ret != TRACE_TYPE_HANDLED) |
| 1196 | return ret; |
| 1197 | break; |
| 1198 | case TRACE_PRINT: |
| 1199 | ret = trace_print_printk_msg_only(iter); |
| 1200 | if (ret != TRACE_TYPE_HANDLED) |
| 1201 | return ret; |
| 1202 | break; |
| 1203 | default: |
| 1204 | event = ftrace_find_event(ent->type); |
| 1205 | if (!event) |
| 1206 | return TRACE_TYPE_UNHANDLED; |
| 1207 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1208 | ret = event->funcs->trace(iter, sym_flags, event); |
Steven Rostedt | 5087f8d | 2009-03-19 15:14:46 -0400 | [diff] [blame] | 1209 | if (ret != TRACE_TYPE_HANDLED) |
| 1210 | return ret; |
| 1211 | } |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1212 | |
Frederic Weisbecker | 412d0bb | 2008-12-24 01:43:25 +0100 | [diff] [blame] | 1213 | /* Strip ending newline */ |
| 1214 | if (s->buffer[s->len - 1] == '\n') { |
| 1215 | s->buffer[s->len - 1] = '\0'; |
| 1216 | s->len--; |
| 1217 | } |
| 1218 | |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 1219 | ret = trace_seq_printf(s, " */\n"); |
| 1220 | if (!ret) |
| 1221 | return TRACE_TYPE_PARTIAL_LINE; |
| 1222 | |
| 1223 | return TRACE_TYPE_HANDLED; |
| 1224 | } |
| 1225 | |
| 1226 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1227 | enum print_line_t |
Jiri Olsa | 321e68b | 2011-06-03 16:58:47 +0200 | [diff] [blame] | 1228 | print_graph_function_flags(struct trace_iterator *iter, u32 flags) |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1229 | { |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1230 | struct ftrace_graph_ent_entry *field; |
| 1231 | struct fgraph_data *data = iter->private; |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1232 | struct trace_entry *entry = iter->ent; |
Steven Rostedt | 5087f8d | 2009-03-19 15:14:46 -0400 | [diff] [blame] | 1233 | struct trace_seq *s = &iter->seq; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1234 | int cpu = iter->cpu; |
| 1235 | int ret; |
| 1236 | |
| 1237 | if (data && per_cpu_ptr(data->cpu_data, cpu)->ignore) { |
| 1238 | per_cpu_ptr(data->cpu_data, cpu)->ignore = 0; |
| 1239 | return TRACE_TYPE_HANDLED; |
| 1240 | } |
| 1241 | |
| 1242 | /* |
| 1243 | * If the last output failed, there's a possibility we need |
| 1244 | * to print out the missing entry which would never go out. |
| 1245 | */ |
| 1246 | if (data && data->failed) { |
| 1247 | field = &data->ent; |
| 1248 | iter->cpu = data->cpu; |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1249 | ret = print_graph_entry(field, s, iter, flags); |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1250 | if (ret == TRACE_TYPE_HANDLED && iter->cpu != cpu) { |
| 1251 | per_cpu_ptr(data->cpu_data, iter->cpu)->ignore = 1; |
| 1252 | ret = TRACE_TYPE_NO_CONSUME; |
| 1253 | } |
| 1254 | iter->cpu = cpu; |
| 1255 | return ret; |
| 1256 | } |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1257 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1258 | switch (entry->type) { |
| 1259 | case TRACE_GRAPH_ENT: { |
Lai Jiangshan | 38ceb59 | 2009-07-28 20:11:24 +0800 | [diff] [blame] | 1260 | /* |
| 1261 | * print_graph_entry() may consume the current event, |
| 1262 | * thus @field may become invalid, so we need to save it. |
| 1263 | * sizeof(struct ftrace_graph_ent_entry) is very small, |
| 1264 | * it can be safely saved at the stack. |
| 1265 | */ |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1266 | struct ftrace_graph_ent_entry saved; |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1267 | trace_assign_type(field, entry); |
Lai Jiangshan | 38ceb59 | 2009-07-28 20:11:24 +0800 | [diff] [blame] | 1268 | saved = *field; |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1269 | return print_graph_entry(&saved, s, iter, flags); |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1270 | } |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1271 | case TRACE_GRAPH_RET: { |
| 1272 | struct ftrace_graph_ret_entry *field; |
| 1273 | trace_assign_type(field, entry); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1274 | return print_graph_return(&field->ret, s, entry, iter, flags); |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1275 | } |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 1276 | case TRACE_STACK: |
| 1277 | case TRACE_FN: |
| 1278 | /* dont trace stack and functions as comments */ |
| 1279 | return TRACE_TYPE_UNHANDLED; |
| 1280 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1281 | default: |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1282 | return print_graph_comment(s, entry, iter, flags); |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 1283 | } |
Steven Rostedt | 5087f8d | 2009-03-19 15:14:46 -0400 | [diff] [blame] | 1284 | |
| 1285 | return TRACE_TYPE_HANDLED; |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1286 | } |
| 1287 | |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 1288 | static enum print_line_t |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1289 | print_graph_function(struct trace_iterator *iter) |
| 1290 | { |
Jiri Olsa | 321e68b | 2011-06-03 16:58:47 +0200 | [diff] [blame] | 1291 | return print_graph_function_flags(iter, tracer_flags.val); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | static enum print_line_t |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1295 | print_graph_function_event(struct trace_iterator *iter, int flags, |
| 1296 | struct trace_event *event) |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 1297 | { |
| 1298 | return print_graph_function(iter); |
| 1299 | } |
| 1300 | |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1301 | static void print_lat_header(struct seq_file *s, u32 flags) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1302 | { |
| 1303 | static const char spaces[] = " " /* 16 spaces */ |
| 1304 | " " /* 4 spaces */ |
| 1305 | " "; /* 17 spaces */ |
| 1306 | int size = 0; |
| 1307 | |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1308 | if (flags & TRACE_GRAPH_PRINT_ABS_TIME) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1309 | size += 16; |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1310 | if (flags & TRACE_GRAPH_PRINT_CPU) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1311 | size += 4; |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1312 | if (flags & TRACE_GRAPH_PRINT_PROC) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1313 | size += 17; |
| 1314 | |
| 1315 | seq_printf(s, "#%.*s _-----=> irqs-off \n", size, spaces); |
| 1316 | seq_printf(s, "#%.*s / _----=> need-resched \n", size, spaces); |
| 1317 | seq_printf(s, "#%.*s| / _---=> hardirq/softirq \n", size, spaces); |
| 1318 | seq_printf(s, "#%.*s|| / _--=> preempt-depth \n", size, spaces); |
Jiri Olsa | 199abfa | 2011-06-03 16:58:50 +0200 | [diff] [blame] | 1319 | seq_printf(s, "#%.*s||| / \n", size, spaces); |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1320 | } |
| 1321 | |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 1322 | static void __print_graph_headers_flags(struct seq_file *s, u32 flags) |
Frederic Weisbecker | decbec3 | 2008-12-08 01:56:06 +0100 | [diff] [blame] | 1323 | { |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1324 | int lat = trace_flags & TRACE_ITER_LATENCY_FMT; |
| 1325 | |
| 1326 | if (lat) |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1327 | print_lat_header(s, flags); |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1328 | |
Frederic Weisbecker | decbec3 | 2008-12-08 01:56:06 +0100 | [diff] [blame] | 1329 | /* 1st line */ |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1330 | seq_printf(s, "#"); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1331 | if (flags & TRACE_GRAPH_PRINT_ABS_TIME) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1332 | seq_printf(s, " TIME "); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1333 | if (flags & TRACE_GRAPH_PRINT_CPU) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1334 | seq_printf(s, " CPU"); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1335 | if (flags & TRACE_GRAPH_PRINT_PROC) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1336 | seq_printf(s, " TASK/PID "); |
| 1337 | if (lat) |
Jiri Olsa | 199abfa | 2011-06-03 16:58:50 +0200 | [diff] [blame] | 1338 | seq_printf(s, "||||"); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1339 | if (flags & TRACE_GRAPH_PRINT_DURATION) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1340 | seq_printf(s, " DURATION "); |
| 1341 | seq_printf(s, " FUNCTION CALLS\n"); |
Frederic Weisbecker | decbec3 | 2008-12-08 01:56:06 +0100 | [diff] [blame] | 1342 | |
| 1343 | /* 2nd line */ |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1344 | seq_printf(s, "#"); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1345 | if (flags & TRACE_GRAPH_PRINT_ABS_TIME) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1346 | seq_printf(s, " | "); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1347 | if (flags & TRACE_GRAPH_PRINT_CPU) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1348 | seq_printf(s, " | "); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1349 | if (flags & TRACE_GRAPH_PRINT_PROC) |
Steven Rostedt | 49ff590 | 2009-09-11 00:30:26 -0400 | [diff] [blame] | 1350 | seq_printf(s, " | | "); |
| 1351 | if (lat) |
Jiri Olsa | 199abfa | 2011-06-03 16:58:50 +0200 | [diff] [blame] | 1352 | seq_printf(s, "||||"); |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1353 | if (flags & TRACE_GRAPH_PRINT_DURATION) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1354 | seq_printf(s, " | | "); |
| 1355 | seq_printf(s, " | | | |\n"); |
Frederic Weisbecker | decbec3 | 2008-12-08 01:56:06 +0100 | [diff] [blame] | 1356 | } |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1357 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 1358 | void print_graph_headers(struct seq_file *s) |
Jiri Olsa | d7a8d9e | 2010-04-02 19:01:21 +0200 | [diff] [blame] | 1359 | { |
| 1360 | print_graph_headers_flags(s, tracer_flags.val); |
| 1361 | } |
| 1362 | |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 1363 | void print_graph_headers_flags(struct seq_file *s, u32 flags) |
| 1364 | { |
| 1365 | struct trace_iterator *iter = s->private; |
| 1366 | |
Jiri Olsa | 749230b | 2011-06-03 16:58:51 +0200 | [diff] [blame] | 1367 | if (!(trace_flags & TRACE_ITER_CONTEXT_INFO)) |
| 1368 | return; |
| 1369 | |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 1370 | if (trace_flags & TRACE_ITER_LATENCY_FMT) { |
| 1371 | /* print nothing if the buffers are empty */ |
| 1372 | if (trace_empty(iter)) |
| 1373 | return; |
| 1374 | |
| 1375 | print_trace_header(s, iter); |
Jiri Olsa | 321e68b | 2011-06-03 16:58:47 +0200 | [diff] [blame] | 1376 | } |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 1377 | |
| 1378 | __print_graph_headers_flags(s, flags); |
| 1379 | } |
| 1380 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 1381 | void graph_trace_open(struct trace_iterator *iter) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1382 | { |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1383 | /* pid and depth on the last trace processed */ |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1384 | struct fgraph_data *data; |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1385 | int cpu; |
| 1386 | |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1387 | iter->private = NULL; |
| 1388 | |
| 1389 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1390 | if (!data) |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1391 | goto out_err; |
| 1392 | |
| 1393 | data->cpu_data = alloc_percpu(struct fgraph_cpu_data); |
| 1394 | if (!data->cpu_data) |
| 1395 | goto out_err_free; |
| 1396 | |
| 1397 | for_each_possible_cpu(cpu) { |
| 1398 | pid_t *pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid); |
| 1399 | int *depth = &(per_cpu_ptr(data->cpu_data, cpu)->depth); |
| 1400 | int *ignore = &(per_cpu_ptr(data->cpu_data, cpu)->ignore); |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 1401 | int *depth_irq = &(per_cpu_ptr(data->cpu_data, cpu)->depth_irq); |
| 1402 | |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1403 | *pid = -1; |
| 1404 | *depth = 0; |
| 1405 | *ignore = 0; |
Jiri Olsa | 2bd16212 | 2010-09-07 16:53:44 +0200 | [diff] [blame] | 1406 | *depth_irq = -1; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1407 | } |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1408 | |
Steven Rostedt | 2fbcdb3 | 2009-03-19 13:24:42 -0400 | [diff] [blame] | 1409 | iter->private = data; |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1410 | |
| 1411 | return; |
| 1412 | |
| 1413 | out_err_free: |
| 1414 | kfree(data); |
| 1415 | out_err: |
| 1416 | pr_warning("function graph tracer: not enough memory\n"); |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1417 | } |
| 1418 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 1419 | void graph_trace_close(struct trace_iterator *iter) |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1420 | { |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1421 | struct fgraph_data *data = iter->private; |
| 1422 | |
| 1423 | if (data) { |
| 1424 | free_percpu(data->cpu_data); |
| 1425 | kfree(data); |
| 1426 | } |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1427 | } |
| 1428 | |
Steven Rostedt | b304d04 | 2010-09-14 18:58:33 -0400 | [diff] [blame] | 1429 | static int func_graph_set_flag(u32 old_flags, u32 bit, int set) |
| 1430 | { |
| 1431 | if (bit == TRACE_GRAPH_PRINT_IRQS) |
| 1432 | ftrace_graph_skip_irqs = !set; |
| 1433 | |
| 1434 | return 0; |
| 1435 | } |
| 1436 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1437 | static struct trace_event_functions graph_functions = { |
| 1438 | .trace = print_graph_function_event, |
| 1439 | }; |
| 1440 | |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 1441 | static struct trace_event graph_trace_entry_event = { |
| 1442 | .type = TRACE_GRAPH_ENT, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1443 | .funcs = &graph_functions, |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 1444 | }; |
| 1445 | |
| 1446 | static struct trace_event graph_trace_ret_event = { |
| 1447 | .type = TRACE_GRAPH_RET, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1448 | .funcs = &graph_functions |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 1449 | }; |
| 1450 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1451 | static struct tracer graph_trace __read_mostly = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 1452 | .name = "function_graph", |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1453 | .open = graph_trace_open, |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1454 | .pipe_open = graph_trace_open, |
Frederic Weisbecker | 9005f3e | 2009-01-22 17:04:53 -0800 | [diff] [blame] | 1455 | .close = graph_trace_close, |
Jiri Olsa | be1eca3 | 2009-11-24 13:57:38 +0100 | [diff] [blame] | 1456 | .pipe_close = graph_trace_close, |
Frederic Weisbecker | 6eaaa5d | 2009-02-11 02:25:00 +0100 | [diff] [blame] | 1457 | .wait_pipe = poll_wait_pipe, |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 1458 | .init = graph_trace_init, |
| 1459 | .reset = graph_trace_reset, |
Frederic Weisbecker | decbec3 | 2008-12-08 01:56:06 +0100 | [diff] [blame] | 1460 | .print_line = print_graph_function, |
| 1461 | .print_header = print_graph_headers, |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1462 | .flags = &tracer_flags, |
Steven Rostedt | b304d04 | 2010-09-14 18:58:33 -0400 | [diff] [blame] | 1463 | .set_flag = func_graph_set_flag, |
Frederic Weisbecker | 7447dce | 2009-02-07 21:33:57 +0100 | [diff] [blame] | 1464 | #ifdef CONFIG_FTRACE_SELFTEST |
| 1465 | .selftest = trace_selftest_startup_function_graph, |
| 1466 | #endif |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1467 | }; |
| 1468 | |
Steven Rostedt | 8741db5 | 2013-01-16 10:49:37 -0500 | [diff] [blame] | 1469 | |
| 1470 | static ssize_t |
| 1471 | graph_depth_write(struct file *filp, const char __user *ubuf, size_t cnt, |
| 1472 | loff_t *ppos) |
| 1473 | { |
| 1474 | unsigned long val; |
| 1475 | int ret; |
| 1476 | |
| 1477 | ret = kstrtoul_from_user(ubuf, cnt, 10, &val); |
| 1478 | if (ret) |
| 1479 | return ret; |
| 1480 | |
| 1481 | max_depth = val; |
| 1482 | |
| 1483 | *ppos += cnt; |
| 1484 | |
| 1485 | return cnt; |
| 1486 | } |
| 1487 | |
| 1488 | static ssize_t |
| 1489 | graph_depth_read(struct file *filp, char __user *ubuf, size_t cnt, |
| 1490 | loff_t *ppos) |
| 1491 | { |
| 1492 | char buf[15]; /* More than enough to hold UINT_MAX + "\n"*/ |
| 1493 | int n; |
| 1494 | |
| 1495 | n = sprintf(buf, "%d\n", max_depth); |
| 1496 | |
| 1497 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, n); |
| 1498 | } |
| 1499 | |
| 1500 | static const struct file_operations graph_depth_fops = { |
| 1501 | .open = tracing_open_generic, |
| 1502 | .write = graph_depth_write, |
| 1503 | .read = graph_depth_read, |
| 1504 | .llseek = generic_file_llseek, |
| 1505 | }; |
| 1506 | |
| 1507 | static __init int init_graph_debugfs(void) |
| 1508 | { |
| 1509 | struct dentry *d_tracer; |
| 1510 | |
| 1511 | d_tracer = tracing_init_dentry(); |
| 1512 | if (!d_tracer) |
| 1513 | return 0; |
| 1514 | |
| 1515 | trace_create_file("max_graph_depth", 0644, d_tracer, |
| 1516 | NULL, &graph_depth_fops); |
| 1517 | |
| 1518 | return 0; |
| 1519 | } |
| 1520 | fs_initcall(init_graph_debugfs); |
| 1521 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1522 | static __init int init_graph_trace(void) |
| 1523 | { |
Lai Jiangshan | 0c9e6f6 | 2009-07-28 20:26:06 +0800 | [diff] [blame] | 1524 | max_bytes_for_cpu = snprintf(NULL, 0, "%d", nr_cpu_ids - 1); |
| 1525 | |
Jiri Olsa | 9106b69 | 2010-04-02 19:01:20 +0200 | [diff] [blame] | 1526 | if (!register_ftrace_event(&graph_trace_entry_event)) { |
| 1527 | pr_warning("Warning: could not register graph trace events\n"); |
| 1528 | return 1; |
| 1529 | } |
| 1530 | |
| 1531 | if (!register_ftrace_event(&graph_trace_ret_event)) { |
| 1532 | pr_warning("Warning: could not register graph trace events\n"); |
| 1533 | return 1; |
| 1534 | } |
| 1535 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 1536 | return register_tracer(&graph_trace); |
| 1537 | } |
| 1538 | |
Steven Rostedt | 6f41567 | 2012-10-05 12:13:07 -0400 | [diff] [blame] | 1539 | core_initcall(init_graph_trace); |