From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Jens Axboe <axboe@kernel.dk>, Ming Lei <tom.leiming@gmail.com>
Subject: [PATCH v3 4/7] blk-mq: fix q->mq_usage_counter access race
Date: Sun, 19 Jul 2015 01:28:20 +0900 [thread overview]
Message-ID: <1437236903-31617-5-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1437236903-31617-1-git-send-email-akinobu.mita@gmail.com>
CPU hotplug handling for blk-mq (blk_mq_queue_reinit) accesses
q->mq_usage_counter while freezing all request queues in all_q_list.
On the other hand, q->mq_usage_counter is deinitialized in
blk_mq_free_queue() before deleting the queue from all_q_list.
So if CPU hotplug event occurs in the window, percpu_ref_kill() is
called with q->mq_usage_counter which has already been marked dead,
and it triggers warning. Fix it by deleting the queue from all_q_list
earlier than destroying q->mq_usage_counter.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <tom.leiming@gmail.com>
---
block/blk-mq.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9328405..d5d93e0 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2077,15 +2077,16 @@ void blk_mq_free_queue(struct request_queue *q)
{
struct blk_mq_tag_set *set = q->tag_set;
+ mutex_lock(&all_q_mutex);
+ list_del_init(&q->all_q_node);
+ mutex_unlock(&all_q_mutex);
+
blk_mq_del_queue_tag_set(q);
blk_mq_exit_hw_queues(q, set, set->nr_hw_queues);
blk_mq_free_hw_queues(q, set);
percpu_ref_exit(&q->mq_usage_counter);
- mutex_lock(&all_q_mutex);
- list_del_init(&q->all_q_node);
- mutex_unlock(&all_q_mutex);
}
/* Basically redo blk_mq_init_queue with queue frozen */
--
1.9.1
next prev parent reply other threads:[~2015-07-18 16:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-18 16:28 [PATCH v3 0/7] blk-mq: fix race conditions on cpu hotplug handling Akinobu Mita
2015-07-18 16:28 ` [PATCH v3 1/7] blk-mq: avoid access hctx->tags->cpumask before allocation Akinobu Mita
2015-07-19 10:24 ` Ming Lei
2015-07-21 13:58 ` Akinobu Mita
2015-07-27 9:49 ` Ming Lei
2015-07-18 16:28 ` [PATCH v3 2/7] blk-mq: fix sysfs registration/unregistration race Akinobu Mita
2015-07-19 11:47 ` Ming Lei
2015-07-18 16:28 ` [PATCH v3 3/7] blk-mq: Fix use after of free q->mq_map Akinobu Mita
2015-07-18 16:28 ` Akinobu Mita [this message]
2015-07-18 16:28 ` [PATCH v3 5/7] blk-mq: avoid inserting requests before establishing new mapping Akinobu Mita
2015-07-19 12:12 ` Ming Lei
2015-07-18 16:28 ` [PATCH v3 6/7] blk-mq: fix freeze queue race Akinobu Mita
2015-07-19 12:12 ` Ming Lei
2015-07-18 16:28 ` [PATCH v3 7/7] blk-mq: fix deadlock when reading cpu_list Akinobu Mita
2015-07-19 12:30 ` Ming Lei
2015-07-28 8:10 ` Wanpeng Li
2015-07-28 23:37 ` Akinobu Mita
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=1437236903-31617-5-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.leiming@gmail.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
all inboxes | Powered by JetHome®