Skip to content

Commit

Permalink
ftrace: preemptoff selftest not working
Browse files Browse the repository at this point in the history
Impact: fix preemptoff and preemptirqsoff tracer self-tests

I was wondering why the preemptoff and preemptirqsoff tracer selftests
don't work on s390. After all its just that they get called from
non-preemptible context:

kernel_init() will execute all initcalls, however the first line in
kernel_init() is lock_kernel(), which causes the preempt_count to be
increased. Any later calls to add_preempt_count() (especially those
from the selftests) will therefore not result in a call to
trace_preempt_off() since the check below in add_preempt_count()
will be false:

        if (preempt_count() == val)
                trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));

Hence the trace buffer will be empty.

Fix this by releasing the BKL during the self-tests.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Heiko Carstens authored and Ingo Molnar committed Nov 18, 2008
1 parent 1c80025 commit a225063
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ int register_tracer(struct tracer *type)
}

#ifdef CONFIG_FTRACE_STARTUP_TEST
/*
* When this gets called we hold the BKL which means that preemption
* is disabled. Various trace selftests however need to disable
* and enable preemption for successful tests. So we drop the BKL here
* and grab it after the tests again.
*/
unlock_kernel();
if (type->selftest) {
struct tracer *saved_tracer = current_trace;
struct trace_array *tr = &global_trace;
Expand Down Expand Up @@ -562,6 +569,7 @@ int register_tracer(struct tracer *type)
}
printk(KERN_CONT "PASSED\n");
}
lock_kernel();
#endif

type->next = trace_types;
Expand Down

0 comments on commit a225063

Please sign in to comment.