Skip to content

Commit 1aa8d87

Browse files
Christoph Hellwigaxboe
authored andcommitted
blk-mq: move the !async handling out of __blk_mq_delay_run_hw_queue
Only blk_mq_run_hw_queue can call __blk_mq_delay_run_hw_queue with async=false, so move the handling there. With this __blk_mq_delay_run_hw_queue can be merged into blk_mq_delay_run_hw_queue. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20230413060651.694656-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent cd735e1 commit 1aa8d87

1 file changed

Lines changed: 13 additions & 27 deletions

File tree

block/blk-mq.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,41 +2212,19 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)
22122212
}
22132213

22142214
/**
2215-
* __blk_mq_delay_run_hw_queue - Run (or schedule to run) a hardware queue.
2215+
* blk_mq_delay_run_hw_queue - Run a hardware queue asynchronously.
22162216
* @hctx: Pointer to the hardware queue to run.
2217-
* @async: If we want to run the queue asynchronously.
22182217
* @msecs: Milliseconds of delay to wait before running the queue.
22192218
*
2220-
* If !@async, try to run the queue now. Else, run the queue asynchronously and
2221-
* with a delay of @msecs.
2219+
* Run a hardware queue asynchronously with a delay of @msecs.
22222220
*/
2223-
static void __blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async,
2224-
unsigned long msecs)
2221+
void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs)
22252222
{
2226-
if (!async && !(hctx->flags & BLK_MQ_F_BLOCKING)) {
2227-
if (cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)) {
2228-
__blk_mq_run_hw_queue(hctx);
2229-
return;
2230-
}
2231-
}
2232-
22332223
if (unlikely(blk_mq_hctx_stopped(hctx)))
22342224
return;
22352225
kblockd_mod_delayed_work_on(blk_mq_hctx_next_cpu(hctx), &hctx->run_work,
22362226
msecs_to_jiffies(msecs));
22372227
}
2238-
2239-
/**
2240-
* blk_mq_delay_run_hw_queue - Run a hardware queue asynchronously.
2241-
* @hctx: Pointer to the hardware queue to run.
2242-
* @msecs: Milliseconds of delay to wait before running the queue.
2243-
*
2244-
* Run a hardware queue asynchronously with a delay of @msecs.
2245-
*/
2246-
void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs)
2247-
{
2248-
__blk_mq_delay_run_hw_queue(hctx, true, msecs);
2249-
}
22502228
EXPORT_SYMBOL(blk_mq_delay_run_hw_queue);
22512229

22522230
/**
@@ -2274,8 +2252,16 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
22742252
need_run = !blk_queue_quiesced(hctx->queue) &&
22752253
blk_mq_hctx_has_pending(hctx));
22762254

2277-
if (need_run)
2278-
__blk_mq_delay_run_hw_queue(hctx, async, 0);
2255+
if (!need_run)
2256+
return;
2257+
2258+
if (async || (hctx->flags & BLK_MQ_F_BLOCKING) ||
2259+
!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)) {
2260+
blk_mq_delay_run_hw_queue(hctx, 0);
2261+
return;
2262+
}
2263+
2264+
__blk_mq_run_hw_queue(hctx);
22792265
}
22802266
EXPORT_SYMBOL(blk_mq_run_hw_queue);
22812267

0 commit comments

Comments
 (0)