]> www.infradead.org Git - nvme.git/commitdiff
blk-mq: register cpuhp callback after hctx is added to xarray table
authorMing Lei <ming.lei@redhat.com>
Fri, 6 Dec 2024 11:16:06 +0000 (19:16 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 6 Dec 2024 16:48:46 +0000 (09:48 -0700)
We need to retrieve 'hctx' from xarray table in the cpuhp callback, so the
callback should be registered after this 'hctx' is added to xarray table.

Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Newman <peternewman@google.com>
Cc: Babu Moger <babu.moger@amd.com>
Cc: Luck Tony <tony.luck@intel.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Tested-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20241206111611.978870-2-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index 424239c075e28c301d0d17e03bf114bc8f582780..a404465036de3fa7cffa430d99d57cdd32efb83d 100644 (file)
@@ -3824,16 +3824,11 @@ static int blk_mq_init_hctx(struct request_queue *q,
 {
        hctx->queue_num = hctx_idx;
 
-       if (!(hctx->flags & BLK_MQ_F_STACKING))
-               cpuhp_state_add_instance_nocalls(CPUHP_AP_BLK_MQ_ONLINE,
-                               &hctx->cpuhp_online);
-       cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD, &hctx->cpuhp_dead);
-
        hctx->tags = set->tags[hctx_idx];
 
        if (set->ops->init_hctx &&
            set->ops->init_hctx(hctx, set->driver_data, hctx_idx))
-               goto unregister_cpu_notifier;
+               goto fail;
 
        if (blk_mq_init_request(set, hctx->fq->flush_rq, hctx_idx,
                                hctx->numa_node))
@@ -3842,6 +3837,11 @@ static int blk_mq_init_hctx(struct request_queue *q,
        if (xa_insert(&q->hctx_table, hctx_idx, hctx, GFP_KERNEL))
                goto exit_flush_rq;
 
+       if (!(hctx->flags & BLK_MQ_F_STACKING))
+               cpuhp_state_add_instance_nocalls(CPUHP_AP_BLK_MQ_ONLINE,
+                               &hctx->cpuhp_online);
+       cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD, &hctx->cpuhp_dead);
+
        return 0;
 
  exit_flush_rq:
@@ -3850,8 +3850,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
  exit_hctx:
        if (set->ops->exit_hctx)
                set->ops->exit_hctx(hctx, hctx_idx);
- unregister_cpu_notifier:
-       blk_mq_remove_cpuhp(hctx);
+ fail:
        return -1;
 }