Re: [PATCH] block/t10-pi: deduplicate blk_reftag_remap_{prepare,complete}()
From: Caleb Sander Mateos
Date: Fri Nov 20 2026 - 23:14:26 EST
On Fri, Nov 20, 2026 at 4:18 PM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
>
> On Fri, Nov 20, 2026 at 10:29:18AM -0800, Caleb Sander Mateos wrote:
> > Sure, happy to switch to an if statement instead of the ternaries to
> > initialize from and to. However, the code generation is worse with the
> > 2 calls to blk_reftag_remap()/blk_tuple_remap(). The compiler doesn't
> > notice that the calls are identical except for the swapped arguments
> > and emits 2 out-of-line calls to the function instead of inlining it.
>
> Add a __force_inline tag to blk_tuple_remap and see if that fixes it?
I mean, sure, you can apply __always_inline to blk_tuple_remap(),
blk_set_ext_remap_ref(), and blk_set_t10_remap_ref() to force them to
be inlined, but that doesn't change the fact that there are 2 separate
(inlined) calls to blk_tuple_remap(). That makes the generated
assembly for blk_integrity_remap() significantly longer. I don't think
compilers generally merge common pieces from if and else branches
(even if they can detect the common code, they may choose to keep
separate copies to improve branch prediction for any nested branches
correlated with the outer branch).
Best,
Caleb