netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: ast@kernel.org, Daniel Borkmann <daniel@iogearbox.net>
Cc: netdev@vger.kernel.org, Sandipan Das <sandipan@linux.vnet.ibm.com>
Subject: Re: [PATCH bpf-next 01/13] bpf: xor of a/x in cbpf can be done
Date: Mon, 29 Jan 2018 00:28:57 +0530	[thread overview]
Message-ID: <1517165673.b6qwvzzvuf.naveen@linux.ibm.com> (raw)
In-Reply-To: <20180126223348.11250-2-daniel@iogearbox.net>

in 32 bit alu

Daniel Borkmann wrote:
> Very minor optimization; saves 1 byte per program in x86_64
> JIT in cBPF prologue.

... but increases program size by 4 bytes on ppc64 :(
In general, this is an area I've been wanting to spend some time on.  
Powerpc doesn't have 32-bit sub-registers, so we need to emit an 
additional instruction to clear the higher 32-bits for all 32-bit 
operations. I need to look at the performance impact.

- Naveen

> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> ---
>  net/core/filter.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 18da42a..cba2f73 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -401,8 +401,8 @@ static int bpf_convert_filter(struct sock_filter *prog, int len,
>  		/* Classic BPF expects A and X to be reset first. These need
>  		 * to be guaranteed to be the first two instructions.
>  		 */
> -		*new_insn++ = BPF_ALU64_REG(BPF_XOR, BPF_REG_A, BPF_REG_A);
> -		*new_insn++ = BPF_ALU64_REG(BPF_XOR, BPF_REG_X, BPF_REG_X);
> +		*new_insn++ = BPF_ALU32_REG(BPF_XOR, BPF_REG_A, BPF_REG_A);
> +		*new_insn++ = BPF_ALU32_REG(BPF_XOR, BPF_REG_X, BPF_REG_X);
>  
>  		/* All programs must keep CTX in callee saved BPF_REG_CTX.
>  		 * In eBPF case it's done by the compiler, here we need to
> -- 
> 2.9.5
> 
> 
> 

  reply	other threads:[~2018-01-28 18:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 22:33 [PATCH bpf-next 00/13] BPF improvements and fixes Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 01/13] bpf: xor of a/x in cbpf can be done in 32 bit alu Daniel Borkmann
2018-01-28 18:58   ` Naveen N. Rao [this message]
2018-01-28 20:51     ` [PATCH bpf-next 01/13] bpf: xor of a/x in cbpf can be done Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 02/13] bpf: improve dead code sanitizing Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 03/13] bpf: make unknown opcode handling more robust Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 04/13] bpf: fix subprog verifier bypass by div/mod by 0 exception Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 05/13] bpf, x86_64: remove obsolete exception handling from div/mod Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 06/13] bpf, arm64: " Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 07/13] bpf, s390x: " Daniel Borkmann
2018-01-29 14:33   ` Michael Holzheu
2018-01-29 15:52     ` Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 08/13] bpf, ppc64: " Daniel Borkmann
2018-01-28 18:52   ` Naveen N. Rao
2018-01-26 22:33 ` [PATCH bpf-next 09/13] bpf, sparc64: " Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 10/13] bpf, mips64: " Daniel Borkmann
2018-01-26 22:39   ` David Daney
2018-01-26 22:33 ` [PATCH bpf-next 11/13] bpf, mips64: remove unneeded zero check from div/mod with k Daniel Borkmann
2018-01-26 22:36   ` David Daney
2018-01-26 22:33 ` [PATCH bpf-next 12/13] bpf, arm: remove obsolete exception handling from div/mod Daniel Borkmann
2018-01-26 22:33 ` [PATCH bpf-next 13/13] bpf: add further test cases around div/mod and others Daniel Borkmann
2018-01-27  0:48 ` [PATCH bpf-next 00/13] BPF improvements and fixes Alexei Starovoitov

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=1517165673.b6qwvzzvuf.naveen@linux.ibm.com \
    --to=naveen.n.rao@linux.vnet.ibm.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=sandipan@linux.vnet.ibm.com \
    /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 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).