Re: [PATCH] blk-mq: run the hw queue synchronously for unplugged scheduler inserts

From: Kaitao Cheng

Date: Wed Nov 18 2026 - 04:12:42 EST


在 2026/11/15 10:27, Qiliang Yuan 写道:
> Hi Kaitao,
>
> On Thu, Oct 29, 2026 at 09:09:19PM +0800, Kaitao Cheng wrote:
>> Our customer ran fio tests with --bs=4K --rw=randwrite --iodepth=1 --numjobs=1
>> and confirmed that adding bio plugging to __submit_bio() improves performance.
>>
>> Without bio plugging in __submit_bio():
>> fio:
>> __submit_bio (17.16%)
>> → blk_mq_submit_bio (16.80%)
>> → blk_mq_run_hw_queue (9.97%)
>> → blk_mq_delay_run_hw_queue (9.41%)
>> → kblockd_mod_delayed_work_on (9.13%)
> [...]
>> With bio plugging in __submit_bio():
>> __submit_bio (26.94%)
>> → __blk_flush_plug (21.36%)
>> → blk_mq_flush_plug_list (21.24%)
>> → blk_mq_flush_plug_list.part.0 (18.38%)
>> → blk_mq_run_hw_queue (15.34%)
>> → blk_mq_sched_dispatch_requests (14.55%)
> [...]
>> Adding bio plugging increased IOPS from 60,000 to 74,000 and reduced latency
>> from 12.4 µs to 9.5 µs.
>
> Thanks, this is the same pattern on NVMe with an I/O scheduler. Without
> the plug every request is dispatched by kblockd, with it the submitter
> dispatches the request itself through blk_mq_run_hw_queue(). This patch
> leaves __submit_bio() unplugged and runs the queue from the submitter
> for scheduler inserts, which should give the plugged profile without
> the plug.

I previously submitted a similar patch that went further, though the
implementation differs from yours. At the time, it was not intended
to address the plugging issue introduced by 9cbbac29d752.

For details, see:
https://lore.kernel.org/all/20261017105400.95967-1-kaitao.cheng@xxxxxxxxx/

> Could you run the same fio job on the unplugged kernel with this patch
> applied? Ming asked earlier whether real devices see a difference, so a
> Tested-by from an NVMe setup would help if it gets back to about 74K
> IOPS.
>

+Cc: zhuzongzhen

zhuzongzhen helped with the testing back then. I'm not sure whether he
still has the test environment available.

--
Thanks
Kaitao Cheng