diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-03-19 21:48:26 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-21 11:16:25 -0400 |
commit | 3c289ba7c320560ee74979a8895141c829046a2d (patch) | |
tree | 293c9d1d931c06acf06998a6ea052193c0a8cf4e /kernel/trace | |
parent | 5006ea73f38caef6065d1136808413813271633f (diff) |
blktrace: remove blk_probe_mutex
blk_register_tracepoints() always returns 0, so make it return void,
thus we don't need to use blk_probe_mutex to protect blk_probes_ref.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <49C2F5EA.8060606@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/blktrace.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 73845b7968bb..223b92e77b3f 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -47,10 +47,9 @@ static struct tracer_flags blk_tracer_flags = { | |||
47 | }; | 47 | }; |
48 | 48 | ||
49 | /* Global reference count of probes */ | 49 | /* Global reference count of probes */ |
50 | static DEFINE_MUTEX(blk_probe_mutex); | ||
51 | static atomic_t blk_probes_ref = ATOMIC_INIT(0); | 50 | static atomic_t blk_probes_ref = ATOMIC_INIT(0); |
52 | 51 | ||
53 | static int blk_register_tracepoints(void); | 52 | static void blk_register_tracepoints(void); |
54 | static void blk_unregister_tracepoints(void); | 53 | static void blk_unregister_tracepoints(void); |
55 | 54 | ||
56 | /* | 55 | /* |
@@ -256,10 +255,8 @@ static void blk_trace_cleanup(struct blk_trace *bt) | |||
256 | free_percpu(bt->sequence); | 255 | free_percpu(bt->sequence); |
257 | free_percpu(bt->msg_data); | 256 | free_percpu(bt->msg_data); |
258 | kfree(bt); | 257 | kfree(bt); |
259 | mutex_lock(&blk_probe_mutex); | ||
260 | if (atomic_dec_and_test(&blk_probes_ref)) | 258 | if (atomic_dec_and_test(&blk_probes_ref)) |
261 | blk_unregister_tracepoints(); | 259 | blk_unregister_tracepoints(); |
262 | mutex_unlock(&blk_probe_mutex); | ||
263 | } | 260 | } |
264 | 261 | ||
265 | int blk_trace_remove(struct request_queue *q) | 262 | int blk_trace_remove(struct request_queue *q) |
@@ -471,13 +468,8 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | |||
471 | bt->pid = buts->pid; | 468 | bt->pid = buts->pid; |
472 | bt->trace_state = Blktrace_setup; | 469 | bt->trace_state = Blktrace_setup; |
473 | 470 | ||
474 | mutex_lock(&blk_probe_mutex); | 471 | if (atomic_add_return(1, &blk_probes_ref) == 1) |
475 | if (atomic_add_return(1, &blk_probes_ref) == 1) { | 472 | blk_register_tracepoints(); |
476 | ret = blk_register_tracepoints(); | ||
477 | if (ret) | ||
478 | goto probe_err; | ||
479 | } | ||
480 | mutex_unlock(&blk_probe_mutex); | ||
481 | 473 | ||
482 | ret = -EBUSY; | 474 | ret = -EBUSY; |
483 | old_bt = xchg(&q->blk_trace, bt); | 475 | old_bt = xchg(&q->blk_trace, bt); |
@@ -487,9 +479,6 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | |||
487 | } | 479 | } |
488 | 480 | ||
489 | return 0; | 481 | return 0; |
490 | probe_err: | ||
491 | atomic_dec(&blk_probes_ref); | ||
492 | mutex_unlock(&blk_probe_mutex); | ||
493 | err: | 482 | err: |
494 | if (bt) { | 483 | if (bt) { |
495 | if (bt->msg_file) | 484 | if (bt->msg_file) |
@@ -863,7 +852,7 @@ void blk_add_driver_data(struct request_queue *q, | |||
863 | } | 852 | } |
864 | EXPORT_SYMBOL_GPL(blk_add_driver_data); | 853 | EXPORT_SYMBOL_GPL(blk_add_driver_data); |
865 | 854 | ||
866 | static int blk_register_tracepoints(void) | 855 | static void blk_register_tracepoints(void) |
867 | { | 856 | { |
868 | int ret; | 857 | int ret; |
869 | 858 | ||
@@ -901,7 +890,6 @@ static int blk_register_tracepoints(void) | |||
901 | WARN_ON(ret); | 890 | WARN_ON(ret); |
902 | ret = register_trace_block_remap(blk_add_trace_remap); | 891 | ret = register_trace_block_remap(blk_add_trace_remap); |
903 | WARN_ON(ret); | 892 | WARN_ON(ret); |
904 | return 0; | ||
905 | } | 893 | } |
906 | 894 | ||
907 | static void blk_unregister_tracepoints(void) | 895 | static void blk_unregister_tracepoints(void) |
@@ -1099,11 +1087,8 @@ static void blk_tracer_print_header(struct seq_file *m) | |||
1099 | 1087 | ||
1100 | static void blk_tracer_start(struct trace_array *tr) | 1088 | static void blk_tracer_start(struct trace_array *tr) |
1101 | { | 1089 | { |
1102 | mutex_lock(&blk_probe_mutex); | ||
1103 | if (atomic_add_return(1, &blk_probes_ref) == 1) | 1090 | if (atomic_add_return(1, &blk_probes_ref) == 1) |
1104 | if (blk_register_tracepoints()) | 1091 | blk_register_tracepoints(); |
1105 | atomic_dec(&blk_probes_ref); | ||
1106 | mutex_unlock(&blk_probe_mutex); | ||
1107 | trace_flags &= ~TRACE_ITER_CONTEXT_INFO; | 1092 | trace_flags &= ~TRACE_ITER_CONTEXT_INFO; |
1108 | } | 1093 | } |
1109 | 1094 | ||
@@ -1118,10 +1103,8 @@ static int blk_tracer_init(struct trace_array *tr) | |||
1118 | static void blk_tracer_stop(struct trace_array *tr) | 1103 | static void blk_tracer_stop(struct trace_array *tr) |
1119 | { | 1104 | { |
1120 | trace_flags |= TRACE_ITER_CONTEXT_INFO; | 1105 | trace_flags |= TRACE_ITER_CONTEXT_INFO; |
1121 | mutex_lock(&blk_probe_mutex); | ||
1122 | if (atomic_dec_and_test(&blk_probes_ref)) | 1106 | if (atomic_dec_and_test(&blk_probes_ref)) |
1123 | blk_unregister_tracepoints(); | 1107 | blk_unregister_tracepoints(); |
1124 | mutex_unlock(&blk_probe_mutex); | ||
1125 | } | 1108 | } |
1126 | 1109 | ||
1127 | static void blk_tracer_reset(struct trace_array *tr) | 1110 | static void blk_tracer_reset(struct trace_array *tr) |