From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Naveen N. Rao" 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 Message-ID: <1517165673.b6qwvzzvuf.naveen@linux.ibm.com> References: <20180126223348.11250-1-daniel@iogearbox.net> <20180126223348.11250-2-daniel@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT Cc: netdev@vger.kernel.org, Sandipan Das To: ast@kernel.org, Daniel Borkmann Return-path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53178 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752257AbeA1S7D (ORCPT ); Sun, 28 Jan 2018 13:59:03 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0SIwmW2103537 for ; Sun, 28 Jan 2018 13:59:03 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fsayu5s28-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 28 Jan 2018 13:59:02 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 28 Jan 2018 18:59:00 -0000 In-Reply-To: <20180126223348.11250-2-daniel@iogearbox.net> Sender: netdev-owner@vger.kernel.org List-ID: 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 > Acked-by: Alexei Starovoitov > --- > 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 > > >