diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-12-05 21:41:33 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-08 09:11:44 -0500 |
commit | 8e1b82e0866befaa0b2920be296c6e4c3fc7f422 (patch) | |
tree | e1570ed8c1b671288d82897789a4891da45b13c8 | |
parent | 8b96f0119818964e4944fd1c423bf6770027d3ac (diff) |
tracing/function-graph-tracer: turn tracing_selftest_running into an int
Impact: cleanup
Apply some suggestions of Steven Rostedt:
_turn tracing_selftest_running into a simple int (no need of an atomic_t)
_set it __read_mostly
_fix a comment style
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/trace/trace.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 7a93c663e52a..33549537f30f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -44,13 +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. | 47 | /* |
48 | * We need to change this state when a selftest is running. | ||
48 | * A selftest will lurk into the ring-buffer to count the | 49 | * A selftest will lurk into the ring-buffer to count the |
49 | * entries inserted during the selftest although some concurrent | 50 | * entries inserted during the selftest although some concurrent |
50 | * insertions into the ring-buffer such as ftrace_printk could occurred | 51 | * insertions into the ring-buffer such as ftrace_printk could occurred |
51 | * at the same time, giving false positive or negative results. | 52 | * at the same time, giving false positive or negative results. |
52 | */ | 53 | */ |
53 | static atomic_t tracing_selftest_running = ATOMIC_INIT(0); | 54 | static bool __read_mostly tracing_selftest_running; |
54 | 55 | ||
55 | /* For tracers that don't implement custom flags */ | 56 | /* For tracers that don't implement custom flags */ |
56 | static struct tracer_opt dummy_tracer_opt[] = { | 57 | static struct tracer_opt dummy_tracer_opt[] = { |
@@ -574,6 +575,8 @@ int register_tracer(struct tracer *type) | |||
574 | unlock_kernel(); | 575 | unlock_kernel(); |
575 | mutex_lock(&trace_types_lock); | 576 | mutex_lock(&trace_types_lock); |
576 | 577 | ||
578 | tracing_selftest_running = true; | ||
579 | |||
577 | for (t = trace_types; t; t = t->next) { | 580 | for (t = trace_types; t; t = t->next) { |
578 | if (strcmp(type->name, t->name) == 0) { | 581 | if (strcmp(type->name, t->name) == 0) { |
579 | /* already found */ | 582 | /* already found */ |
@@ -598,7 +601,6 @@ int register_tracer(struct tracer *type) | |||
598 | struct trace_array *tr = &global_trace; | 601 | struct trace_array *tr = &global_trace; |
599 | int i; | 602 | int i; |
600 | 603 | ||
601 | atomic_set(&tracing_selftest_running, 1); | ||
602 | /* | 604 | /* |
603 | * Run a selftest on this tracer. | 605 | * Run a selftest on this tracer. |
604 | * Here we reset the trace buffer, and set the current | 606 | * Here we reset the trace buffer, and set the current |
@@ -613,7 +615,6 @@ int register_tracer(struct tracer *type) | |||
613 | /* the test is responsible for initializing and enabling */ | 615 | /* the test is responsible for initializing and enabling */ |
614 | pr_info("Testing tracer %s: ", type->name); | 616 | pr_info("Testing tracer %s: ", type->name); |
615 | ret = type->selftest(type, tr); | 617 | ret = type->selftest(type, tr); |
616 | atomic_set(&tracing_selftest_running, 0); | ||
617 | /* the test is responsible for resetting too */ | 618 | /* the test is responsible for resetting too */ |
618 | current_trace = saved_tracer; | 619 | current_trace = saved_tracer; |
619 | if (ret) { | 620 | if (ret) { |
@@ -635,6 +636,7 @@ int register_tracer(struct tracer *type) | |||
635 | max_tracer_type_len = len; | 636 | max_tracer_type_len = len; |
636 | 637 | ||
637 | out: | 638 | out: |
639 | tracing_selftest_running = false; | ||
638 | mutex_unlock(&trace_types_lock); | 640 | mutex_unlock(&trace_types_lock); |
639 | lock_kernel(); | 641 | lock_kernel(); |
640 | 642 | ||
@@ -3605,7 +3607,7 @@ int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) | |||
3605 | unsigned long flags, irq_flags; | 3607 | unsigned long flags, irq_flags; |
3606 | int cpu, len = 0, size, pc; | 3608 | int cpu, len = 0, size, pc; |
3607 | 3609 | ||
3608 | if (tracing_disabled || atomic_read(&tracing_selftest_running)) | 3610 | if (tracing_disabled || tracing_selftest_running) |
3609 | return 0; | 3611 | return 0; |
3610 | 3612 | ||
3611 | pc = preempt_count(); | 3613 | pc = preempt_count(); |