diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-12-04 17:47:35 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-05 08:47:43 -0500 |
commit | ff32504fdc56407654584ef187b20022c94a3486 (patch) | |
tree | 71f265bbc27f603732e3791bb24896e450489083 /kernel/trace/trace.c | |
parent | 970987beb9c99ca806edc464518d411cc399fb4d (diff) |
tracing/ftrace: don't insert TRACE_PRINT during selftests
Impact: fix tracer selfstests false results
After setting a ftrace_printk somewhere in th kernel, I saw the
Function tracer selftest failing.
When a selftest occurs, the ring buffer is lurked to see if
some entries were inserted. But concurrent insertion such as
ftrace_printk could occured at the same time and could give
false positive or negative results.
This patch prevent prevent from TRACE_PRINT entries insertion
during selftests.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ea38652d631c..5dca6ef1fbeb 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -44,6 +44,14 @@ | |||
44 | unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX; | 44 | unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX; |
45 | unsigned long __read_mostly tracing_thresh; | 45 | unsigned long __read_mostly tracing_thresh; |
46 | 46 | ||
47 | /* We need to change this state when a selftest is running. | ||
48 | * A selftest will lurk into the ring-buffer to count the | ||
49 | * entries inserted during the selftest although some concurrent | ||
50 | * insertions into the ring-buffer such as ftrace_printk could occurred | ||
51 | * at the same time, giving false positive or negative results. | ||
52 | */ | ||
53 | static atomic_t tracing_selftest_running = ATOMIC_INIT(0); | ||
54 | |||
47 | /* For tracers that don't implement custom flags */ | 55 | /* For tracers that don't implement custom flags */ |
48 | static struct tracer_opt dummy_tracer_opt[] = { | 56 | static struct tracer_opt dummy_tracer_opt[] = { |
49 | { } | 57 | { } |
@@ -589,6 +597,8 @@ int register_tracer(struct tracer *type) | |||
589 | struct tracer *saved_tracer = current_trace; | 597 | struct tracer *saved_tracer = current_trace; |
590 | struct trace_array *tr = &global_trace; | 598 | struct trace_array *tr = &global_trace; |
591 | int i; | 599 | int i; |
600 | |||
601 | atomic_set(&tracing_selftest_running, 1); | ||
592 | /* | 602 | /* |
593 | * Run a selftest on this tracer. | 603 | * Run a selftest on this tracer. |
594 | * Here we reset the trace buffer, and set the current | 604 | * Here we reset the trace buffer, and set the current |
@@ -603,6 +613,7 @@ int register_tracer(struct tracer *type) | |||
603 | /* the test is responsible for initializing and enabling */ | 613 | /* the test is responsible for initializing and enabling */ |
604 | pr_info("Testing tracer %s: ", type->name); | 614 | pr_info("Testing tracer %s: ", type->name); |
605 | ret = type->selftest(type, tr); | 615 | ret = type->selftest(type, tr); |
616 | atomic_set(&tracing_selftest_running, 0); | ||
606 | /* the test is responsible for resetting too */ | 617 | /* the test is responsible for resetting too */ |
607 | current_trace = saved_tracer; | 618 | current_trace = saved_tracer; |
608 | if (ret) { | 619 | if (ret) { |
@@ -3594,7 +3605,7 @@ int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) | |||
3594 | unsigned long flags, irq_flags; | 3605 | unsigned long flags, irq_flags; |
3595 | int cpu, len = 0, size, pc; | 3606 | int cpu, len = 0, size, pc; |
3596 | 3607 | ||
3597 | if (tracing_disabled) | 3608 | if (tracing_disabled || atomic_read(&tracing_selftest_running)) |
3598 | return 0; | 3609 | return 0; |
3599 | 3610 | ||
3600 | pc = preempt_count(); | 3611 | pc = preempt_count(); |