All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: ast@kernel.org, netdev@vger.kernel.org,
	Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call()
Date: Mon, 29 Jan 2018 07:39:19 +0100	[thread overview]
Message-ID: <20180129063919.GA20230@1wt.eu> (raw)
In-Reply-To: <0f909080f2ef055783fc7b394e8111e0df3c4971.1517190206.git.daniel@iogearbox.net>

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

  reply	other threads:[~2018-01-29  6:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29  1:48 [PATCH stable 4.9 0/8] BPF stable patches Daniel Borkmann
2018-01-29  1:48 ` [PATCH stable 4.9 1/8] x86: bpf_jit: small optimization in emit_bpf_tail_call() Daniel Borkmann
2018-01-29  6:39   ` Willy Tarreau [this message]
2018-01-29 14:04     ` Eric Dumazet
2018-01-29 14:06       ` Willy Tarreau
2018-01-29 12:35   ` Patch "x86: bpf_jit: small optimization in emit_bpf_tail_call()" has been added to the 4.9-stable tree gregkh
2018-01-29  1:48 ` [PATCH stable 4.9 2/8] bpf: fix bpf_tail_call() x64 JIT Daniel Borkmann
2018-01-29 12:35   ` Patch "bpf: fix bpf_tail_call() x64 JIT" has been added to the 4.9-stable tree gregkh
2018-01-29  1:48 ` [PATCH stable 4.9 3/8] bpf: introduce BPF_JIT_ALWAYS_ON config Daniel Borkmann
2018-01-29 12:35   ` Patch "bpf: introduce BPF_JIT_ALWAYS_ON config" has been added to the 4.9-stable tree gregkh
2018-01-29  1:48 ` [PATCH stable 4.9 4/8] bpf: arsh is not supported in 32 bit alu thus reject it Daniel Borkmann
2018-01-29 12:34   ` Patch "bpf: arsh is not supported in 32 bit alu thus reject it" has been added to the 4.9-stable tree gregkh
2018-01-29  1:48 ` [PATCH stable 4.9 5/8] bpf: avoid false sharing of map refcount with max_entries Daniel Borkmann
2018-01-29 12:34   ` Patch "bpf: avoid false sharing of map refcount with max_entries" has been added to the 4.9-stable tree gregkh
2018-01-29  1:48 ` [PATCH stable 4.9 6/8] bpf: fix divides by zero Daniel Borkmann
2018-01-29 12:35   ` Patch "bpf: fix divides by zero" has been added to the 4.9-stable tree gregkh
2018-01-29  1:49 ` [PATCH stable 4.9 7/8] bpf: fix 32-bit divide by zero Daniel Borkmann
2018-01-29 12:34   ` Patch "bpf: fix 32-bit divide by zero" has been added to the 4.9-stable tree gregkh
2018-01-29  1:49 ` [PATCH stable 4.9 8/8] bpf: reject stores into ctx via st and xadd Daniel Borkmann
2018-01-29 12:35   ` Patch "bpf: reject stores into ctx via st and xadd" has been added to the 4.9-stable tree gregkh
2018-01-29 12:30 ` [PATCH stable 4.9 0/8] BPF stable patches Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180129063919.GA20230@1wt.eu \
    --to=w@1wt.eu \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.