diff options
-rw-r--r-- | kernel/trace/blktrace.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 5b28f0f119c5..8d6bd12aab10 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -478,7 +478,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | |||
478 | goto err; | 478 | goto err; |
479 | } | 479 | } |
480 | 480 | ||
481 | if (atomic_add_return(1, &blk_probes_ref) == 1) | 481 | if (atomic_inc_return(&blk_probes_ref) == 1) |
482 | blk_register_tracepoints(); | 482 | blk_register_tracepoints(); |
483 | 483 | ||
484 | return 0; | 484 | return 0; |
@@ -1091,8 +1091,6 @@ static void blk_tracer_print_header(struct seq_file *m) | |||
1091 | 1091 | ||
1092 | static void blk_tracer_start(struct trace_array *tr) | 1092 | static void blk_tracer_start(struct trace_array *tr) |
1093 | { | 1093 | { |
1094 | if (atomic_add_return(1, &blk_probes_ref) == 1) | ||
1095 | blk_register_tracepoints(); | ||
1096 | trace_flags &= ~TRACE_ITER_CONTEXT_INFO; | 1094 | trace_flags &= ~TRACE_ITER_CONTEXT_INFO; |
1097 | } | 1095 | } |
1098 | 1096 | ||
@@ -1107,15 +1105,10 @@ static int blk_tracer_init(struct trace_array *tr) | |||
1107 | static void blk_tracer_stop(struct trace_array *tr) | 1105 | static void blk_tracer_stop(struct trace_array *tr) |
1108 | { | 1106 | { |
1109 | trace_flags |= TRACE_ITER_CONTEXT_INFO; | 1107 | trace_flags |= TRACE_ITER_CONTEXT_INFO; |
1110 | if (atomic_dec_and_test(&blk_probes_ref)) | ||
1111 | blk_unregister_tracepoints(); | ||
1112 | } | 1108 | } |
1113 | 1109 | ||
1114 | static void blk_tracer_reset(struct trace_array *tr) | 1110 | static void blk_tracer_reset(struct trace_array *tr) |
1115 | { | 1111 | { |
1116 | if (!atomic_read(&blk_probes_ref)) | ||
1117 | return; | ||
1118 | |||
1119 | blk_tracer_enabled = false; | 1112 | blk_tracer_enabled = false; |
1120 | blk_tracer_stop(tr); | 1113 | blk_tracer_stop(tr); |
1121 | } | 1114 | } |
@@ -1254,6 +1247,9 @@ static int blk_trace_remove_queue(struct request_queue *q) | |||
1254 | if (bt == NULL) | 1247 | if (bt == NULL) |
1255 | return -EINVAL; | 1248 | return -EINVAL; |
1256 | 1249 | ||
1250 | if (atomic_dec_and_test(&blk_probes_ref)) | ||
1251 | blk_unregister_tracepoints(); | ||
1252 | |||
1257 | kfree(bt); | 1253 | kfree(bt); |
1258 | return 0; | 1254 | return 0; |
1259 | } | 1255 | } |
@@ -1280,6 +1276,9 @@ static int blk_trace_setup_queue(struct request_queue *q, dev_t dev) | |||
1280 | return -EBUSY; | 1276 | return -EBUSY; |
1281 | } | 1277 | } |
1282 | 1278 | ||
1279 | if (atomic_inc_return(&blk_probes_ref) == 1) | ||
1280 | blk_register_tracepoints(); | ||
1281 | |||
1283 | return 0; | 1282 | return 0; |
1284 | } | 1283 | } |
1285 | 1284 | ||