BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] bpf: Track delta between "linked" registers.
@ 2024-06-08  0:44 Alexei Starovoitov
  2024-06-08  0:44 ` [PATCH bpf-next 1/4] bpf: Relax tuple len requirement for sk helpers Alexei Starovoitov
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Alexei Starovoitov @ 2024-06-08  0:44 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, martin.lau, memxor, eddyz87, kernel-team

From: Alexei Starovoitov <ast@kernel.org>

Compilers can generate the code
  r1 = r2
  r1 += 0x1
  if r2 < 1000 goto ...
  use knowledge of r2 range in subsequent r1 operations

The "undo" pass was introduced in LLVM
https://reviews.llvm.org/D121937
to prevent this optimization, but it cannot cover all cases.
Instead of fighting middle end optimizer in BPF backend teach the verifier
about this pattern.

The veristat difference:
File                                Program             Insns (A)  Insns (B)  Insns     (DIFF)
----------------------------------  ------------------  ---------  ---------  ----------------
arena_htab.bpf.o                    arena_htab_llvm         18656        768  -17888 (-95.88%)
arena_htab_asm.bpf.o                arena_htab_asm          18523        586  -17937 (-96.84%)
iters.bpf.o                         iter_subprog_iters       1109        981    -128 (-11.54%)
verifier_iterating_callbacks.bpf.o  cond_break1               110        121     +11 (+10.00%)
verifier_iterating_callbacks.bpf.o  cond_break2               113         91     -22 (-19.47%)

Alexei Starovoitov (4):
  bpf: Relax tuple len requirement for sk helpers.
  bpf: Track delta between "linked" registers.
  bpf: Support can_loop/cond_break on big endian
  selftests/bpf: Add tests for add_const

 include/linux/bpf_verifier.h                  |  12 +-
 kernel/bpf/log.c                              |   4 +-
 kernel/bpf/verifier.c                         |  90 +++++++++--
 net/core/filter.c                             |  24 +--
 .../testing/selftests/bpf/bpf_experimental.h  |  28 ++++
 .../testing/selftests/bpf/progs/arena_htab.c  |  16 +-
 .../bpf/progs/verifier_iterating_callbacks.c  | 150 ++++++++++++++++++
 7 files changed, 298 insertions(+), 26 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-06-10 21:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-08  0:44 [PATCH bpf-next 0/4] bpf: Track delta between "linked" registers Alexei Starovoitov
2024-06-08  0:44 ` [PATCH bpf-next 1/4] bpf: Relax tuple len requirement for sk helpers Alexei Starovoitov
2024-06-08  0:44 ` [PATCH bpf-next 2/4] bpf: Track delta between "linked" registers Alexei Starovoitov
2024-06-10 18:32   ` Eduard Zingerman
2024-06-10 18:56     ` Eduard Zingerman
2024-06-10 20:31       ` Alexei Starovoitov
2024-06-10 21:51         ` Eduard Zingerman
2024-06-10 20:27     ` Alexei Starovoitov
2024-06-10 21:25       ` Alexei Starovoitov
2024-06-08  0:44 ` [PATCH bpf-next 3/4] bpf: Support can_loop/cond_break on big endian Alexei Starovoitov
2024-06-10  5:44   ` Yonghong Song
2024-06-08  0:44 ` [PATCH bpf-next 4/4] selftests/bpf: Add tests for add_const Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox