diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 5f13f4d0bcce..9cb20d14c6b9 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -51,7 +51,10 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues) queue = 0; for_each_possible_cpu(i) { - if (!cpu_online(i)) { + /* + * Offline or full nohz CPUs get mapped to CPU0 + */ + if (blk_mq_cpu_offline(i)) { map[i] = 0; continue; } diff --git a/block/blk-mq.c b/block/blk-mq.c index b7b8933ec241..ec0de2871950 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -366,7 +366,7 @@ static void blk_mq_ipi_complete_request(struct request *rq) if (!test_bit(QUEUE_FLAG_SAME_FORCE, &rq->q->queue_flags)) shared = cpus_share_cache(cpu, ctx->cpu); - if (cpu != ctx->cpu && !shared && cpu_online(ctx->cpu)) { + if (cpu != ctx->cpu && !shared && !blk_mq_cpu_offline(ctx->cpu)) { rq->csd.func = __blk_mq_complete_request_remote; rq->csd.info = rq; rq->csd.flags = 0; @@ -1022,7 +1022,7 @@ void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx; current_ctx = blk_mq_get_ctx(q); - if (!cpu_online(ctx->cpu)) + if (blk_mq_cpu_offline(ctx->cpu)) rq->mq_ctx = ctx = current_ctx; hctx = q->mq_ops->map_queue(q, ctx->cpu); @@ -1051,7 +1051,7 @@ static void blk_mq_insert_requests(struct request_queue *q, current_ctx = blk_mq_get_ctx(q); - if (!cpu_online(ctx->cpu)) + if (blk_mq_cpu_offline(ctx->cpu)) ctx = current_ctx; hctx = q->mq_ops->map_queue(q, ctx->cpu); @@ -1757,7 +1757,7 @@ static void blk_mq_init_cpu_queues(struct request_queue *q, __ctx->queue = q; /* If the cpu isn't online, the cpu is mapped to first hctx */ - if (!cpu_online(i)) + if (blk_mq_cpu_offline(i)) continue; hctx = q->mq_ops->map_queue(q, i); @@ -1789,7 +1789,7 @@ static void blk_mq_map_swqueue(struct request_queue *q) */ queue_for_each_ctx(q, ctx, i) { /* If the cpu isn't online, the cpu is mapped to first hctx */ - if (!cpu_online(i)) + if (blk_mq_cpu_offline(i)) continue; hctx = q->mq_ops->map_queue(q, i); diff --git a/block/blk-mq.h b/block/blk-mq.h index 6a48c4c0d8a2..443dc8e0ea24 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -1,6 +1,8 @@ #ifndef INT_BLK_MQ_H #define INT_BLK_MQ_H +#include + struct blk_mq_tag_set; struct blk_mq_ctx { @@ -123,4 +125,13 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx) return hctx->nr_ctx && hctx->tags; } +/* + * If the CPU is offline or is a nohz CPU, we will remap any IO processing + * to the first hardware queue. + */ +static inline bool blk_mq_cpu_offline(const unsigned int cpu) +{ + return !cpu_online(cpu) || tick_nohz_full_cpu(cpu); +} + #endif