From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035602AbdEZP3a (ORCPT ); Fri, 26 May 2017 11:29:30 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:41438 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030511AbdEZP30 (ORCPT ); Fri, 26 May 2017 11:29:26 -0400 Date: Fri, 26 May 2017 11:29:24 -0400 (EDT) Message-Id: <20170526.112924.2288900171993979942.davem@davemloft.net> To: david.daney@cavium.com Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org, ralf@linux-mips.org, markos.chandras@imgtec.com Subject: Re: [PATCH 5/5] MIPS: Add support for eBPF JIT. From: David Miller In-Reply-To: <20170526003826.10834-6-david.daney@cavium.com> References: <20170526003826.10834-1-david.daney@cavium.com> <20170526003826.10834-6-david.daney@cavium.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 26 May 2017 07:47:51 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Daney Date: Thu, 25 May 2017 17:38:26 -0700 > +static int gen_int_prologue(struct jit_ctx *ctx) > +{ > + int stack_adjust = 0; > + int store_offset; > + int locals_size; > + > + if (ctx->flags & EBPF_SAVE_RA) > + /* > + * If RA we are doing a function call and may need > + * extra 8-byte tmp area. > + */ > + stack_adjust += 16; > + if (ctx->flags & EBPF_SAVE_S0) > + stack_adjust += 8; > + if (ctx->flags & EBPF_SAVE_S1) > + stack_adjust += 8; > + if (ctx->flags & EBPF_SAVE_S2) > + stack_adjust += 8; > + if (ctx->flags & EBPF_SAVE_S3) > + stack_adjust += 8; > + > + BUILD_BUG_ON(MAX_BPF_STACK & 7); > + locals_size = (ctx->flags & EBPF_SEEN_FP) ? MAX_BPF_STACK : 0; You will also need to use MAX_BPF_STACK here when you see a tail call, but it appears you haven't implemented tail call support yet. Which also several of the eBPF samples won't JIT and thus be tested under this new MIPS JIT, since they make use of tail calls. > +/* > + * Track the value range (i.e. 32-bit vs. 64-bit) of each register at > + * each eBPF insn. This allows unneeded sign and zero extension > + * operations to be omitted. > + * > + * Doesn't handle yet confluence of control paths with conflicting > + * ranges, but it is good enough for most sane code. > + */ > +static int reg_val_propagate(struct jit_ctx *ctx) Very interesting technique. I may adopt this for Sparc as well :-) Perhaps at a some point, when the BPF verifier has real data flow analysis, it can compute this for the JIT.