Skip to content

Commit

Permalink
blktrace: remove blk_probe_mutex
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Mar 21, 2009
1 parent 5006ea7 commit 3c289ba
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions kernel/trace/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ static struct tracer_flags blk_tracer_flags = {
};

/* Global reference count of probes */
static DEFINE_MUTEX(blk_probe_mutex);
static atomic_t blk_probes_ref = ATOMIC_INIT(0);

static int blk_register_tracepoints(void);
static void blk_register_tracepoints(void);
static void blk_unregister_tracepoints(void);

/*
Expand Down Expand Up @@ -256,10 +255,8 @@ static void blk_trace_cleanup(struct blk_trace *bt)
free_percpu(bt->sequence);
free_percpu(bt->msg_data);
kfree(bt);
mutex_lock(&blk_probe_mutex);
if (atomic_dec_and_test(&blk_probes_ref))
blk_unregister_tracepoints();
mutex_unlock(&blk_probe_mutex);
}

int blk_trace_remove(struct request_queue *q)
Expand Down Expand Up @@ -471,13 +468,8 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
bt->pid = buts->pid;
bt->trace_state = Blktrace_setup;

mutex_lock(&blk_probe_mutex);
if (atomic_add_return(1, &blk_probes_ref) == 1) {
ret = blk_register_tracepoints();
if (ret)
goto probe_err;
}
mutex_unlock(&blk_probe_mutex);
if (atomic_add_return(1, &blk_probes_ref) == 1)
blk_register_tracepoints();

ret = -EBUSY;
old_bt = xchg(&q->blk_trace, bt);
Expand All @@ -487,9 +479,6 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
}

return 0;
probe_err:
atomic_dec(&blk_probes_ref);
mutex_unlock(&blk_probe_mutex);
err:
if (bt) {
if (bt->msg_file)
Expand Down Expand Up @@ -863,7 +852,7 @@ void blk_add_driver_data(struct request_queue *q,
}
EXPORT_SYMBOL_GPL(blk_add_driver_data);

static int blk_register_tracepoints(void)
static void blk_register_tracepoints(void)
{
int ret;

Expand Down Expand Up @@ -901,7 +890,6 @@ static int blk_register_tracepoints(void)
WARN_ON(ret);
ret = register_trace_block_remap(blk_add_trace_remap);
WARN_ON(ret);
return 0;
}

static void blk_unregister_tracepoints(void)
Expand Down Expand Up @@ -1099,11 +1087,8 @@ static void blk_tracer_print_header(struct seq_file *m)

static void blk_tracer_start(struct trace_array *tr)
{
mutex_lock(&blk_probe_mutex);
if (atomic_add_return(1, &blk_probes_ref) == 1)
if (blk_register_tracepoints())
atomic_dec(&blk_probes_ref);
mutex_unlock(&blk_probe_mutex);
blk_register_tracepoints();
trace_flags &= ~TRACE_ITER_CONTEXT_INFO;
}

Expand All @@ -1118,10 +1103,8 @@ static int blk_tracer_init(struct trace_array *tr)
static void blk_tracer_stop(struct trace_array *tr)
{
trace_flags |= TRACE_ITER_CONTEXT_INFO;
mutex_lock(&blk_probe_mutex);
if (atomic_dec_and_test(&blk_probes_ref))
blk_unregister_tracepoints();
mutex_unlock(&blk_probe_mutex);
}

static void blk_tracer_reset(struct trace_array *tr)
Expand Down

0 comments on commit 3c289ba

Please sign in to comment.