netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>, ast@kernel.org
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH bpf] bpf, x64: increase number of passes
Date: Wed, 07 Mar 2018 13:42:59 -0800	[thread overview]
Message-ID: <1520458979.109662.55.camel@gmail.com> (raw)
In-Reply-To: <20180307211001.25449-1-daniel@iogearbox.net>

On Wed, 2018-03-07 at 22:10 +0100, Daniel Borkmann wrote:
> In Cilium some of the main programs we run today are hitting 9 passes
> on x64's JIT compiler, and we've had cases already where we surpassed
> the limit where the JIT then punts the program to the interpreter
> instead, leading to insertion failures due to
> CONFIG_BPF_JIT_ALWAYS_ON
> or insertion failures due to the prog array owner being JITed but the
> program to insert not (both must have the same JITed/non-JITed
> property).
> 
> One concrete case the program image shrunk from 12,767 bytes down to
> 10,288 bytes where the image converged after 16 steps. I've measured
> that this took 340us in the JIT until it converges on my i7-6600U.
> Thus,
> increase the original limit we had from day one where the JIT covered
> cBPF only back then before we run into the case (as similar with the
> complexity limit) where we trip over this and hit program rejections.
> Also add a cond_resched() into the compilation loop, the JIT process
> runs without any locks and may sleep anyway.
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> ---
>  arch/x86/net/bpf_jit_comp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/net/bpf_jit_comp.c
> b/arch/x86/net/bpf_jit_comp.c
> index 45e4eb5..ce5b2eb 100644
> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c
> @@ -1188,7 +1188,7 @@ struct bpf_prog *bpf_int_jit_compile(struct
> bpf_prog *prog)
>  	 * may converge on the last pass. In such case do one more
>  	 * pass to emit the final image
>  	 */
> -	for (pass = 0; pass < 10 || image; pass++) {
> +	for (pass = 0; pass < 20 || image; pass++) {
>  		proglen = do_jit(prog, addrs, image, oldproglen,
> &ctx);
>  		if (proglen <= 0) {
>  			image = NULL;
> @@ -1215,6 +1215,7 @@ struct bpf_prog *bpf_int_jit_compile(struct
> bpf_prog *prog)
>  			}
>  		}
>  		oldproglen = proglen;
> +		cond_resched();
>  	}
>  
>  	if (bpf_jit_enable > 1)

Thanks !

Reviewed-by: Eric Dumazet <edumazet@google.com>

  reply	other threads:[~2018-03-07 21:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 21:10 [PATCH bpf] bpf, x64: increase number of passes Daniel Borkmann
2018-03-07 21:42 ` Eric Dumazet [this message]
2018-03-07 22:48 ` 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=1520458979.109662.55.camel@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --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 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).