mbox series

[bpf-next,v1,0/4] Add BPF JIT support for LoongArch

Message ID 1660996260-11337-1-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
Headers show
Series Add BPF JIT support for LoongArch | expand

Message

Tiezhu Yang Aug. 20, 2022, 11:50 a.m. UTC
The basic support for LoongArch has been merged into the upstream Linux
kernel since 5.19-rc1 on June 5, 2022, this patch series adds BPF JIT
support for LoongArch.

Here is the LoongArch documention:
https://www.kernel.org/doc/html/latest/loongarch/index.html

With this patch series, the test cases in lib/test_bpf.ko have passed
on LoongArch.

  # echo 1 > /proc/sys/net/core/bpf_jit_enable
  # modprobe test_bpf
  # dmesg | grep Summary
  test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed]
  test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
  test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

It seems that this patch series can not be applied cleanly to bpf-next
which is not synced to v6.0-rc1.

v1:
  -- Rebased series on v6.0-rc1
  -- Move {signed,unsigned}_imm_check() to inst.h
  -- Define the imm field as "unsigned int" in the instruction format
  -- Use DEF_EMIT_*_FORMAT to define the same kind of instructions
  -- Use "stack_adjust += sizeof(long) * 8" in build_prologue()

RFC:
  https://lore.kernel.org/bpf/1660013580-19053-1-git-send-email-yangtiezhu@loongson.cn/

Tiezhu Yang (4):
  LoongArch: Move {signed,unsigned}_imm_check() to inst.h
  LoongArch: Add some instruction opcodes and formats
  LoongArch: Add BPF JIT support
  LoongArch: Enable BPF_JIT and TEST_BPF in default config

 arch/loongarch/Kbuild                      |    1 +
 arch/loongarch/Kconfig                     |    1 +
 arch/loongarch/configs/loongson3_defconfig |    2 +
 arch/loongarch/include/asm/inst.h          |  317 +++++++-
 arch/loongarch/kernel/module.c             |   10 -
 arch/loongarch/net/Makefile                |    7 +
 arch/loongarch/net/bpf_jit.c               | 1113 ++++++++++++++++++++++++++++
 arch/loongarch/net/bpf_jit.h               |  308 ++++++++
 8 files changed, 1744 insertions(+), 15 deletions(-)
 create mode 100644 arch/loongarch/net/Makefile
 create mode 100644 arch/loongarch/net/bpf_jit.c
 create mode 100644 arch/loongarch/net/bpf_jit.h

Comments

Tiezhu Yang Aug. 22, 2022, 1:36 a.m. UTC | #1
On 08/20/2022 07:50 PM, Tiezhu Yang wrote:
> The basic support for LoongArch has been merged into the upstream Linux
> kernel since 5.19-rc1 on June 5, 2022, this patch series adds BPF JIT
> support for LoongArch.
>
> Here is the LoongArch documention:
> https://www.kernel.org/doc/html/latest/loongarch/index.html
>
> With this patch series, the test cases in lib/test_bpf.ko have passed
> on LoongArch.
>
>   # echo 1 > /proc/sys/net/core/bpf_jit_enable
>   # modprobe test_bpf
>   # dmesg | grep Summary
>   test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed]
>   test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
>   test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED
>
> It seems that this patch series can not be applied cleanly to bpf-next
> which is not synced to v6.0-rc1.


Hi Alexei, Daniel, Andrii,

Do you know which tree this patch series will go through?
bpf-next or loongarch-next?

I will wait for some more review comments and then send v2
to fix the build warning in patch #3 reported by test robot.

Thanks,
Tiezhu

>
> v1:
>   -- Rebased series on v6.0-rc1
>   -- Move {signed,unsigned}_imm_check() to inst.h
>   -- Define the imm field as "unsigned int" in the instruction format
>   -- Use DEF_EMIT_*_FORMAT to define the same kind of instructions
>   -- Use "stack_adjust += sizeof(long) * 8" in build_prologue()
>
> RFC:
>   https://lore.kernel.org/bpf/1660013580-19053-1-git-send-email-yangtiezhu@loongson.cn/
>
> Tiezhu Yang (4):
>   LoongArch: Move {signed,unsigned}_imm_check() to inst.h
>   LoongArch: Add some instruction opcodes and formats
>   LoongArch: Add BPF JIT support
>   LoongArch: Enable BPF_JIT and TEST_BPF in default config
>
>  arch/loongarch/Kbuild                      |    1 +
>  arch/loongarch/Kconfig                     |    1 +
>  arch/loongarch/configs/loongson3_defconfig |    2 +
>  arch/loongarch/include/asm/inst.h          |  317 +++++++-
>  arch/loongarch/kernel/module.c             |   10 -
>  arch/loongarch/net/Makefile                |    7 +
>  arch/loongarch/net/bpf_jit.c               | 1113 ++++++++++++++++++++++++++++
>  arch/loongarch/net/bpf_jit.h               |  308 ++++++++
>  8 files changed, 1744 insertions(+), 15 deletions(-)
>  create mode 100644 arch/loongarch/net/Makefile
>  create mode 100644 arch/loongarch/net/bpf_jit.c
>  create mode 100644 arch/loongarch/net/bpf_jit.h
>
Alexei Starovoitov Aug. 23, 2022, 12:46 a.m. UTC | #2
On Sun, Aug 21, 2022 at 6:36 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
>
>
> On 08/20/2022 07:50 PM, Tiezhu Yang wrote:
> > The basic support for LoongArch has been merged into the upstream Linux
> > kernel since 5.19-rc1 on June 5, 2022, this patch series adds BPF JIT
> > support for LoongArch.
> >
> > Here is the LoongArch documention:
> > https://www.kernel.org/doc/html/latest/loongarch/index.html
> >
> > With this patch series, the test cases in lib/test_bpf.ko have passed
> > on LoongArch.
> >
> >   # echo 1 > /proc/sys/net/core/bpf_jit_enable
> >   # modprobe test_bpf
> >   # dmesg | grep Summary
> >   test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed]
> >   test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
> >   test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED
> >
> > It seems that this patch series can not be applied cleanly to bpf-next
> > which is not synced to v6.0-rc1.
>
>
> Hi Alexei, Daniel, Andrii,
>
> Do you know which tree this patch series will go through?
> bpf-next or loongarch-next?

Whichever way is easier.
Looks like all changes are contained within arch/loongarch,
so there should be no conflicts with generic JIT infra.
In that sense it's fine to carry it in loongarch-next.
We can take it through bpf-next too with arch maintainers acks.
Huacai Chen Aug. 23, 2022, 12:08 p.m. UTC | #3
Hi, all,

On Tue, Aug 23, 2022 at 8:46 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Sun, Aug 21, 2022 at 6:36 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >
> >
> >
> > On 08/20/2022 07:50 PM, Tiezhu Yang wrote:
> > > The basic support for LoongArch has been merged into the upstream Linux
> > > kernel since 5.19-rc1 on June 5, 2022, this patch series adds BPF JIT
> > > support for LoongArch.
> > >
> > > Here is the LoongArch documention:
> > > https://www.kernel.org/doc/html/latest/loongarch/index.html
> > >
> > > With this patch series, the test cases in lib/test_bpf.ko have passed
> > > on LoongArch.
> > >
> > >   # echo 1 > /proc/sys/net/core/bpf_jit_enable
> > >   # modprobe test_bpf
> > >   # dmesg | grep Summary
> > >   test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed]
> > >   test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
> > >   test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED
> > >
> > > It seems that this patch series can not be applied cleanly to bpf-next
> > > which is not synced to v6.0-rc1.
> >
> >
> > Hi Alexei, Daniel, Andrii,
> >
> > Do you know which tree this patch series will go through?
> > bpf-next or loongarch-next?
>
> Whichever way is easier.
> Looks like all changes are contained within arch/loongarch,
> so there should be no conflicts with generic JIT infra.
> In that sense it's fine to carry it in loongarch-next.
> We can take it through bpf-next too with arch maintainers acks.
OK, both ways look good to me.

Huacai