BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] bpf: Keep fewer states apart because of pointers
@ 2026-12-03 19:58 Alexei Starovoitov
  2026-12-03 19:58 ` [PATCH bpf-next 1/4] bpf: Keep the lowest offset of a stack pointer that moves up Alexei Starovoitov
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2026-12-03 19:58 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, eddyz87, memxor

From: Alexei Starovoitov <ast@kernel.org>

Andrii reported [1] that wprof needs a global variable 'zero' in place of
the constant 0. The verifier accepts both, but 0 makes the handler of
sched_switch slower to verify. With 0 clang spills one more pointer. The
slot is dead, but the liveness of the stack keeps it, and it keeps states
apart. Patch 1 fixes that. Pointers to values of two maps multiply the
states again. Patch 3 joins them. Patch 2 lets bpf_dynptr_from_mem() take
the result.

wprof_task_switch, processed insns:

                    clang 20            clang 24
                 zero        0       zero        0
  before       174164   241778     314200   510629
  patch 1      127680   128858     145393   144076
  patch 3       92729    94077     112454   111659

The time goes from 250..750 ms to 135..185 ms.

1.46M programs of public projects, clang 14..23 and gcc 14..16: no verdict
changes, -0.8 % of insns, 109K programs go down, 24 go up by 2 % at most.
wprof -40 %, strobelight-libs -13 %, bpf-examples -10 %, Cilium -4 %,
katran -3 %.

[1] https://lore.kernel.org/bpf/CAEf4Bza2on4t-L8KnbK0hr5HjRgTJOZxnBY-roD+DMWJHzxOyw@mail.gmail.com/

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Alexei Starovoitov (4):
  bpf: Keep the lowest offset of a stack pointer that moves up
  bpf: Let bpf_dynptr_from_mem() take memory that nothing invalidates
  bpf: Join pointers to values of two maps
  selftests/bpf: Test walks over the stack and joins of map values

 Documentation/bpf/verifier.rst                |   7 +-
 include/linux/bpf_verifier.h                  |  13 +
 include/uapi/linux/bpf.h                      |   3 +-
 kernel/bpf/join.c                             |  20 +-
 kernel/bpf/liveness.c                         |  73 ++++--
 kernel/bpf/precision.c                        |  23 +-
 kernel/bpf/states.c                           |  39 ++-
 kernel/bpf/verifier.c                         |  13 +-
 tools/include/uapi/linux/bpf.h                |   3 +-
 .../testing/selftests/bpf/progs/dynptr_fail.c |  19 ++
 .../selftests/bpf/progs/verifier_partition.c  | 248 +++++++++++++++++-
 11 files changed, 419 insertions(+), 42 deletions(-)


base-commit: 289cd43f93ed974660044caaaa19bfea14b1781c
-- 
2.55.0


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

end of thread, other threads:[~2026-12-03 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 19:58 [PATCH bpf-next 0/4] bpf: Keep fewer states apart because of pointers Alexei Starovoitov
2026-12-03 19:58 ` [PATCH bpf-next 1/4] bpf: Keep the lowest offset of a stack pointer that moves up Alexei Starovoitov
2026-12-03 20:31   ` sashiko-bot
2026-12-03 19:58 ` [PATCH bpf-next 2/4] bpf: Let bpf_dynptr_from_mem() take memory that nothing invalidates Alexei Starovoitov
2026-12-03 19:58 ` [PATCH bpf-next 3/4] bpf: Join pointers to values of two maps Alexei Starovoitov
2026-12-03 20:42   ` bot+bpf-ci
2026-12-03 19:58 ` [PATCH bpf-next 4/4] selftests/bpf: Test walks over the stack and joins of map values Alexei Starovoitov

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