Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1416195 > unrolled thread
| Started by | "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> |
|---|---|
| First post | 2016-06-07 15:40 +0200 |
| Last post | 2016-06-11 07:50 +0200 |
| Articles | 6 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/6] eBPF JIT for PPC64 "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-06-07 15:40 +0200
[PATCH 3/6] ppc: bpf/jit: Introduce rotate immediate instructions "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-06-07 17:40 +0200
Re: [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-06-08 01:00 +0200
Re: [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-06-08 19:20 +0200
Re: [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-06-09 08:10 +0200
Re: [PATCH 0/6] eBPF JIT for PPC64 David Miller <davem@davemloft.net> - 2016-06-11 07:50 +0200
| From | "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-06-07 15:40 +0200 |
| Subject | [PATCH 0/6] eBPF JIT for PPC64 |
| Message-ID | <rHpoB-3hJ-11@gated-at.bofh.it> |
Implement extended BPF JIT for ppc64. We retain the classic BPF JIT for ppc32 and move ppc64 BE/LE to use the new JIT. Classic BPF filters will be converted to extended BPF (see convert_filter()) and JIT'ed with the new compiler. Most of the existing macros are retained and fixed/enhanced where appropriate. Patches 1-4 are geared towards this. Patch 5 breaks out the classic BPF JIT specifics into a separate bpf_jit32.h header file, while retaining all the generic instruction macros in bpf_jit.h. Patch 6 implements eBPF JIT for ppc64. Since the RFC patchset [1], powerpc JIT has now gained support for skb access helpers and now passes all tests in test_bpf.ko. Review comments on the RFC patches have been addressed (use of an ABI macro [2] and use of bpf_jit_binary_alloc()), along with a few other generic fixes and updates. Prominent TODOs: - implement BPF tail calls - support for BPF constant blinding Please note that patch [2] is a pre-requisite for this patchset, and is not yet upstream. - Naveen [1] http://thread.gmane.org/gmane.linux.kernel/2188694 [2] http://thread.gmane.org/gmane.linux.ports.ppc.embedded/96514 Naveen N. Rao (6): ppc: bpf/jit: Fix/enhance 32-bit Load Immediate implementation ppc: bpf/jit: Optimize 64-bit Immediate loads ppc: bpf/jit: Introduce rotate immediate instructions ppc: bpf/jit: A few cleanups ppc: bpf/jit: Isolate classic BPF JIT specifics into a separate header ppc: ebpf/jit: Implement JIT compiler for extended BPF arch/powerpc/Kconfig | 3 +- arch/powerpc/include/asm/asm-compat.h | 2 + arch/powerpc/include/asm/ppc-opcode.h | 22 +- arch/powerpc/net/Makefile | 4 + arch/powerpc/net/bpf_jit.h | 235 ++++----- arch/powerpc/net/bpf_jit32.h | 139 +++++ arch/powerpc/net/bpf_jit64.h | 102 ++++ arch/powerpc/net/bpf_jit_asm.S | 2 +- arch/powerpc/net/bpf_jit_asm64.S | 180 +++++++ arch/powerpc/net/bpf_jit_comp.c | 10 +- arch/powerpc/net/bpf_jit_comp64.c | 956 ++++++++++++++++++++++++++++++++++ 11 files changed, 1504 insertions(+), 151 deletions(-) create mode 100644 arch/powerpc/net/bpf_jit32.h create mode 100644 arch/powerpc/net/bpf_jit64.h create mode 100644 arch/powerpc/net/bpf_jit_asm64.S create mode 100644 arch/powerpc/net/bpf_jit_comp64.c -- 2.8.2
[toc] | [next] | [standalone]
| From | "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-06-07 17:40 +0200 |
| Subject | [PATCH 3/6] ppc: bpf/jit: Introduce rotate immediate instructions |
| Message-ID | <rHrgK-4rU-15@gated-at.bofh.it> |
| In reply to | #1416195 |
Since we will be using the rotate immediate instructions for extended BPF JIT, let's introduce macros for the same. And since the shift immediate operations use the rotate immediate instructions, let's redo those macros to use the newly introduced instructions. Cc: Matt Evans <matt@ozlabs.org> Cc: Denis Kirjanov <kda@linux-powerpc.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Paul Mackerras <paulus@samba.org> Cc: Alexei Starovoitov <ast@fb.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> --- arch/powerpc/include/asm/ppc-opcode.h | 2 ++ arch/powerpc/net/bpf_jit.h | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h index 1d035c1..fd8d640 100644 --- a/arch/powerpc/include/asm/ppc-opcode.h +++ b/arch/powerpc/include/asm/ppc-opcode.h @@ -272,6 +272,8 @@ #define __PPC_SH(s) __PPC_WS(s) #define __PPC_MB(s) (((s) & 0x1f) << 6) #define __PPC_ME(s) (((s) & 0x1f) << 1) +#define __PPC_MB64(s) (__PPC_MB(s) | ((s) & 0x20)) +#define __PPC_ME64(s) __PPC_MB64(s) #define __PPC_BI(s) (((s) & 0x1f) << 16) #define __PPC_CT(t) (((t) & 0x0f) << 21) diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h index 4c1e055..95d0e38 100644 --- a/arch/powerpc/net/bpf_jit.h +++ b/arch/powerpc/net/bpf_jit.h @@ -210,18 +210,20 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh); ___PPC_RS(a) | ___PPC_RB(s)) #define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | ___PPC_RA(d) | \ ___PPC_RS(a) | ___PPC_RB(s)) +#define PPC_RLWINM(d, a, i, mb, me) EMIT(PPC_INST_RLWINM | ___PPC_RA(d) | \ + ___PPC_RS(a) | __PPC_SH(i) | \ + __PPC_MB(mb) | __PPC_ME(me)) +#define PPC_RLDICR(d, a, i, me) EMIT(PPC_INST_RLDICR | ___PPC_RA(d) | \ + ___PPC_RS(a) | __PPC_SH(i) | \ + __PPC_ME64(me) | (((i) & 0x20) >> 4)) + /* slwi = rlwinm Rx, Ry, n, 0, 31-n */ -#define PPC_SLWI(d, a, i) EMIT(PPC_INST_RLWINM | ___PPC_RA(d) | \ - ___PPC_RS(a) | __PPC_SH(i) | \ - __PPC_MB(0) | __PPC_ME(31-(i))) +#define PPC_SLWI(d, a, i) PPC_RLWINM(d, a, i, 0, 31-(i)) /* srwi = rlwinm Rx, Ry, 32-n, n, 31 */ -#define PPC_SRWI(d, a, i) EMIT(PPC_INST_RLWINM | ___PPC_RA(d) | \ - ___PPC_RS(a) | __PPC_SH(32-(i)) | \ - __PPC_MB(i) | __PPC_ME(31)) +#define PPC_SRWI(d, a, i) PPC_RLWINM(d, a, 32-(i), i, 31) /* sldi = rldicr Rx, Ry, n, 63-n */ -#define PPC_SLDI(d, a, i) EMIT(PPC_INST_RLDICR | ___PPC_RA(d) | \ - ___PPC_RS(a) | __PPC_SH(i) | \ - __PPC_MB(63-(i)) | (((i) & 0x20) >> 4)) +#define PPC_SLDI(d, a, i) PPC_RLDICR(d, a, i, 63-(i)) + #define PPC_NEG(d, a) EMIT(PPC_INST_NEG | ___PPC_RT(d) | ___PPC_RA(a)) /* Long jump; (unconditional 'branch') */ -- 2.8.2
[toc] | [prev] | [next] | [standalone]
| From | Alexei Starovoitov <alexei.starovoitov@gmail.com> |
|---|---|
| Date | 2016-06-08 01:00 +0200 |
| Subject | Re: [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF |
| Message-ID | <rHy8y-dV-1@gated-at.bofh.it> |
| In reply to | #1416195 |
On Tue, Jun 07, 2016 at 07:02:23PM +0530, Naveen N. Rao wrote: > PPC64 eBPF JIT compiler. > > Enable with: > echo 1 > /proc/sys/net/core/bpf_jit_enable > or > echo 2 > /proc/sys/net/core/bpf_jit_enable > > ... to see the generated JIT code. This can further be processed with > tools/net/bpf_jit_disasm. > > With CONFIG_TEST_BPF=m and 'modprobe test_bpf': > test_bpf: Summary: 305 PASSED, 0 FAILED, [297/297 JIT'ed] > > ... on both ppc64 BE and LE. Nice. That's even better than on x64 which cannot jit one test: test_bpf: #262 BPF_MAXINSNS: Jump, gap, jump, ... jited:0 168 PASS which was designed specifically to hit x64 jit pass limit. ppc jit has predicatble number of passes and doesn't have this problem as expected. Great. > The details of the approach are documented through various comments in > the code. > > Cc: Matt Evans <matt@ozlabs.org> > Cc: Denis Kirjanov <kda@linux-powerpc.org> > Cc: Michael Ellerman <mpe@ellerman.id.au> > Cc: Paul Mackerras <paulus@samba.org> > Cc: Alexei Starovoitov <ast@fb.com> > Cc: Daniel Borkmann <daniel@iogearbox.net> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> > --- > arch/powerpc/Kconfig | 3 +- > arch/powerpc/include/asm/asm-compat.h | 2 + > arch/powerpc/include/asm/ppc-opcode.h | 20 +- > arch/powerpc/net/Makefile | 4 + > arch/powerpc/net/bpf_jit.h | 53 +- > arch/powerpc/net/bpf_jit64.h | 102 ++++ > arch/powerpc/net/bpf_jit_asm64.S | 180 +++++++ > arch/powerpc/net/bpf_jit_comp64.c | 956 ++++++++++++++++++++++++++++++++++ > 8 files changed, 1317 insertions(+), 3 deletions(-) > create mode 100644 arch/powerpc/net/bpf_jit64.h > create mode 100644 arch/powerpc/net/bpf_jit_asm64.S > create mode 100644 arch/powerpc/net/bpf_jit_comp64.c don't see any issues with the code. Thank you for working on this. Acked-by: Alexei Starovoitov <ast@kernel.org>
[toc] | [prev] | [next] | [standalone]
| From | "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-06-08 19:20 +0200 |
| Subject | Re: [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF |
| Message-ID | <rHPj4-30z-7@gated-at.bofh.it> |
| In reply to | #1416704 |
On 2016/06/07 03:56PM, Alexei Starovoitov wrote: > On Tue, Jun 07, 2016 at 07:02:23PM +0530, Naveen N. Rao wrote: > > PPC64 eBPF JIT compiler. > > > > Enable with: > > echo 1 > /proc/sys/net/core/bpf_jit_enable > > or > > echo 2 > /proc/sys/net/core/bpf_jit_enable > > > > ... to see the generated JIT code. This can further be processed with > > tools/net/bpf_jit_disasm. > > > > With CONFIG_TEST_BPF=m and 'modprobe test_bpf': > > test_bpf: Summary: 305 PASSED, 0 FAILED, [297/297 JIT'ed] > > > > ... on both ppc64 BE and LE. > > Nice. That's even better than on x64 which cannot jit one test: > test_bpf: #262 BPF_MAXINSNS: Jump, gap, jump, ... jited:0 168 PASS > which was designed specifically to hit x64 jit pass limit. > ppc jit has predicatble number of passes and doesn't have this problem > as expected. Great. Yes, that's thanks to the clever handling of conditional branches by Matt -- we always emit 2 instructions for this reason (encoded in PPC_BCC() macro). > > > The details of the approach are documented through various comments in > > the code. > > > > Cc: Matt Evans <matt@ozlabs.org> > > Cc: Denis Kirjanov <kda@linux-powerpc.org> > > Cc: Michael Ellerman <mpe@ellerman.id.au> > > Cc: Paul Mackerras <paulus@samba.org> > > Cc: Alexei Starovoitov <ast@fb.com> > > Cc: Daniel Borkmann <daniel@iogearbox.net> > > Cc: "David S. Miller" <davem@davemloft.net> > > Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> > > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> > > --- > > arch/powerpc/Kconfig | 3 +- > > arch/powerpc/include/asm/asm-compat.h | 2 + > > arch/powerpc/include/asm/ppc-opcode.h | 20 +- > > arch/powerpc/net/Makefile | 4 + > > arch/powerpc/net/bpf_jit.h | 53 +- > > arch/powerpc/net/bpf_jit64.h | 102 ++++ > > arch/powerpc/net/bpf_jit_asm64.S | 180 +++++++ > > arch/powerpc/net/bpf_jit_comp64.c | 956 ++++++++++++++++++++++++++++++++++ > > 8 files changed, 1317 insertions(+), 3 deletions(-) > > create mode 100644 arch/powerpc/net/bpf_jit64.h > > create mode 100644 arch/powerpc/net/bpf_jit_asm64.S > > create mode 100644 arch/powerpc/net/bpf_jit_comp64.c > > don't see any issues with the code. > Thank you for working on this. > > Acked-by: Alexei Starovoitov <ast@kernel.org> Thanks, Alexei! Regards, Naveen
[toc] | [prev] | [next] | [standalone]
| From | "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-06-09 08:10 +0200 |
| Subject | Re: [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF |
| Message-ID | <rI1kd-2sF-5@gated-at.bofh.it> |
| In reply to | #1416195 |
On 2016/06/08 10:19PM, Nilay Vaish wrote: > Naveen, can you point out where in the patch you update the variable: > idx, a member of codegen_contex structure? Somehow I am unable to > figure it out. I can only see that we set it to 0 in the > bpf_int_jit_compile function. Since all your test cases pass, I am > clearly overlooking something. Yes, that's being done in bpf_jit.h (see the earlier patches in the series). All the PPC_*() instruction macros are defined to EMIT() the respective powerpc instruction encoding. EMIT() translates to PLANT_INSTR(), which actually increments idx. - Naveen
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-06-11 07:50 +0200 |
| Message-ID | <rIJXX-7sE-3@gated-at.bofh.it> |
| In reply to | #1416195 |
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> Date: Tue, 7 Jun 2016 19:02:17 +0530 > Please note that patch [2] is a pre-requisite for this patchset, and is > not yet upstream. ... > [1] http://thread.gmane.org/gmane.linux.kernel/2188694 > [2] http://thread.gmane.org/gmane.linux.ports.ppc.embedded/96514 Because of #2 I don't think I can take this directly into the networking tree, right? Therefore, how would you like this to be merged?
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web