blk-mq: setup queue ->tag_set before initializing hctx
PATCH 1/1 blk-mq: setup queue ->tag_set before initializing hctx
Commit 7b815817aa58 ("blk-mq: add helper for checking if one CPU is mapped to specified hctx") needs to check queue mapping via tag set in hctx's cpuhp handler.
However, q->tag_set may not be setup yet when the cpuhp handler is enabled, then kernel oops is triggered.
Fix the issue by setup queue tag_set before initializing hctx.
--- block/blk-mq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
block/blk-mq.c +6 -2
@@ -4310,6 +4310,12 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,/* mark the queue as mq asap */ q->mq_ops = set->ops; +/* +* ->tag_set has to be setup before initialize hctx, which cpuphp +* handler needs it for checking queue mapping +*/ + q->tag_set = set; +if (blk_mq_alloc_ctxs (q)) goto err_exit;
@@ -4328,8 +4334,6 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,INIT_WORK (&q->timeout_work, blk_mq_timeout_work);blk_queue_rq_timeout (q, set->timeout ? set->timeout :30 *HZ ); - q->tag_set = set; - q->queue_flags |=QUEUE_FLAG_MQ_DEFAULT ;INIT_DELAYED_WORK (&q->requeue_work, blk_mq_requeue_work);
Signature · 1 line
2.46.0
Quoted 1 line · Ming Lei
Commit
7b815817aa58("blk-mq: add helper for checking if one CPU is mapped to specified hctx")
Overly long line.
Otherwise looks good:
Quoted 6 lines · Ming Lei
Commit
7b815817aa58("blk-mq: add helper for checking if one CPU is mapped to specified hctx") needs to check queue mapping via tag set in hctx's cpuhp handler.However,
q->tag_setmay not be setup yet when the cpuhp handler is enabled, then kernel oops is triggered.
Quoted 6 lines
Fix the issue by setup queue
tag_setbefore initializing hctx.Reported-and-tested-by Rick Koch<[email protected]>Closes https://urldefense.com/v3/__https://lore.kernel.org/linux-block/ CANa58eeNDozLaBHKPLxSAhEy__FPfJT_F71W=sEQw49UCrC9PQ@mail.gmail.com__;!! ACWV5N9M2RV99hQ! I8rs4BE3PAgb5C75MUXZygt6Rmrgq1Nf9gHkileqLC5dagKa9zQ7aaFcJDNZkQwwCAKyu0RXanbmTtnTcwOR$ Fixes: 7b815817aa58 ("blk-mq: add helper for checking if one CPU is mapped to specified hctx")Signed-off-by Ming Lei<[email protected]>---
Quoted 9 lines · Ming Lei
Commit
7b815817aa58("blk-mq: add helper for checking if one CPU is mapped to specified hctx") needs to check queue mapping via tag set in hctx's cpuhp handler.However,
q->tag_setmay not be setup yet when the cpuhp handler is enabled, then kernel oops is triggered.Fix the issue by setup queue
tag_setbefore initializing hctx.[...]
Applied, thanks!
[1/1] blk-mq: setup queue ->tag_set before initializing hctx
commit: cd6279bd6e3c022bb74f88bd2299daf63ae519e6
Best regards,
Signature · 1 line
Jens Axboe