aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_selftest.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-08-01 12:26:41 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:35:19 -0400
commitdd0e545f061f90099a3dcc13aa77e29c6295cf23 (patch)
tree91842e81cacd2ae785bf14b96f3f65af96985658 /kernel/trace/trace_selftest.c
parent2e2ca155cd2213b4f398031180fb3d399d5b7db9 (diff)
ftrace: printk formatting infrastructure
This patch adds a feature that can help kernel developers debug their code using ftrace. int ftrace_printk(const char *fmt, ...); This records into the ftrace buffer using printf formatting. The entry size in the buffers are still a fixed length. A new type has been added that allows for more entries to be used for a single recording. The start of the print is still the same as the other entries. It returns the number of characters written to the ftrace buffer. For example: Having a module with the following code: static int __init ftrace_print_test(void) { ftrace_printk("jiffies are %ld\n", jiffies); return 0; } Gives me: insmod-5441 3...1 7569us : ftrace_print_test: jiffies are 4296626666 for the latency_trace file and: insmod-5441 [03] 1959.370498: ftrace_print_test jiffies are 4296626666 for the trace file. Note: Only the infrastructure should go into the kernel. It is to help facilitate debugging for other kernel developers. Calls to ftrace_printk is not intended to be left in the kernel, and should be frowned upon just like scattering printks around in the code. But having this easily at your fingertips helps the debugging go faster and bugs be solved quicker. Maybe later on, we can hook this with markers and have their printf format be sucked into ftrace output. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r--kernel/trace/trace_selftest.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 0911b7e073bf..630715bbd572 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -9,7 +9,9 @@ static inline int trace_valid_entry(struct trace_entry *entry)
9 case TRACE_FN: 9 case TRACE_FN:
10 case TRACE_CTX: 10 case TRACE_CTX:
11 case TRACE_WAKE: 11 case TRACE_WAKE:
12 case TRACE_CONT:
12 case TRACE_STACK: 13 case TRACE_STACK:
14 case TRACE_PRINT:
13 case TRACE_SPECIAL: 15 case TRACE_SPECIAL:
14 return 1; 16 return 1;
15 } 17 }
@@ -120,11 +122,11 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
120 struct trace_array *tr, 122 struct trace_array *tr,
121 int (*func)(void)) 123 int (*func)(void))
122{ 124{
123 unsigned long count;
124 int ret;
125 int save_ftrace_enabled = ftrace_enabled; 125 int save_ftrace_enabled = ftrace_enabled;
126 int save_tracer_enabled = tracer_enabled; 126 int save_tracer_enabled = tracer_enabled;
127 unsigned long count;
127 char *func_name; 128 char *func_name;
129 int ret;
128 130
129 /* The ftrace test PASSED */ 131 /* The ftrace test PASSED */
130 printk(KERN_CONT "PASSED\n"); 132 printk(KERN_CONT "PASSED\n");
@@ -157,6 +159,7 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
157 /* enable tracing */ 159 /* enable tracing */
158 tr->ctrl = 1; 160 tr->ctrl = 1;
159 trace->init(tr); 161 trace->init(tr);
162
160 /* Sleep for a 1/10 of a second */ 163 /* Sleep for a 1/10 of a second */
161 msleep(100); 164 msleep(100);
162 165
@@ -212,10 +215,10 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
212int 215int
213trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr) 216trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
214{ 217{
215 unsigned long count;
216 int ret;
217 int save_ftrace_enabled = ftrace_enabled; 218 int save_ftrace_enabled = ftrace_enabled;
218 int save_tracer_enabled = tracer_enabled; 219 int save_tracer_enabled = tracer_enabled;
220 unsigned long count;
221 int ret;
219 222
220 /* make sure msleep has been recorded */ 223 /* make sure msleep has been recorded */
221 msleep(1); 224 msleep(1);