aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_selftest.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-05-12 15:20:45 -0400
committerThomas Gleixner <tglx@linutronix.de>2008-05-23 14:40:46 -0400
commitc7aafc549766b87819285d3480648fc652a47bc4 (patch)
tree4c36170a644633f930feca57b27f8c5d23644e70 /kernel/trace/trace_selftest.c
parent60a11774b38fef1ab90b18c5353bd1c7c4d311c8 (diff)
ftrace: cleanups
factor out code and clean it up. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r--kernel/trace/trace_selftest.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index ef4d3cc009f5..c01874c3b1f9 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -1,6 +1,7 @@
1/* Include in trace.c */ 1/* Include in trace.c */
2 2
3#include <linux/kthread.h> 3#include <linux/kthread.h>
4#include <linux/delay.h>
4 5
5static inline int trace_valid_entry(struct trace_entry *entry) 6static inline int trace_valid_entry(struct trace_entry *entry)
6{ 7{
@@ -15,28 +16,29 @@ static inline int trace_valid_entry(struct trace_entry *entry)
15static int 16static int
16trace_test_buffer_cpu(struct trace_array *tr, struct trace_array_cpu *data) 17trace_test_buffer_cpu(struct trace_array *tr, struct trace_array_cpu *data)
17{ 18{
18 struct page *page;
19 struct trace_entry *entries; 19 struct trace_entry *entries;
20 struct page *page;
20 int idx = 0; 21 int idx = 0;
21 int i; 22 int i;
22 23
24 BUG_ON(list_empty(&data->trace_pages));
23 page = list_entry(data->trace_pages.next, struct page, lru); 25 page = list_entry(data->trace_pages.next, struct page, lru);
24 entries = page_address(page); 26 entries = page_address(page);
25 27
26 if (data->trace != entries) 28 if (head_page(data) != entries)
27 goto failed; 29 goto failed;
28 30
29 /* 31 /*
30 * The starting trace buffer always has valid elements, 32 * The starting trace buffer always has valid elements,
31 * if any element exits. 33 * if any element exists.
32 */ 34 */
33 entries = data->trace; 35 entries = head_page(data);
34 36
35 for (i = 0; i < tr->entries; i++) { 37 for (i = 0; i < tr->entries; i++) {
36 38
37 if (i < data->trace_idx && 39 if (i < data->trace_idx && !trace_valid_entry(&entries[idx])) {
38 !trace_valid_entry(&entries[idx])) { 40 printk(KERN_CONT ".. invalid entry %d ",
39 printk(KERN_CONT ".. invalid entry %d ", entries[idx].type); 41 entries[idx].type);
40 goto failed; 42 goto failed;
41 } 43 }
42 44
@@ -80,11 +82,10 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
80 int ret = 0; 82 int ret = 0;
81 83
82 for_each_possible_cpu(cpu) { 84 for_each_possible_cpu(cpu) {
83 if (!tr->data[cpu]->trace) 85 if (!head_page(tr->data[cpu]))
84 continue; 86 continue;
85 87
86 cnt += tr->data[cpu]->trace_idx; 88 cnt += tr->data[cpu]->trace_idx;
87 printk("%d: count = %ld\n", cpu, cnt);
88 89
89 ret = trace_test_buffer_cpu(tr, tr->data[cpu]); 90 ret = trace_test_buffer_cpu(tr, tr->data[cpu]);
90 if (ret) 91 if (ret)
@@ -117,6 +118,8 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
117 } 118 }
118 119
119 /* start the tracing */ 120 /* start the tracing */
121 ftrace_enabled = 1;
122
120 tr->ctrl = 1; 123 tr->ctrl = 1;
121 trace->init(tr); 124 trace->init(tr);
122 /* Sleep for a 1/10 of a second */ 125 /* Sleep for a 1/10 of a second */
@@ -124,6 +127,8 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
124 /* stop the tracing. */ 127 /* stop the tracing. */
125 tr->ctrl = 0; 128 tr->ctrl = 0;
126 trace->ctrl_update(tr); 129 trace->ctrl_update(tr);
130 ftrace_enabled = 0;
131
127 /* check the trace buffer */ 132 /* check the trace buffer */
128 ret = trace_test_buffer(tr, &count); 133 ret = trace_test_buffer(tr, &count);
129 trace->reset(tr); 134 trace->reset(tr);
@@ -328,7 +333,7 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
328 333
329 /* create a high prio thread */ 334 /* create a high prio thread */
330 p = kthread_run(trace_wakeup_test_thread, &isrt, "ftrace-test"); 335 p = kthread_run(trace_wakeup_test_thread, &isrt, "ftrace-test");
331 if (!IS_ERR(p)) { 336 if (IS_ERR(p)) {
332 printk(KERN_CONT "Failed to create ftrace wakeup test thread "); 337 printk(KERN_CONT "Failed to create ftrace wakeup test thread ");
333 return -1; 338 return -1;
334 } 339 }