* Re: [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code [not found] ` <20190709174744.dtbjm72cbu5fepar@treble> @ 2019-07-09 18:02 ` Alexei Starovoitov 2019-07-09 19:17 ` Josh Poimboeuf 0 siblings, 1 reply; 3+ messages in thread From: Alexei Starovoitov @ 2019-07-09 18:02 UTC (permalink / raw) To: Josh Poimboeuf Cc: Ingo Molnar, Thomas Gleixner, Steven Rostedt, Kairui Song, Daniel Borkmann, Peter Zijlstra, LKML, bpf On Tue, Jul 9, 2019 at 10:48 AM Josh Poimboeuf <jpoimboe@redhat.com> 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 <ast@kerrnel.org> or Daniel can take it into bpf tree while I'm traveling. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code 2019-07-09 18:02 ` [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code Alexei Starovoitov @ 2019-07-09 19:17 ` Josh Poimboeuf 2019-07-09 19:26 ` Daniel Borkmann 0 siblings, 1 reply; 3+ messages in thread From: Josh Poimboeuf @ 2019-07-09 19:17 UTC (permalink / raw) To: Alexei Starovoitov Cc: Ingo Molnar, Thomas Gleixner, Steven Rostedt, Kairui Song, Daniel Borkmann, Peter Zijlstra, LKML, bpf On Tue, Jul 09, 2019 at 11:02:40AM -0700, Alexei Starovoitov wrote: > On Tue, Jul 9, 2019 at 10:48 AM Josh Poimboeuf <jpoimboe@redhat.com> 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 <ast@kerrnel.org> > > 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code 2019-07-09 19:17 ` Josh Poimboeuf @ 2019-07-09 19:26 ` Daniel Borkmann 0 siblings, 0 replies; 3+ messages in thread From: Daniel Borkmann @ 2019-07-09 19:26 UTC (permalink / raw) To: Josh Poimboeuf, Alexei Starovoitov Cc: Ingo Molnar, Thomas Gleixner, Steven Rostedt, Kairui Song, Peter Zijlstra, LKML, bpf 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 <jpoimboe@redhat.com> 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 <ast@kerrnel.org> >> >> 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! ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-09 19:27 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <tip-b22cf36c189f31883ad0238a69ccf82aa1f3b16b@git.kernel.org> [not found] ` <20190706202942.GA123403@gmail.com> [not found] ` <20190707013206.don22x3tfldec4zm@treble> [not found] ` <20190707055209.xqyopsnxfurhrkxw@treble> [not found] ` <CAADnVQJqT8o=_6P6xHjwxrXqX9ToSb0cTfoOcm2Xcha3KRNNSw@mail.gmail.com> [not found] ` <20190708223834.zx7u45a4uuu2yyol@treble> [not found] ` <CAADnVQKWDvzsvyjGoFvSQV7VGr2hF2zzCsC9vnpncWMxOJWYdw@mail.gmail.com> [not found] ` <20190708225359.ewk44pvrv6a4oao7@treble> [not found] ` <20190708230201.mol27wzansuy3n2v@treble> [not found] ` <CAADnVQ+imsK-reGBiSzY02e+KdyGYZxm1su7T1bWvti=YmSV-Q@mail.gmail.com> [not found] ` <20190709174744.dtbjm72cbu5fepar@treble> 2019-07-09 18:02 ` [tip:x86/urgent] bpf: Fix ORC unwinding in non-JIT BPF code Alexei Starovoitov 2019-07-09 19:17 ` Josh Poimboeuf 2019-07-09 19:26 ` Daniel Borkmann
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).