Received: by 10.213.65.68 with SMTP id h4csp908342imn; Tue, 27 Mar 2018 11:00:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/nwzVYsZ5xm9DVCpZJLX0PLkREBtguSCw0NOViWRqlKNj8+7l+eyMVNyW6/r9tH+fhHSfO X-Received: by 2002:a17:902:71cf:: with SMTP id t15-v6mr296912plm.107.1522173620231; Tue, 27 Mar 2018 11:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522173620; cv=none; d=google.com; s=arc-20160816; b=GAZeJTOdL552S/UXDrLMxLEFWCiYv7T/xSvHK9R7AYuorvuvmFz61d+2bBXWSerKI/ KN3LdG284JA5U0o1PSI5Tm/3N+zrZEZVcvmmvsQo/k1BeNHsU1+KGG9bNQbcZxpGTbv2 7oX0AFBN29ENI0DYJbM3pl3usDaOEvtLHO8B3FBmFxowFpE8S8GfguQ/zJYEoQpYnQgi KuYmexO96KVDX/ggs4QSGIY8zX8RcTy51sxCaIm0N3yXWtuaZo0kS/JB/JfAzxJ3TsDS Xg0RuzmhgFPTjg/ZqJ7HgjpeqkR2AEqCCCdhlB5qFbc2HRwypt2TAn01y4FuB3X76JuF cbmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Y/rzNjvVKXMvGdkchoroqo6xHdc48QqlvGIPTsHErgg=; b=G5DDMC0X0jw5jTkd/qvW2rgcsFOA6v8RcDfioB6YZLrLBlle3ZiRG2a1gwgvvrNiXp nT2H+xeOu6UpeimHaGx4td/sSO4VtoQ+2tQSPpY6d8AdKbfrS+VMBi9f65MzTF5Ga321 VlA3rt78c5dpq2gbs3aZ6xfBQe3NziMQlb3tVv6ftO/H8WtualZow0JpplHBiVd8ASPs DEFDscmx5FV0owKLKhDS5AhuiaKDaRN7hER2ycVSUNo91g04a59KixQL4KI9tjXMxk3c ZiMozsQGvoyHbMf5Swb5xXMhjxpDdjDmS5sHEMrlBtMZM2yCCNIhhcZ5KH0U3EdjC1zJ GMSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r25si1105908pge.759.2018.03.27.10.59.57; Tue, 27 Mar 2018 11:00:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753134AbeC0Qah (ORCPT + 99 others); Tue, 27 Mar 2018 12:30:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42032 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753068AbeC0Qaf (ORCPT ); Tue, 27 Mar 2018 12:30:35 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1DF4811EA; Tue, 27 Mar 2018 16:30:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Borkmann , Alexei Starovoitov , Eric Dumazet Subject: [PATCH 4.4 43/43] bpf, x64: increase number of passes Date: Tue, 27 Mar 2018 18:27:47 +0200 Message-Id: <20180327162718.802115307@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162716.407986916@linuxfoundation.org> References: <20180327162716.407986916@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann commit 6007b080d2e2adb7af22bf29165f0594ea12b34c upstream. 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 Acked-by: Alexei Starovoitov Reviewed-by: Eric Dumazet Signed-off-by: Alexei Starovoitov Signed-off-by: Greg Kroah-Hartman --- arch/x86/net/bpf_jit_comp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -1077,7 +1077,7 @@ void bpf_int_jit_compile(struct bpf_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; @@ -1100,6 +1100,7 @@ void bpf_int_jit_compile(struct bpf_prog goto out; } oldproglen = proglen; + cond_resched(); } if (bpf_jit_enable > 1)