mbox series

[bpf-next,v2,0/6] Zbb support and code simplification for RV64 JIT

Message ID 20230919035839.3297328-1-pulehui@huaweicloud.com (mailing list archive)
Headers show
Series Zbb support and code simplification for RV64 JIT | expand

Message

Pu Lehui Sept. 19, 2023, 3:58 a.m. UTC
Add Zbb support [0] to optimize code size and performance of RV64 JIT.
Meanwhile, adjust the code for unification and simplification. Tests
test_bpf.ko and test_verifier have passed, as well as the relative
testcases of test_progs*.

Link: https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf [0]

v2:
- Add runtime detection for Zbb instructions. (Conor Dooley)
- Correct formatting issues detected by checkpatch. (Simon Horman)

v1:
https://lore.kernel.org/bpf/20230913153413.1446068-1-pulehui@huaweicloud.com/

Pu Lehui (6):
  riscv, bpf: Unify 32-bit sign-extension to emit_sextw
  riscv, bpf: Unify 32-bit zero-extension to emit_zextw
  riscv, bpf: Simplify sext and zext logics in branch instructions
  riscv, bpf: Add necessary Zbb instructions
  riscv, bpf: Optimize sign-extention mov insns with Zbb support
  riscv, bpf: Optimize bswap insns with Zbb support

 arch/riscv/net/bpf_jit.h        | 124 +++++++++++++++++++
 arch/riscv/net/bpf_jit_comp64.c | 213 +++++++++++---------------------
 2 files changed, 195 insertions(+), 142 deletions(-)

Comments

Björn Töpel Sept. 26, 2023, 1:30 p.m. UTC | #1
Pu Lehui <pulehui@huaweicloud.com> writes:

> Add Zbb support [0] to optimize code size and performance of RV64 JIT.
> Meanwhile, adjust the code for unification and simplification. Tests
> test_bpf.ko and test_verifier have passed, as well as the relative
> testcases of test_progs*.

Apologies for the review delay. I'm travelling, and will pick it up ASAP
when I'm back.


Björn
Björn Töpel Sept. 28, 2023, 10:44 a.m. UTC | #2
Pu Lehui <pulehui@huaweicloud.com> writes:

> Add Zbb support [0] to optimize code size and performance of RV64 JIT.
> Meanwhile, adjust the code for unification and simplification. Tests
> test_bpf.ko and test_verifier have passed, as well as the relative
> testcases of test_progs*.

Nice work!

Did you measure how the instruction count changed for, say, test_bpf.ko
and test_progs?


Björn
Pu Lehui Jan. 15, 2024, 12:22 p.m. UTC | #3
On 2023/9/28 18:44, Björn Töpel wrote:
> Pu Lehui <pulehui@huaweicloud.com> writes:
> 
>> Add Zbb support [0] to optimize code size and performance of RV64 JIT.
>> Meanwhile, adjust the code for unification and simplification. Tests
>> test_bpf.ko and test_verifier have passed, as well as the relative
>> testcases of test_progs*.
> 
> Nice work!
> 
> Did you measure how the instruction count changed for, say, test_bpf.ko
> and test_progs? >

Sorry for not responding for so long.

I made statistics on the number of body instructions and the changes are 
as follows:

test_progs:
1. verifier_movsx: 260 -> 224
2. verifier_bswap: 180 -> 56

test_bpf.ko:
1. MOVSX: 154 -> 146
2. BSWAP: 336 -> 136

We can see that the change in BSWAP is obvious, and the change in MOVSX 
is in line with expectations.

> 
> Björn
Björn Töpel Jan. 16, 2024, 9:05 a.m. UTC | #4
Pu Lehui <pulehui@huaweicloud.com> writes:

> On 2023/9/28 18:44, Björn Töpel wrote:
>> Pu Lehui <pulehui@huaweicloud.com> writes:
>> 
>>> Add Zbb support [0] to optimize code size and performance of RV64 JIT.
>>> Meanwhile, adjust the code for unification and simplification. Tests
>>> test_bpf.ko and test_verifier have passed, as well as the relative
>>> testcases of test_progs*.
>> 
>> Nice work!
>> 
>> Did you measure how the instruction count changed for, say, test_bpf.ko
>> and test_progs? >
>
> Sorry for not responding for so long.

Welcome back!

> I made statistics on the number of body instructions and the changes are 
> as follows:
>
> test_progs:
> 1. verifier_movsx: 260 -> 224
> 2. verifier_bswap: 180 -> 56
>
> test_bpf.ko:
> 1. MOVSX: 154 -> 146
> 2. BSWAP: 336 -> 136
>
> We can see that the change in BSWAP is obvious, and the change in MOVSX 
> is in line with expectations.

Thank you. I'll test/review the v3 during the week!


Cheers,
Björn