From: Frederic Weisbecker <fweisbec@gmail.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>, Jens Axboe <jens.axboe@oracle.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/7] blktrace: remove blk_probe_mutex
Date: Fri, 20 Mar 2009 09:50:17 +0100 [thread overview]
Message-ID: <20090320085016.GB7820@nowhere> (raw)
In-Reply-To: <49C2F5EA.8060606@cn.fujitsu.com>
On Fri, Mar 20, 2009 at 09:48:26AM +0800, Li Zefan wrote:
> 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>
> ---
> 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 73845b7..223b92e 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -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);
>
> /*
> @@ -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)
> @@ -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)
atomic_inc_return() is a bit more simple.
> + blk_register_tracepoints();
>
> ret = -EBUSY;
> 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,
> }
>
> return 0;
> -probe_err:
> - atomic_dec(&blk_probes_ref);
> - mutex_unlock(&blk_probe_mutex);
> err:
> if (bt) {
> if (bt->msg_file)
> @@ -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;
>
> @@ -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)
> @@ -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;
> }
>
> @@ -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)
> --
> 1.5.4.rc3
>
Looks good.
next prev parent reply other threads:[~2009-03-20 8:50 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-20 1:47 [PATCH 0/7] blktrace: various cleanups and fixes Li Zefan
2009-03-20 1:47 ` [PATCH 1/7] blktrace: fix possible memory leak Li Zefan
2009-03-20 10:25 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 12:53 ` [PATCH 1/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:48 ` [PATCH 2/7] blktrace: make blk_tracer_enabled a bool flag Li Zefan
2009-03-20 8:47 ` Frederic Weisbecker
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 12:58 ` [PATCH 2/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:48 ` [PATCH 3/7] blktrace: remove blk_probe_mutex Li Zefan
2009-03-20 8:50 ` Frederic Weisbecker [this message]
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:03 ` [PATCH 3/7] " Arnaldo Carvalho de Melo
2009-03-22 6:04 ` Li Zefan
2009-03-22 15:09 ` Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:48 ` [PATCH 4/7] blktrace: don't increase blk_probes_ref if failed to setup blk trace Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:04 ` [PATCH 4/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:49 ` [PATCH 5/7] blktrace: report EBUSY correctly Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:10 ` [PATCH 5/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` Ingo Molnar
2009-03-21 15:19 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:49 ` [PATCH 6/7] blktrace: remove sysfs_blk_trace_enable_show/store() Li Zefan
2009-03-20 3:33 ` Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-21 15:19 ` Li Zefan
2009-03-20 13:07 ` [PATCH 6/7] " Arnaldo Carvalho de Melo
2009-03-20 1:49 ` [PATCH 7/7] blktrace: avoid accessing NULL bdev->bd_disk Li Zefan
2009-03-20 2:34 ` Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-21 15:19 ` Li Zefan
2009-03-20 13:08 ` [PATCH 7/7] " Arnaldo Carvalho de Melo
2009-03-20 10:20 ` [PATCH 0/7] blktrace: various cleanups and fixes Ingo Molnar
2009-03-20 11:09 ` Ingo Molnar
2009-03-23 14:48 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090320085016.GB7820@nowhere \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.