Re: [PATCH 2/2] blk-mq: ensure a q_usage_counter reference is held when splitting bios

Jens Axboe
2024-01-12T14:22:20Z

On 1/11/24 10:44 PM, Christoph Hellwig wrote:
> On Thu, Jan 11, 2024 at 01:06:43PM -0700, Jens Axboe wrote:
>> Something like this? Not super pretty with the duplication, but...
>> Should suffice for a fix, and then we can refactor it on top of that.
>> ioprio is inherited when cloning, so we don't need to do that post the
>> split.
>
> Yes, this could work. It'll get worse with anything we need to do under
> q_usage_counter counter, though. I mean, it is a perpcu_counter, which
> should be really light-weight compared to all the other stuff you do.
> I'd really love to see numbers that show it matters.

Yep it is pretty cheap, but it's not free. Here's a test where we just
grab a ref and drop it, which should arguably be cheaper than doing a
ref at the top and dropping it at the bottom due to temporal locality:

5.01% +0.86% [kernel.vmlinux] [k] blk_mq_submit_bio

>> Should
>> be set at init time and then never change. And agree would be so nice to
>> kill that code...
>
> I wish we could see some more folks from the mmc maintainers to do
> proper scatterlist (or bio/request) kmap helpers. The scsi drivers
> could easily piggy back on that or just be disabled for HIGHMEM configs.

Maybe we just nudge them that way by making them depend on !HIGHMEM...

--
Jens Axboe