Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8276376ybi; Tue, 9 Jul 2019 12:28:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLL2lkosEgcpRGX7vSzMzkUZlEB6Rtuob1C1WssHc//erBhDUCwegDhzpTLkKqogl7sFMj X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr27352757plm.306.1562700518983; Tue, 09 Jul 2019 12:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562700518; cv=none; d=google.com; s=arc-20160816; b=FUGm0GZ4KV44swb1O4dW5Dt+D+jiEYYbqdqWukOR5diRjoyQA/3/z1Vz5KFwYwyw+2 ObKW8BJDQIR2XmzLWJ1ccEoDWe429Nk9TIGkoS6Zngufat291MN3vCq3o/pTYRDD2w4a H/d05jogwCOKyv6VKI1ZBVyOvLhNetgVVb83uhyOb8rL8hGwS9xtCbSMVZq1vc32PHuR j+tUwapn3VCi8kyEMpmm7TCXmx5cLOh/KdCxwRS+UZ3/v2ownU2ld6QMVN4XvbuEG0xZ 8dQ6a8jIOCkwe1jfB+02bIyt0+W0cqJz3g1uE6ECpAhPnfBmIg8wHcMLhmjPrTlYKadl 4lZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=sc+wuR/2jL4NwCzYRp56z95ZIr1MNoHwydHPBn+nXU0=; b=MG8ISYzhn4riCGfn1JFMH3jK3USbinVz6UViEgEGUBWAcg1SX6j5x/pOAq2ciFcsxX OJ31PduFiMcg8mW+znyYiac8R5MXYcgIgcGMaJ1qkrsYH0lqkXtZxKesxS7kEXBqp5qM wJaHYAuP0wYVIAJvKq7p5bLudAerp4eeH0s08uUYVjEQ2lijT1ZWxIbTIfubaUdJyq1v lHyGfTUQvgN9flmdfrGSbne2GQu+TDSldJxoAaz9SeW26NGzwbvLsvr9hkvzIxI5RSnJ I1P3mA3ccTb9HlGD+Ux9F5hlKV9JIHLTpZn0BNB7N5dvGuv08CAaxD4kK8FrparIz0PR y3/Q== 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 q24si15749743pls.7.2019.07.09.12.28.23; Tue, 09 Jul 2019 12:28:38 -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 S1729047AbfGIT1g (ORCPT + 99 others); Tue, 9 Jul 2019 15:27:36 -0400 Received: from www62.your-server.de ([213.133.104.62]:40730 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbfGIT1g (ORCPT ); Tue, 9 Jul 2019 15:27:36 -0400 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1hkvlT-0001La-9D; Tue, 09 Jul 2019 21:26:59 +0200 Received: from [178.193.45.231] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hkvlT-0002W3-3L; Tue, 09 Jul 2019 21:26:59 +0200 Subject: Re: [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code To: Josh Poimboeuf , Alexei Starovoitov Cc: Ingo Molnar , Thomas Gleixner , Steven Rostedt , Kairui Song , Peter Zijlstra , LKML , bpf References: <20190707013206.don22x3tfldec4zm@treble> <20190707055209.xqyopsnxfurhrkxw@treble> <20190708223834.zx7u45a4uuu2yyol@treble> <20190708225359.ewk44pvrv6a4oao7@treble> <20190708230201.mol27wzansuy3n2v@treble> <20190709174744.dtbjm72cbu5fepar@treble> <20190709191751.24eq5zx2c7hoqot6@treble> From: Daniel Borkmann Message-ID: <47fc592d-08a0-a69a-89d0-603d47893656@iogearbox.net> Date: Tue, 9 Jul 2019 21:26:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20190709191751.24eq5zx2c7hoqot6@treble> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.3/25505/Tue Jul 9 10:07:53 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/09/2019 09:17 PM, Josh Poimboeuf wrote: > On Tue, Jul 09, 2019 at 11:02:40AM -0700, Alexei Starovoitov wrote: >> On Tue, Jul 9, 2019 at 10:48 AM Josh Poimboeuf wrote: >>> >>> On Mon, Jul 08, 2019 at 04:16:25PM -0700, Alexei Starovoitov wrote: >>>> total time is hard to compare. >>>> Could you compare few tests? >>>> like two that are called "tcpdump *" >>>> >>>> I think small regression is ok. >>>> Folks that care about performance should be using JIT. >>> >>> I did each test 20 times and computed the averages: >>> >>> "tcpdump port 22": >>> default: 0.00743175s >>> -fno-gcse: 0.00709920s (~4.5% speedup) >>> >>> "tcpdump complex": >>> default: 0.00876715s >>> -fno-gcse: 0.00854895s (~2.5% speedup) >>> >>> So there does seem to be a small performance gain by disabling this >>> optimization. >> >> great. thanks for checking. >> >>> We could change it for the whole file, by adjusting CFLAGS_core.o in the >>> BPF makefile, or we could change it for the function only with something >>> like the below patch. >>> >>> Thoughts? >>> >>> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h >>> index e8579412ad21..d7ee4c6bad48 100644 >>> --- a/include/linux/compiler-gcc.h >>> +++ b/include/linux/compiler-gcc.h >>> @@ -170,3 +170,5 @@ >>> #else >>> #define __diag_GCC_8(s) >>> #endif >>> + >>> +#define __no_fgcse __attribute__((optimize("-fno-gcse"))) >>> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h >>> index 095d55c3834d..599c27b56c29 100644 >>> --- a/include/linux/compiler_types.h >>> +++ b/include/linux/compiler_types.h >>> @@ -189,6 +189,10 @@ struct ftrace_likely_data { >>> #define asm_volatile_goto(x...) asm goto(x) >>> #endif >>> >>> +#ifndef __no_fgcse >>> +# define __no_fgcse >>> +#endif >>> + >>> /* Are two types/vars the same type (ignoring qualifiers)? */ >>> #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) >>> >>> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c >>> index 7e98f36a14e2..8191a7db2777 100644 >>> --- a/kernel/bpf/core.c >>> +++ b/kernel/bpf/core.c >>> @@ -1295,7 +1295,7 @@ bool bpf_opcode_in_insntable(u8 code) >>> * >>> * Decode and execute eBPF instructions. >>> */ >>> -static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, u64 *stack) >>> +static u64 __no_fgcse ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, u64 *stack) >> >> I prefer per-function flag. Same preference from my side. >> If you want to route it via tip: >> Acked-by: Alexei Starovoitov >> >> or Daniel can take it into bpf tree while I'm traveling. > > Thanks! I''ll probably send it through the tip tree, along with an > objtool fix for the other optimization. Ok, sounds good, thanks!