diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2015-09-27 02:09:19 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-22 14:49:35 -0700 |
commit | 5781175fab1a2c8b0339644fb27d64bf24c9fda4 (patch) | |
tree | 11a7d16e69087e1d20573bc7de520978d0e5f80c | |
parent | 4e9415aadba0f966ac40b071695149b5e1a7aaa9 (diff) | |
download | lwn-5781175fab1a2c8b0339644fb27d64bf24c9fda4.tar.gz lwn-5781175fab1a2c8b0339644fb27d64bf24c9fda4.zip |
blk-mq: avoid setting hctx->tags->cpumask before allocation
commit 1356aae08338f1c19ce1c67bf8c543a267688fc3 upstream.
When unmapped hw queue is remapped after CPU topology is changed,
hctx->tags->cpumask has to be set after hctx->tags is setup in
blk_mq_map_swqueue(), otherwise it causes null pointer dereference.
Fixes: f26cdc8536 ("blk-mq: Shared tag enhancements")
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | block/blk-mq.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index 176262ec3731..c69902695136 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1807,7 +1807,6 @@ static void blk_mq_map_swqueue(struct request_queue *q) hctx = q->mq_ops->map_queue(q, i); cpumask_set_cpu(i, hctx->cpumask); - cpumask_set_cpu(i, hctx->tags->cpumask); ctx->index_hw = hctx->nr_ctx; hctx->ctxs[hctx->nr_ctx++] = ctx; } @@ -1847,6 +1846,14 @@ static void blk_mq_map_swqueue(struct request_queue *q) hctx->next_cpu = cpumask_first(hctx->cpumask); hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH; } + + queue_for_each_ctx(q, ctx, i) { + if (!cpu_online(i)) + continue; + + hctx = q->mq_ops->map_queue(q, i); + cpumask_set_cpu(i, hctx->tags->cpumask); + } } static void blk_mq_update_tag_set_depth(struct blk_mq_tag_set *set) |