From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>
Cc: linux-block@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH] blk-mq: fix kernel oops in blk_mq_tag_idle()
Date: Tue, 9 Jan 2018 08:29:56 -0700 [thread overview]
Message-ID: <20180109152954.GA5512@kernel.dk> (raw)
In-Reply-To: <20180109132829.31479-1-ming.lei@redhat.com>
On Tue, Jan 09 2018, Ming Lei wrote:
> HW queues may be unmapped in some cases, such as blk_mq_update_nr_hw_queues(),
> then we need to check it before calling blk_mq_tag_idle(), otherwise
> the following kernel oops can be triggered, so fix it by checking if
> the hw queue is unmapped since it doesn't make sense to idle the tags
> any more after hw queues are unmapped.
Seems cleaner to just move the mapped check to the idling function,
especially since we already have the same check in the other spot where
we call the idling.
diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h
index 61deab0b5a5a..10e7e1ef8297 100644
--- a/block/blk-mq-tag.h
+++ b/block/blk-mq-tag.h
@@ -63,6 +63,8 @@ static inline bool blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)
static inline void blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)
{
+ if (!blk_mq_hw_queue_mapped(hctx))
+ return;
if (!(hctx->flags & BLK_MQ_F_TAG_SHARED))
return;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 111e1aa5562f..4d9f79bfdca2 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -873,11 +873,8 @@ static void blk_mq_timeout_work(struct work_struct *work)
} else {
struct blk_mq_hw_ctx *hctx;
- queue_for_each_hw_ctx(q, hctx, i) {
- /* the hctx may be unmapped, so check it here */
- if (blk_mq_hw_queue_mapped(hctx))
- blk_mq_tag_idle(hctx);
- }
+ queue_for_each_hw_ctx(q, hctx, i)
+ blk_mq_tag_idle(hctx);
}
blk_queue_exit(q);
}
--
Jens Axboe
next prev parent reply other threads:[~2018-01-09 15:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 13:28 [PATCH] blk-mq: fix kernel oops in blk_mq_tag_idle() Ming Lei
2018-01-09 15:29 ` Jens Axboe [this message]
2018-01-09 15:38 ` Jens Axboe
2018-01-09 15:48 ` 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=20180109152954.GA5512@kernel.dk \
--to=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=yi.zhang@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).