From: Bart Van Assche <bvanassche@acm.org>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org>,
Mike Snitzer <snitzer@redhat.com>
Subject: Re: [PATCH] block: don't acquire .sysfs_lock before removing mq & iosched kobjects
Date: Fri, 16 Aug 2019 08:31:06 -0700 [thread overview]
Message-ID: <14a9ae85-0d65-483d-30f7-d692c4058e46@acm.org> (raw)
In-Reply-To: <20190816135506.29253-1-ming.lei@redhat.com>
On 8/16/19 6:55 AM, Ming Lei wrote:
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 977c659dcd18..46f033b48917 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -1021,6 +1021,7 @@ EXPORT_SYMBOL_GPL(blk_register_queue);
> void blk_unregister_queue(struct gendisk *disk)
> {
> struct request_queue *q = disk->queue;
> + bool has_elevator;
>
> if (WARN_ON(!q))
> return;
> @@ -1035,8 +1036,9 @@ void blk_unregister_queue(struct gendisk *disk)
> * concurrent elv_iosched_store() calls.
> */
> mutex_lock(&q->sysfs_lock);
> -
> blk_queue_flag_clear(QUEUE_FLAG_REGISTERED, q);
> + has_elevator = q->elevator;
> + mutex_unlock(&q->sysfs_lock);
blk_queue_flag_clear() modifies queue flags atomically so no need to
hold sysfs_lock around calls of that function.
> @@ -1044,16 +1046,13 @@ void blk_unregister_queue(struct gendisk *disk)
> */
> if (queue_is_mq(q))
> blk_mq_unregister_dev(disk_to_dev(disk), q);
> - mutex_unlock(&q->sysfs_lock);
>
> kobject_uevent(&q->kobj, KOBJ_REMOVE);
> kobject_del(&q->kobj);
> blk_trace_remove_sysfs(disk_to_dev(disk));
>
> - mutex_lock(&q->sysfs_lock);
> - if (q->elevator)
> + if (has_elevator)
> elv_unregister_queue(q);
> - mutex_unlock(&q->sysfs_lock);
Have you considered to move the q->elevator check into
elv_unregister_queue() such that no new 'has_elevator' variable has to
be introduced in this function?
Thanks,
Bart.
next prev parent reply other threads:[~2019-08-16 15:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 13:55 [PATCH] block: don't acquire .sysfs_lock before removing mq & iosched kobjects Ming Lei
2019-08-16 15:14 ` Bart Van Assche
2019-08-19 8:15 ` Ming Lei
2019-08-20 21:07 ` Bart Van Assche
2019-08-21 2:45 ` Ming Lei
2019-08-16 15:31 ` Bart Van Assche [this message]
2019-08-16 15:45 ` Ming Lei
2019-08-20 21:21 ` Bart Van Assche
2019-08-21 3:00 ` Ming Lei
2019-08-21 15:41 ` Bart Van Assche
2019-08-22 1:16 ` Ming Lei
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=14a9ae85-0d65-483d-30f7-d692c4058e46@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=snitzer@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).