Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf, arm64: Optimize BPF store/load using str/ldr with immediate offset #2697

Closed
wants to merge 2 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: bpf, arm64: Optimize BPF store/load using str/ldr with immediate offset
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=622651

@kernel-patches-bot
Copy link
Author

Master branch: 6789ab9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622651
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: c09df4b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622651
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: d3b351f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=622651
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: d3b351f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=623094
version: 2

The current BPF store/load instruction is translated by the JIT into two
instructions. The first instruction moves the immediate offset into a
temporary register. The second instruction uses this temporary register
to do the real store/load.

In fact, arm64 supports addressing with immediate offsets. So This patch
introduces optimization that uses arm64 str/ldr instruction with immediate
offset when the offset fits.

Example of generated instuction for r2 = *(u64 *)(r1 + 0):

without optimization:
mov x10, 0
ldr x1, [x0, x10]

with optimization:
ldr x1, [x0, 0]

If the offset is negative, or is not aligned correctly, or exceeds max
value, rollback to the use of temporary register.

Result for test_bpf:
 # dmesg -D
 # insmod test_bpf.ko
 # dmesg | grep Summary
 test_bpf: Summary: 1009 PASSED, 0 FAILED, [997/997 JIT'ed]
 test_bpf: test_tail_calls: Summary: 8 PASSED, 0 FAILED, [8/8 JIT'ed]
 test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=623094 expired. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/622651=>bpf-next branch March 17, 2022 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant