Re: [PATCH net-next-2.6] filter: optimize sk_run_filter

David Miller
2010-11-19T16:21:00Z

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 19 Nov 2010 12:17:52 +0100

> Le vendredi 19 novembre 2010 à 10:54 +0100, Eric Dumazet a écrit :
>
>> I believe we should revert the u32 f_k = fentry->k; part
>>
>> fentry->k as is fast as f_k if stored on stack, and avoids one
>> instruction if fentry->k is not needed.
>>
>>
>
> A revert is not good on arches with decent number of registers (x86_64
> for example).

-EFIX_THE_DAMN_COMPILER

We never make calls out of this function or touch volatile memory or
create a full memory barrier between the assignment of f_k and it's
uses.

Therefore if common sub-expression elimination is working the compiler
will be able to decide properly whether to access things via memory or
use a register for the value.

Remember this is why we have that ACCESS_ONCE() thing.

We can't have it both ways, either ACCESS_ONCE() should be removed or
we should never make changes like your's and instead should submit
compiler bug reports :-)