]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/trace/trace_selftest.c
uwb: add WiMedia LLC Protocol (build system)
[linux-2.6-omap-h63xx.git] / kernel / trace / trace_selftest.c
index 546307de6e3d017bc867e64b5449b5d1bca0e70b..0911b7e073bf197b021ba77c75f6777a03910aa7 100644 (file)
@@ -3,11 +3,14 @@
 #include <linux/kthread.h>
 #include <linux/delay.h>
 
-static notrace inline int trace_valid_entry(struct trace_entry *entry)
+static inline int trace_valid_entry(struct trace_entry *entry)
 {
        switch (entry->type) {
        case TRACE_FN:
        case TRACE_CTX:
+       case TRACE_WAKE:
+       case TRACE_STACK:
+       case TRACE_SPECIAL:
                return 1;
        }
        return 0;
@@ -25,6 +28,7 @@ trace_test_buffer_cpu(struct trace_array *tr, struct trace_array_cpu *data)
        page = list_entry(data->trace_pages.next, struct page, lru);
        entries = page_address(page);
 
+       check_pages(data);
        if (head_page(data) != entries)
                goto failed;
 
@@ -79,10 +83,12 @@ trace_test_buffer_cpu(struct trace_array *tr, struct trace_array_cpu *data)
  */
 static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
 {
-       unsigned long cnt = 0;
-       int cpu;
-       int ret = 0;
+       unsigned long flags, cnt = 0;
+       int cpu, ret = 0;
 
+       /* Don't allow flipping of max traces now */
+       raw_local_irq_save(flags);
+       __raw_spin_lock(&ftrace_max_lock);
        for_each_possible_cpu(cpu) {
                if (!head_page(tr->data[cpu]))
                        continue;
@@ -93,6 +99,8 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
                if (ret)
                        break;
        }
+       __raw_spin_unlock(&ftrace_max_lock);
+       raw_local_irq_restore(flags);
 
        if (count)
                *count = cnt;
@@ -104,14 +112,8 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 
-#define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
 #define __STR(x) #x
 #define STR(x) __STR(x)
-static int DYN_FTRACE_TEST_NAME(void)
-{
-       /* used to call mcount */
-       return 0;
-}
 
 /* Test dynamic code modification and ftrace filters */
 int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
@@ -122,6 +124,7 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
        int ret;
        int save_ftrace_enabled = ftrace_enabled;
        int save_tracer_enabled = tracer_enabled;
+       char *func_name;
 
        /* The ftrace test PASSED */
        printk(KERN_CONT "PASSED\n");
@@ -141,9 +144,15 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
                return ret;
        }
 
+       /*
+        * Some archs *cough*PowerPC*cough* add charachters to the
+        * start of the function names. We simply put a '*' to
+        * accomodate them.
+        */
+       func_name = "*" STR(DYN_FTRACE_TEST_NAME);
+
        /* filter only on our function */
-       ftrace_set_filter(STR(DYN_FTRACE_TEST_NAME),
-                         sizeof(STR(DYN_FTRACE_TEST_NAME)), 1);
+       ftrace_set_filter(func_name, strlen(func_name), 1);
 
        /* enable tracing */
        tr->ctrl = 1;
@@ -179,7 +188,7 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
 
        /* we should only have one item */
        if (!ret && count != 1) {
-               printk(KERN_CONT ".. filter failed ..");
+               printk(KERN_CONT ".. filter failed count=%ld ..", count);
                ret = -1;
                goto out;
        }
@@ -409,11 +418,11 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
 #ifdef CONFIG_SCHED_TRACER
 static int trace_wakeup_test_thread(void *data)
 {
-       struct completion *x = data;
-
        /* Make this a RT thread, doesn't need to be too high */
+       struct sched_param param = { .sched_priority = 5 };
+       struct completion *x = data;
 
-       rt_mutex_setprio(current, MAX_RT_PRIO - 5);
+       sched_setscheduler(current, SCHED_FIFO, &param);
 
        /* Make it know we have a new prio */
        complete(x);
@@ -529,3 +538,26 @@ trace_selftest_startup_sched_switch(struct tracer *trace, struct trace_array *tr
        return ret;
 }
 #endif /* CONFIG_CONTEXT_SWITCH_TRACER */
+
+#ifdef CONFIG_SYSPROF_TRACER
+int
+trace_selftest_startup_sysprof(struct tracer *trace, struct trace_array *tr)
+{
+       unsigned long count;
+       int ret;
+
+       /* start the tracing */
+       tr->ctrl = 1;
+       trace->init(tr);
+       /* Sleep for a 1/10 of a second */
+       msleep(100);
+       /* stop the tracing. */
+       tr->ctrl = 0;
+       trace->ctrl_update(tr);
+       /* check the trace buffer */
+       ret = trace_test_buffer(tr, &count);
+       trace->reset(tr);
+
+       return ret;
+}
+#endif /* CONFIG_SYSPROF_TRACER */