selftests/bpf: Using llvm may_goto inline asm for cond_break macro
Subsystems (3)
Yonghong Song
reviewerPATCH 1/1 selftests/bpf: Using llvm may_goto inline asm for cond_break macro
Currently, cond_break macro uses bytes to encode the may_goto insn. Patch [1] in llvm implemented may_goto insn in BPF backend. Replace byte-level encoding with llvm inline asm for better usability. Using llvm may_goto insn is controlled by macro __BPF_FEATURE_MAY_GOTO.
[1] https://github.com/llvm/llvm-project/commit/0e0bfacff71859d1f9212205f8f873d47029d3fb
--- tools/testing/selftests/bpf/bpf_experimental.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/testing/selftests/bpf/bpf_experimental.h +11 -0
@@ -326,6 +326,16 @@ l_true: \ })#endif +#ifdef __BPF_FEATURE_MAY_GOTO +#define cond_break \ + ({ __label__ l_break, l_continue; \ + asm volatile goto("may_goto %l[l_break]" \ + :::: l_break); \ + goto l_continue; \ + l_break: break; \ + l_continue:; \ + }) +#else #define cond_break \ ({ __label__ l_break, l_continue; \ asm volatile goto("1:.byte 0xe5; \
@@ -337,6 +347,7 @@ l_true: \ l_break:break ; \ l_continue:; \ }) +#endif #ifndef bpf_nop_mov#define bpf_nop_mov (var) \
Signature · 1 line
2.43.0
Quoted 45 lines · Yonghong Song
Currently,
cond_breakmacro uses bytes to encode themay_gotoinsn. Patch [1] in llvm implementedmay_gotoinsn in BPF backend. Replace byte-level encoding with llvm inline asm for better usability. Using llvmmay_gotoinsn is controlled by macro__BPF_FEATURE_MAY_GOTO.[1] https://github.com/llvm/llvm-project/commit/0e0bfacff71859d1f9212205f8f873d47029d3fb
Signed-off-by Yonghong Song <[email protected]>--- tools/testing/selftests/bpf/bpf_experimental.h | 11 +++++++++++ 1 file changed, 11 insertions(+)tools/testing/selftests/bpf/bpf_experimental.h +11
-0@@ -326,6 +326,16 @@ l_true: \ })#endif +#ifdef __BPF_FEATURE_MAY_GOTO +#define cond_break \ + ({ __label__ l_break, l_continue; \ + asm volatile goto("may_goto %l[l_break]" \ + :::: l_break); \ + goto l_continue; \ + l_break: break; \ + l_continue:; \ + }) +#else #define cond_break \ ({ __label__ l_break, l_continue; \ asm volatile goto("1:.byte 0xe5; \@@ -337,6 +347,7 @@ l_true: \ l_break:break ; \ l_continue:; \ }) +#endif #ifndef bpf_nop_mov#define bpf_nop_mov (var) \Signature · 1 line
2.43.0
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Mon, 1 Apr 2024 19:54:46 -0700 you wrote:
Currently,
cond_breakmacro uses bytes to encode themay_gotoinsn. Patch [1] in llvm implementedmay_gotoinsn in BPF backend. Replace byte-level encoding with llvm inline asm for better usability. Using llvmmay_gotoinsn is controlled by macro__BPF_FEATURE_MAY_GOTO.[1] https://github.com/llvm/llvm-project/commit/0e0bfacff71859d1f9212205f8f873d47029d3fb
[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Using llvm may_goto inline asm for cond_break macro
https://git.kernel.org/bpf/bpf-next/c/965c6167c93f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html