* Re: [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call() [not found] ` <0f909080f2ef055783fc7b394e8111e0df3c4971.1517190206.git.daniel@iogearbox.net> @ 2018-01-29 6:39 ` Willy Tarreau 2018-01-29 14:04 ` Eric Dumazet 0 siblings, 1 reply; 3+ messages in thread From: Willy Tarreau @ 2018-01-29 6:39 UTC (permalink / raw) To: Daniel Borkmann; +Cc: ast, netdev, Eric Dumazet, David S . Miller Hi, [ replaced stable@ and greg@ by netdev@ as my question below is not relevant to stable ] On Mon, Jan 29, 2018 at 02:48:54AM +0100, Daniel Borkmann wrote: > From: Eric Dumazet <edumazet@google.com> > > [ upstream commit 84ccac6e7854ebbfb56d2fc6d5bef9be49bb304c ] > > Saves 4 bytes replacing following instructions : > > lea rax, [rsi + rdx * 8 + offsetof(...)] > mov rax, qword ptr [rax] > cmp rax, 0 > > by : > > mov rax, [rsi + rdx * 8 + offsetof(...)] > test rax, rax I've just noticed this on stable@. If these 4 bytes matter, why not use cmpq with an immediate value instead, which saves 2 extra bytes ? : - the mov above is 11 bytes total : 0: 48 8b 84 d6 78 56 34 mov 0x12345678(%rsi,%rdx,8),%rax 7: 12 8: 48 85 c0 test %rax,%rax - the equivalent cmp is only 9 bytes : 0: 48 83 bc d6 78 56 34 cmpq $0x0,0x12345678(%rsi,%rdx,8) 7: 12 00 And as a bonus, it doesn't even clobber rax. Just my two cents, Willy ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call() 2018-01-29 6:39 ` [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call() Willy Tarreau @ 2018-01-29 14:04 ` Eric Dumazet 2018-01-29 14:06 ` Willy Tarreau 0 siblings, 1 reply; 3+ messages in thread From: Eric Dumazet @ 2018-01-29 14:04 UTC (permalink / raw) To: Willy Tarreau Cc: Daniel Borkmann, Alexei Starovoitov, netdev, David S . Miller On Sun, Jan 28, 2018 at 10:39 PM, Willy Tarreau <w@1wt.eu> wrote: > Hi, > > [ replaced stable@ and greg@ by netdev@ as my question below is not > relevant to stable ] > > On Mon, Jan 29, 2018 at 02:48:54AM +0100, Daniel Borkmann wrote: >> From: Eric Dumazet <edumazet@google.com> >> >> [ upstream commit 84ccac6e7854ebbfb56d2fc6d5bef9be49bb304c ] >> >> Saves 4 bytes replacing following instructions : >> >> lea rax, [rsi + rdx * 8 + offsetof(...)] >> mov rax, qword ptr [rax] >> cmp rax, 0 >> >> by : >> >> mov rax, [rsi + rdx * 8 + offsetof(...)] >> test rax, rax > > I've just noticed this on stable@. If these 4 bytes matter, why not use > cmpq with an immediate value instead, which saves 2 extra bytes ? : > > - the mov above is 11 bytes total : > > 0: 48 8b 84 d6 78 56 34 mov 0x12345678(%rsi,%rdx,8),%rax > 7: 12 > 8: 48 85 c0 test %rax,%rax > > - the equivalent cmp is only 9 bytes : > > 0: 48 83 bc d6 78 56 34 cmpq $0x0,0x12345678(%rsi,%rdx,8) > 7: 12 00 > > And as a bonus, it doesn't even clobber rax. > > Just my two cents, Hi Willy Please look more closely at following instructions. We need the value later, not only testing it being zero :) ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call() 2018-01-29 14:04 ` Eric Dumazet @ 2018-01-29 14:06 ` Willy Tarreau 0 siblings, 0 replies; 3+ messages in thread From: Willy Tarreau @ 2018-01-29 14:06 UTC (permalink / raw) To: Eric Dumazet Cc: Daniel Borkmann, Alexei Starovoitov, netdev, David S . Miller Hi Eric, On Mon, Jan 29, 2018 at 06:04:30AM -0800, Eric Dumazet wrote: > > If these 4 bytes matter, why not use > > cmpq with an immediate value instead, which saves 2 extra bytes ? : > > > > - the mov above is 11 bytes total : > > > > 0: 48 8b 84 d6 78 56 34 mov 0x12345678(%rsi,%rdx,8),%rax > > 7: 12 > > 8: 48 85 c0 test %rax,%rax > > > > - the equivalent cmp is only 9 bytes : > > > > 0: 48 83 bc d6 78 56 34 cmpq $0x0,0x12345678(%rsi,%rdx,8) > > 7: 12 00 > > > > And as a bonus, it doesn't even clobber rax. > > > > Just my two cents, > > > Hi Willy > > Please look more closely at following instructions. > > We need the value later, not only testing it being zero :) Ah OK that makes total sense then ;-) Thanks, willy ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-29 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1517190206.git.daniel@iogearbox.net>
[not found] ` <0f909080f2ef055783fc7b394e8111e0df3c4971.1517190206.git.daniel@iogearbox.net>
2018-01-29 6:39 ` [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call() Willy Tarreau
2018-01-29 14:04 ` Eric Dumazet
2018-01-29 14:06 ` Willy Tarreau
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).