On Tue, 09 Aug 2011 07:00:27 +0200, Eric Dumazet wrote:
I tried this idea since its already an enum and all enum values are
handled in the switch, but all gcc versions I used still generate the
useless compare and branch (always predicted by modern CPU, so harmless
anyway ?)
Don't think so, the list is rather long - the CPU may not have any
indication. But strange that your gcc generate a conditional sequence of
cmp and conditional jump instruction instead of a jump table! Look at
commit 01f2f3f6ef4d076c, this is what I got after I refactored to an
_dense_ enum list.
(But this would need to use a larger kernel_sock_filter with not an u16
code, but the target address).
Not sure if the benefit is worth to try it. Can we avoid any cacheline
misses? I don't think so.
+ switch ((enum bpf_inst)fentry->code) {
That should not differ! Eric, sure that this do the trick?
Hagen