Re: [PATCH 2/2] radix-tree: Fix optimisation problem

From: Linus Torvalds
Date: Thu Sep 22 2016 - 14:10:09 EST


On Thu, Sep 22, 2016 at 11:53 AM, Matthew Wilcox
<mawilcox@xxxxxxxxxxxxxxxxx> wrote:
>
> Change the test suite to compile with -O2, and
> fix the optimisation problem by passing 'entry' through entry_to_node()
> so gcc knows this isn't a plain pointer.

Ugh. I really don't like this patch very much.

Wouldn't it be cleaner to just fix "get_slot_offset()" instead? As it
is, looking at the code, I suspect that it's really hard to convince
people that there isn't some other place this might happen. Because
the "pointer subtraction followed by pointer addition" pattern is all
hidden in these inline functions.

Or at least add a big comment about why this is the only such case.

Because without that, the code now looks very bad.

Linus