Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8271880ybi; Tue, 9 Jul 2019 12:22:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0UpBWa/T3mZE9fPshpFDJf1f0P9Y9U3c8XIj3NN2a8tJk/d3M9wRCIlxO+E5eNQLOHzxX X-Received: by 2002:a17:90a:8c0c:: with SMTP id a12mr1854445pjo.67.1562700163636; Tue, 09 Jul 2019 12:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562700163; cv=none; d=google.com; s=arc-20160816; b=NtEKIY4gFtnevHb5wDr5Nm9knzpLt0v0NlZ+MA6cox9nBpQ4X3jBtRqJ8pOW4km8lp gDN3z7rVx7m7q9JmqFJXuFLGtE9J82mmsv/LtU1A8TpfQCdP5xLStQeBvYfOqJIgWTht 6WZOz5mue9UIuH0UhLPDmdevWowQAXo4Jv/4KrtG8BMMjeOyvhvv6WhNg8tW4sAv5n6V wVmLFJq5pyRrSVCksm7t8xCkFdNftg6LeJ40o5L+UnIV5R0qV4ZQWJEHhDg5DjBgkOWS 6wLZXIf93q0Rx3VzHDA/H0ip9aUK4E52tz5juTnuMY+Ihh6VgE5kj65zPddUUgx6Zynv 7l0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=3yoBPyG5wO8+cqRUaLckcUM9hiLW6XervLlrsnEXBps=; b=jz0xncYSj1HjCMtIK2hkuk6e6rTPkc9Neqtt7ULPwy0LAIr3bhFv7KcBcxHA4W9cBp ZQBf2q3+GE4PyIwXc8SBBWDZCMZY0V2KA04MaXZTRKiFFqqCqdinPNPHvkEl0PRlRXug 5Hg82UYEyfRNHDJXkKqCjra/ZuvMfBkGslXSsLZCmEk/PkHWgUmtIan8dJSdsbj18k3Q m9FUsE+t+hD7DUOfAptWW0FON8z9cy1KlYDyPGqUegOTFJ3wTQng+3m+QaBx59Tu/DcN HzRUvJl2X0S5pyBqmUwIMnfC9OF87VkQBcU+CNrd42tw0zd/Rxo6DKDHipEe4+vEeKsa xlcw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10si25774054pgw.494.2019.07.09.12.22.28; Tue, 09 Jul 2019 12:22:43 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbfGITR4 (ORCPT + 99 others); Tue, 9 Jul 2019 15:17:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56670 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbfGITR4 (ORCPT ); Tue, 9 Jul 2019 15:17:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A952E30821AE; Tue, 9 Jul 2019 19:17:55 +0000 (UTC) Received: from treble (ovpn-112-43.rdu2.redhat.com [10.10.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CFD15F9A6; Tue, 9 Jul 2019 19:17:53 +0000 (UTC) Date: Tue, 9 Jul 2019 14:17:51 -0500 From: Josh Poimboeuf To: Alexei Starovoitov Cc: Ingo Molnar , Thomas Gleixner , Steven Rostedt , Kairui Song , Daniel Borkmann , Peter Zijlstra , LKML , bpf Subject: Re: [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code Message-ID: <20190709191751.24eq5zx2c7hoqot6@treble> References: <20190707013206.don22x3tfldec4zm@treble> <20190707055209.xqyopsnxfurhrkxw@treble> <20190708223834.zx7u45a4uuu2yyol@treble> <20190708225359.ewk44pvrv6a4oao7@treble> <20190708230201.mol27wzansuy3n2v@treble> <20190709174744.dtbjm72cbu5fepar@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 09 Jul 2019 19:17:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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. -- Josh