]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: Remove 'may_goto 0' instruction in opt_remove_nops()
authorYonghong Song <yonghong.song@linux.dev>
Sat, 18 Jan 2025 19:20:29 +0000 (11:20 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 20 Jan 2025 17:46:10 +0000 (09:46 -0800)
commit0c35ca252a7dea61f0731e99d695492176862e2c
treea7e2aad21d76b996bdf0bb8fc99f1727b42d0457
parentaefaa4313b5083427781f9e3e0cc7b5ce5cb4df0
bpf: Remove 'may_goto 0' instruction in opt_remove_nops()

Since 'may_goto 0' insns are actually no-op, let us remove them.
Otherwise, verifier will generate code like
   /* r10 - 8 stores the implicit loop count */
   r11 = *(u64 *)(r10 -8)
   if r11 == 0x0 goto pc+2
   r11 -= 1
   *(u64 *)(r10 -8) = r11

which is the pure overhead.

The following code patterns (from the previous commit) are also
handled:
   may_goto 2
   may_goto 1
   may_goto 0

With this commit, the above three 'may_goto' insns are all
eliminated.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250118192029.2124584-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c