From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [PATCH bpf-next 01/13] bpf: xor of a/x in cbpf can be done Date: Sun, 28 Jan 2018 21:51:37 +0100 Message-ID: <754bf668-2151-5a5c-c03d-b97c7da012a5@iogearbox.net> References: <20180126223348.11250-1-daniel@iogearbox.net> <20180126223348.11250-2-daniel@iogearbox.net> <1517165673.b6qwvzzvuf.naveen@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, Sandipan Das To: "Naveen N. Rao" , ast@kernel.org Return-path: Received: from www62.your-server.de ([213.133.104.62]:35037 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751867AbeA1Uvs (ORCPT ); Sun, 28 Jan 2018 15:51:48 -0500 In-Reply-To: <1517165673.b6qwvzzvuf.naveen@linux.ibm.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 01/28/2018 07:58 PM, Naveen N. Rao wrote: > 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. Right, I think one way to optimize this could be on JIT level in such case when CPU doesn't have subregs. There is the bpf_prog_was_classic() helper that can be used there in order to skip some of the bpf_alu32_trunc goto cases e.g. for some of the bit ops as an example, since we know that upper part in cBPF must be zero here anyway, this should definitely be a low hanging fruit given we use alu32 in the cBPF to eBPF conversion in a lot of places. Thanks, Daniel