tracing: Dump either the oops's cpu source or all cpus buffers
[pandora-kernel.git] / kernel / trace / trace_selftest.c
1 /* Include in trace.c */
2
3 #include <linux/stringify.h>
4 #include <linux/kthread.h>
5 #include <linux/delay.h>
6 #include <linux/slab.h>
7
8 static inline int trace_valid_entry(struct trace_entry *entry)
9 {
10         switch (entry->type) {
11         case TRACE_FN:
12         case TRACE_CTX:
13         case TRACE_WAKE:
14         case TRACE_STACK:
15         case TRACE_PRINT:
16         case TRACE_SPECIAL:
17         case TRACE_BRANCH:
18         case TRACE_GRAPH_ENT:
19         case TRACE_GRAPH_RET:
20         case TRACE_HW_BRANCHES:
21         case TRACE_KSYM:
22                 return 1;
23         }
24         return 0;
25 }
26
27 static int trace_test_buffer_cpu(struct trace_array *tr, int cpu)
28 {
29         struct ring_buffer_event *event;
30         struct trace_entry *entry;
31         unsigned int loops = 0;
32
33         while ((event = ring_buffer_consume(tr->buffer, cpu, NULL, NULL))) {
34                 entry = ring_buffer_event_data(event);
35
36                 /*
37                  * The ring buffer is a size of trace_buf_size, if
38                  * we loop more than the size, there's something wrong
39                  * with the ring buffer.
40                  */
41                 if (loops++ > trace_buf_size) {
42                         printk(KERN_CONT ".. bad ring buffer ");
43                         goto failed;
44                 }
45                 if (!trace_valid_entry(entry)) {
46                         printk(KERN_CONT ".. invalid entry %d ",
47                                 entry->type);
48                         goto failed;
49                 }
50         }
51         return 0;
52
53  failed:
54         /* disable tracing */
55         tracing_disabled = 1;
56         printk(KERN_CONT ".. corrupted trace buffer .. ");
57         return -1;
58 }
59
60 /*
61  * Test the trace buffer to see if all the elements
62  * are still sane.
63  */
64 static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
65 {
66         unsigned long flags, cnt = 0;
67         int cpu, ret = 0;
68
69         /* Don't allow flipping of max traces now */
70         local_irq_save(flags);
71         arch_spin_lock(&ftrace_max_lock);
72
73         cnt = ring_buffer_entries(tr->buffer);
74
75         /*
76          * The trace_test_buffer_cpu runs a while loop to consume all data.
77          * If the calling tracer is broken, and is constantly filling
78          * the buffer, this will run forever, and hard lock the box.
79          * We disable the ring buffer while we do this test to prevent
80          * a hard lock up.
81          */
82         tracing_off();
83         for_each_possible_cpu(cpu) {
84                 ret = trace_test_buffer_cpu(tr, cpu);
85                 if (ret)
86                         break;
87         }
88         tracing_on();
89         arch_spin_unlock(&ftrace_max_lock);
90         local_irq_restore(flags);
91
92         if (count)
93                 *count = cnt;
94
95         return ret;
96 }
97
98 static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
99 {
100         printk(KERN_WARNING "Failed to init %s tracer, init returned %d\n",
101                 trace->name, init_ret);
102 }
103 #ifdef CONFIG_FUNCTION_TRACER
104
105 #ifdef CONFIG_DYNAMIC_FTRACE
106
107 /* Test dynamic code modification and ftrace filters */
108 int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
109                                            struct trace_array *tr,
110                                            int (*func)(void))
111 {
112         int save_ftrace_enabled = ftrace_enabled;
113         int save_tracer_enabled = tracer_enabled;
114         unsigned long count;
115         char *func_name;
116         int ret;
117
118         /* The ftrace test PASSED */
119         printk(KERN_CONT "PASSED\n");
120         pr_info("Testing dynamic ftrace: ");
121
122         /* enable tracing, and record the filter function */
123         ftrace_enabled = 1;
124         tracer_enabled = 1;
125
126         /* passed in by parameter to fool gcc from optimizing */
127         func();
128
129         /*
130          * Some archs *cough*PowerPC*cough* add characters to the
131          * start of the function names. We simply put a '*' to
132          * accommodate them.
133          */
134         func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
135
136         /* filter only on our function */
137         ftrace_set_filter(func_name, strlen(func_name), 1);
138
139         /* enable tracing */
140         ret = tracer_init(trace, tr);
141         if (ret) {
142                 warn_failed_init_tracer(trace, ret);
143                 goto out;
144         }
145
146         /* Sleep for a 1/10 of a second */
147         msleep(100);
148
149         /* we should have nothing in the buffer */
150         ret = trace_test_buffer(tr, &count);
151         if (ret)
152                 goto out;
153
154         if (count) {
155                 ret = -1;
156                 printk(KERN_CONT ".. filter did not filter .. ");
157                 goto out;
158         }
159
160         /* call our function again */
161         func();
162
163         /* sleep again */
164         msleep(100);
165
166         /* stop the tracing. */
167         tracing_stop();
168         ftrace_enabled = 0;
169
170         /* check the trace buffer */
171         ret = trace_test_buffer(tr, &count);
172         trace->reset(tr);
173         tracing_start();
174
175         /* we should only have one item */
176         if (!ret && count != 1) {
177                 printk(KERN_CONT ".. filter failed count=%ld ..", count);
178                 ret = -1;
179                 goto out;
180         }
181
182  out:
183         ftrace_enabled = save_ftrace_enabled;
184         tracer_enabled = save_tracer_enabled;
185
186         /* Enable tracing on all functions again */
187         ftrace_set_filter(NULL, 0, 1);
188
189         return ret;
190 }
191 #else
192 # define trace_selftest_startup_dynamic_tracing(trace, tr, func) ({ 0; })
193 #endif /* CONFIG_DYNAMIC_FTRACE */
194
195 /*
196  * Simple verification test of ftrace function tracer.
197  * Enable ftrace, sleep 1/10 second, and then read the trace
198  * buffer to see if all is in order.
199  */
200 int
201 trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
202 {
203         int save_ftrace_enabled = ftrace_enabled;
204         int save_tracer_enabled = tracer_enabled;
205         unsigned long count;
206         int ret;
207
208         /* make sure msleep has been recorded */
209         msleep(1);
210
211         /* start the tracing */
212         ftrace_enabled = 1;
213         tracer_enabled = 1;
214
215         ret = tracer_init(trace, tr);
216         if (ret) {
217                 warn_failed_init_tracer(trace, ret);
218                 goto out;
219         }
220
221         /* Sleep for a 1/10 of a second */
222         msleep(100);
223         /* stop the tracing. */
224         tracing_stop();
225         ftrace_enabled = 0;
226
227         /* check the trace buffer */
228         ret = trace_test_buffer(tr, &count);
229         trace->reset(tr);
230         tracing_start();
231
232         if (!ret && !count) {
233                 printk(KERN_CONT ".. no entries found ..");
234                 ret = -1;
235                 goto out;
236         }
237
238         ret = trace_selftest_startup_dynamic_tracing(trace, tr,
239                                                      DYN_FTRACE_TEST_NAME);
240
241  out:
242         ftrace_enabled = save_ftrace_enabled;
243         tracer_enabled = save_tracer_enabled;
244
245         /* kill ftrace totally if we failed */
246         if (ret)
247                 ftrace_kill();
248
249         return ret;
250 }
251 #endif /* CONFIG_FUNCTION_TRACER */
252
253
254 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
255
256 /* Maximum number of functions to trace before diagnosing a hang */
257 #define GRAPH_MAX_FUNC_TEST     100000000
258
259 static void
260 __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode);
261 static unsigned int graph_hang_thresh;
262
263 /* Wrap the real function entry probe to avoid possible hanging */
264 static int trace_graph_entry_watchdog(struct ftrace_graph_ent *trace)
265 {
266         /* This is harmlessly racy, we want to approximately detect a hang */
267         if (unlikely(++graph_hang_thresh > GRAPH_MAX_FUNC_TEST)) {
268                 ftrace_graph_stop();
269                 printk(KERN_WARNING "BUG: Function graph tracer hang!\n");
270                 if (ftrace_dump_on_oops)
271                         __ftrace_dump(false, DUMP_ALL);
272                 return 0;
273         }
274
275         return trace_graph_entry(trace);
276 }
277
278 /*
279  * Pretty much the same than for the function tracer from which the selftest
280  * has been borrowed.
281  */
282 int
283 trace_selftest_startup_function_graph(struct tracer *trace,
284                                         struct trace_array *tr)
285 {
286         int ret;
287         unsigned long count;
288
289         /*
290          * Simulate the init() callback but we attach a watchdog callback
291          * to detect and recover from possible hangs
292          */
293         tracing_reset_online_cpus(tr);
294         set_graph_array(tr);
295         ret = register_ftrace_graph(&trace_graph_return,
296                                     &trace_graph_entry_watchdog);
297         if (ret) {
298                 warn_failed_init_tracer(trace, ret);
299                 goto out;
300         }
301         tracing_start_cmdline_record();
302
303         /* Sleep for a 1/10 of a second */
304         msleep(100);
305
306         /* Have we just recovered from a hang? */
307         if (graph_hang_thresh > GRAPH_MAX_FUNC_TEST) {
308                 tracing_selftest_disabled = true;
309                 ret = -1;
310                 goto out;
311         }
312
313         tracing_stop();
314
315         /* check the trace buffer */
316         ret = trace_test_buffer(tr, &count);
317
318         trace->reset(tr);
319         tracing_start();
320
321         if (!ret && !count) {
322                 printk(KERN_CONT ".. no entries found ..");
323                 ret = -1;
324                 goto out;
325         }
326
327         /* Don't test dynamic tracing, the function tracer already did */
328
329 out:
330         /* Stop it if we failed */
331         if (ret)
332                 ftrace_graph_stop();
333
334         return ret;
335 }
336 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
337
338
339 #ifdef CONFIG_IRQSOFF_TRACER
340 int
341 trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
342 {
343         unsigned long save_max = tracing_max_latency;
344         unsigned long count;
345         int ret;
346
347         /* start the tracing */
348         ret = tracer_init(trace, tr);
349         if (ret) {
350                 warn_failed_init_tracer(trace, ret);
351                 return ret;
352         }
353
354         /* reset the max latency */
355         tracing_max_latency = 0;
356         /* disable interrupts for a bit */
357         local_irq_disable();
358         udelay(100);
359         local_irq_enable();
360
361         /*
362          * Stop the tracer to avoid a warning subsequent
363          * to buffer flipping failure because tracing_stop()
364          * disables the tr and max buffers, making flipping impossible
365          * in case of parallels max irqs off latencies.
366          */
367         trace->stop(tr);
368         /* stop the tracing. */
369         tracing_stop();
370         /* check both trace buffers */
371         ret = trace_test_buffer(tr, NULL);
372         if (!ret)
373                 ret = trace_test_buffer(&max_tr, &count);
374         trace->reset(tr);
375         tracing_start();
376
377         if (!ret && !count) {
378                 printk(KERN_CONT ".. no entries found ..");
379                 ret = -1;
380         }
381
382         tracing_max_latency = save_max;
383
384         return ret;
385 }
386 #endif /* CONFIG_IRQSOFF_TRACER */
387
388 #ifdef CONFIG_PREEMPT_TRACER
389 int
390 trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
391 {
392         unsigned long save_max = tracing_max_latency;
393         unsigned long count;
394         int ret;
395
396         /*
397          * Now that the big kernel lock is no longer preemptable,
398          * and this is called with the BKL held, it will always
399          * fail. If preemption is already disabled, simply
400          * pass the test. When the BKL is removed, or becomes
401          * preemptible again, we will once again test this,
402          * so keep it in.
403          */
404         if (preempt_count()) {
405                 printk(KERN_CONT "can not test ... force ");
406                 return 0;
407         }
408
409         /* start the tracing */
410         ret = tracer_init(trace, tr);
411         if (ret) {
412                 warn_failed_init_tracer(trace, ret);
413                 return ret;
414         }
415
416         /* reset the max latency */
417         tracing_max_latency = 0;
418         /* disable preemption for a bit */
419         preempt_disable();
420         udelay(100);
421         preempt_enable();
422
423         /*
424          * Stop the tracer to avoid a warning subsequent
425          * to buffer flipping failure because tracing_stop()
426          * disables the tr and max buffers, making flipping impossible
427          * in case of parallels max preempt off latencies.
428          */
429         trace->stop(tr);
430         /* stop the tracing. */
431         tracing_stop();
432         /* check both trace buffers */
433         ret = trace_test_buffer(tr, NULL);
434         if (!ret)
435                 ret = trace_test_buffer(&max_tr, &count);
436         trace->reset(tr);
437         tracing_start();
438
439         if (!ret && !count) {
440                 printk(KERN_CONT ".. no entries found ..");
441                 ret = -1;
442         }
443
444         tracing_max_latency = save_max;
445
446         return ret;
447 }
448 #endif /* CONFIG_PREEMPT_TRACER */
449
450 #if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER)
451 int
452 trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *tr)
453 {
454         unsigned long save_max = tracing_max_latency;
455         unsigned long count;
456         int ret;
457
458         /*
459          * Now that the big kernel lock is no longer preemptable,
460          * and this is called with the BKL held, it will always
461          * fail. If preemption is already disabled, simply
462          * pass the test. When the BKL is removed, or becomes
463          * preemptible again, we will once again test this,
464          * so keep it in.
465          */
466         if (preempt_count()) {
467                 printk(KERN_CONT "can not test ... force ");
468                 return 0;
469         }
470
471         /* start the tracing */
472         ret = tracer_init(trace, tr);
473         if (ret) {
474                 warn_failed_init_tracer(trace, ret);
475                 goto out_no_start;
476         }
477
478         /* reset the max latency */
479         tracing_max_latency = 0;
480
481         /* disable preemption and interrupts for a bit */
482         preempt_disable();
483         local_irq_disable();
484         udelay(100);
485         preempt_enable();
486         /* reverse the order of preempt vs irqs */
487         local_irq_enable();
488
489         /*
490          * Stop the tracer to avoid a warning subsequent
491          * to buffer flipping failure because tracing_stop()
492          * disables the tr and max buffers, making flipping impossible
493          * in case of parallels max irqs/preempt off latencies.
494          */
495         trace->stop(tr);
496         /* stop the tracing. */
497         tracing_stop();
498         /* check both trace buffers */
499         ret = trace_test_buffer(tr, NULL);
500         if (ret)
501                 goto out;
502
503         ret = trace_test_buffer(&max_tr, &count);
504         if (ret)
505                 goto out;
506
507         if (!ret && !count) {
508                 printk(KERN_CONT ".. no entries found ..");
509                 ret = -1;
510                 goto out;
511         }
512
513         /* do the test by disabling interrupts first this time */
514         tracing_max_latency = 0;
515         tracing_start();
516         trace->start(tr);
517
518         preempt_disable();
519         local_irq_disable();
520         udelay(100);
521         preempt_enable();
522         /* reverse the order of preempt vs irqs */
523         local_irq_enable();
524
525         trace->stop(tr);
526         /* stop the tracing. */
527         tracing_stop();
528         /* check both trace buffers */
529         ret = trace_test_buffer(tr, NULL);
530         if (ret)
531                 goto out;
532
533         ret = trace_test_buffer(&max_tr, &count);
534
535         if (!ret && !count) {
536                 printk(KERN_CONT ".. no entries found ..");
537                 ret = -1;
538                 goto out;
539         }
540
541 out:
542         tracing_start();
543 out_no_start:
544         trace->reset(tr);
545         tracing_max_latency = save_max;
546
547         return ret;
548 }
549 #endif /* CONFIG_IRQSOFF_TRACER && CONFIG_PREEMPT_TRACER */
550
551 #ifdef CONFIG_NOP_TRACER
552 int
553 trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
554 {
555         /* What could possibly go wrong? */
556         return 0;
557 }
558 #endif
559
560 #ifdef CONFIG_SCHED_TRACER
561 static int trace_wakeup_test_thread(void *data)
562 {
563         /* Make this a RT thread, doesn't need to be too high */
564         struct sched_param param = { .sched_priority = 5 };
565         struct completion *x = data;
566
567         sched_setscheduler(current, SCHED_FIFO, &param);
568
569         /* Make it know we have a new prio */
570         complete(x);
571
572         /* now go to sleep and let the test wake us up */
573         set_current_state(TASK_INTERRUPTIBLE);
574         schedule();
575
576         /* we are awake, now wait to disappear */
577         while (!kthread_should_stop()) {
578                 /*
579                  * This is an RT task, do short sleeps to let
580                  * others run.
581                  */
582                 msleep(100);
583         }
584
585         return 0;
586 }
587
588 int
589 trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
590 {
591         unsigned long save_max = tracing_max_latency;
592         struct task_struct *p;
593         struct completion isrt;
594         unsigned long count;
595         int ret;
596
597         init_completion(&isrt);
598
599         /* create a high prio thread */
600         p = kthread_run(trace_wakeup_test_thread, &isrt, "ftrace-test");
601         if (IS_ERR(p)) {
602                 printk(KERN_CONT "Failed to create ftrace wakeup test thread ");
603                 return -1;
604         }
605
606         /* make sure the thread is running at an RT prio */
607         wait_for_completion(&isrt);
608
609         /* start the tracing */
610         ret = tracer_init(trace, tr);
611         if (ret) {
612                 warn_failed_init_tracer(trace, ret);
613                 return ret;
614         }
615
616         /* reset the max latency */
617         tracing_max_latency = 0;
618
619         /* sleep to let the RT thread sleep too */
620         msleep(100);
621
622         /*
623          * Yes this is slightly racy. It is possible that for some
624          * strange reason that the RT thread we created, did not
625          * call schedule for 100ms after doing the completion,
626          * and we do a wakeup on a task that already is awake.
627          * But that is extremely unlikely, and the worst thing that
628          * happens in such a case, is that we disable tracing.
629          * Honestly, if this race does happen something is horrible
630          * wrong with the system.
631          */
632
633         wake_up_process(p);
634
635         /* give a little time to let the thread wake up */
636         msleep(100);
637
638         /* stop the tracing. */
639         tracing_stop();
640         /* check both trace buffers */
641         ret = trace_test_buffer(tr, NULL);
642         if (!ret)
643                 ret = trace_test_buffer(&max_tr, &count);
644
645
646         trace->reset(tr);
647         tracing_start();
648
649         tracing_max_latency = save_max;
650
651         /* kill the thread */
652         kthread_stop(p);
653
654         if (!ret && !count) {
655                 printk(KERN_CONT ".. no entries found ..");
656                 ret = -1;
657         }
658
659         return ret;
660 }
661 #endif /* CONFIG_SCHED_TRACER */
662
663 #ifdef CONFIG_CONTEXT_SWITCH_TRACER
664 int
665 trace_selftest_startup_sched_switch(struct tracer *trace, struct trace_array *tr)
666 {
667         unsigned long count;
668         int ret;
669
670         /* start the tracing */
671         ret = tracer_init(trace, tr);
672         if (ret) {
673                 warn_failed_init_tracer(trace, ret);
674                 return ret;
675         }
676
677         /* Sleep for a 1/10 of a second */
678         msleep(100);
679         /* stop the tracing. */
680         tracing_stop();
681         /* check the trace buffer */
682         ret = trace_test_buffer(tr, &count);
683         trace->reset(tr);
684         tracing_start();
685
686         if (!ret && !count) {
687                 printk(KERN_CONT ".. no entries found ..");
688                 ret = -1;
689         }
690
691         return ret;
692 }
693 #endif /* CONFIG_CONTEXT_SWITCH_TRACER */
694
695 #ifdef CONFIG_SYSPROF_TRACER
696 int
697 trace_selftest_startup_sysprof(struct tracer *trace, struct trace_array *tr)
698 {
699         unsigned long count;
700         int ret;
701
702         /* start the tracing */
703         ret = tracer_init(trace, tr);
704         if (ret) {
705                 warn_failed_init_tracer(trace, ret);
706                 return ret;
707         }
708
709         /* Sleep for a 1/10 of a second */
710         msleep(100);
711         /* stop the tracing. */
712         tracing_stop();
713         /* check the trace buffer */
714         ret = trace_test_buffer(tr, &count);
715         trace->reset(tr);
716         tracing_start();
717
718         if (!ret && !count) {
719                 printk(KERN_CONT ".. no entries found ..");
720                 ret = -1;
721         }
722
723         return ret;
724 }
725 #endif /* CONFIG_SYSPROF_TRACER */
726
727 #ifdef CONFIG_BRANCH_TRACER
728 int
729 trace_selftest_startup_branch(struct tracer *trace, struct trace_array *tr)
730 {
731         unsigned long count;
732         int ret;
733
734         /* start the tracing */
735         ret = tracer_init(trace, tr);
736         if (ret) {
737                 warn_failed_init_tracer(trace, ret);
738                 return ret;
739         }
740
741         /* Sleep for a 1/10 of a second */
742         msleep(100);
743         /* stop the tracing. */
744         tracing_stop();
745         /* check the trace buffer */
746         ret = trace_test_buffer(tr, &count);
747         trace->reset(tr);
748         tracing_start();
749
750         if (!ret && !count) {
751                 printk(KERN_CONT ".. no entries found ..");
752                 ret = -1;
753         }
754
755         return ret;
756 }
757 #endif /* CONFIG_BRANCH_TRACER */
758
759 #ifdef CONFIG_HW_BRANCH_TRACER
760 int
761 trace_selftest_startup_hw_branches(struct tracer *trace,
762                                    struct trace_array *tr)
763 {
764         struct trace_iterator *iter;
765         struct tracer tracer;
766         unsigned long count;
767         int ret;
768
769         if (!trace->open) {
770                 printk(KERN_CONT "missing open function...");
771                 return -1;
772         }
773
774         ret = tracer_init(trace, tr);
775         if (ret) {
776                 warn_failed_init_tracer(trace, ret);
777                 return ret;
778         }
779
780         /*
781          * The hw-branch tracer needs to collect the trace from the various
782          * cpu trace buffers - before tracing is stopped.
783          */
784         iter = kzalloc(sizeof(*iter), GFP_KERNEL);
785         if (!iter)
786                 return -ENOMEM;
787
788         memcpy(&tracer, trace, sizeof(tracer));
789
790         iter->trace = &tracer;
791         iter->tr = tr;
792         iter->pos = -1;
793         mutex_init(&iter->mutex);
794
795         trace->open(iter);
796
797         mutex_destroy(&iter->mutex);
798         kfree(iter);
799
800         tracing_stop();
801
802         ret = trace_test_buffer(tr, &count);
803         trace->reset(tr);
804         tracing_start();
805
806         if (!ret && !count) {
807                 printk(KERN_CONT "no entries found..");
808                 ret = -1;
809         }
810
811         return ret;
812 }
813 #endif /* CONFIG_HW_BRANCH_TRACER */
814
815 #ifdef CONFIG_KSYM_TRACER
816 static int ksym_selftest_dummy;
817
818 int
819 trace_selftest_startup_ksym(struct tracer *trace, struct trace_array *tr)
820 {
821         unsigned long count;
822         int ret;
823
824         /* start the tracing */
825         ret = tracer_init(trace, tr);
826         if (ret) {
827                 warn_failed_init_tracer(trace, ret);
828                 return ret;
829         }
830
831         ksym_selftest_dummy = 0;
832         /* Register the read-write tracing request */
833
834         ret = process_new_ksym_entry("ksym_selftest_dummy",
835                                      HW_BREAKPOINT_R | HW_BREAKPOINT_W,
836                                         (unsigned long)(&ksym_selftest_dummy));
837
838         if (ret < 0) {
839                 printk(KERN_CONT "ksym_trace read-write startup test failed\n");
840                 goto ret_path;
841         }
842         /* Perform a read and a write operation over the dummy variable to
843          * trigger the tracer
844          */
845         if (ksym_selftest_dummy == 0)
846                 ksym_selftest_dummy++;
847
848         /* stop the tracing. */
849         tracing_stop();
850         /* check the trace buffer */
851         ret = trace_test_buffer(tr, &count);
852         trace->reset(tr);
853         tracing_start();
854
855         /* read & write operations - one each is performed on the dummy variable
856          * triggering two entries in the trace buffer
857          */
858         if (!ret && count != 2) {
859                 printk(KERN_CONT "Ksym tracer startup test failed");
860                 ret = -1;
861         }
862
863 ret_path:
864         return ret;
865 }
866 #endif /* CONFIG_KSYM_TRACER */
867