Re: [PATCH 3/8] blk-mq: Use a pointer for sbitmap

Jens Axboe
2019-11-27T14:22:03Z

On 11/27/19 6:05 AM, John Garry wrote:
> On 27/11/2019 01:46, Jens Axboe wrote:
>>>> Would be interesting to check the generated code for that, ideally we'd
>>>> get rid of the extra load for that case, even if it is in the same
>>>> cacheline.
>>>>
>>> I checked the disassembly and we still have the load instead of the add.
>>>
>>> This is not surprising, as the compiler would not know for certain that
>>> we point to a field within the same struct. But at least we still should
>>> point to a close memory.
>>>
>>> Note that the pointer could be dropped, which would remove the load, but
>>> then we have many if-elses which could be slower, not to mention that
>>> the blk-mq-tag code deals in bitmap pointers anyway.
>
> Hi Jens,
>
>> It might still be worthwhile to do:
>>
>> if (tags->ptr == &tags->__default)
>> foo(&tags->__default);
>>
>> to make it clear, as that branch will predict easily.
>
> Not sure. So this code does produce the same assembly, as we still need
> to do the tags->ptr load for the comparison.

How can it be the same? The approach in the patchset needs to load
*tags->ptr, this one needs tags->ptr. That's the big difference.

--
Jens Axboe