]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/trace/trace_selftest.c
ftrace: start wakeup tracing after setting function tracer
[linux-2.6-omap-h63xx.git] / kernel / trace / trace_selftest.c
index a6f1ed75f8368f04f548d604a1b388b2a2e5637a..18c5423bc9777390c9442a5b461b5b67ba1d71f1 100644 (file)
@@ -8,6 +8,9 @@ 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;
        }
@@ -248,6 +257,10 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
        ftrace_enabled = save_ftrace_enabled;
        tracer_enabled = save_tracer_enabled;
 
+       /* kill ftrace totally if we failed */
+       if (ret)
+               ftrace_kill();
+
        return ret;
 }
 #endif /* CONFIG_FTRACE */
@@ -405,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);