bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] Reduce kmalloc / kfree churn in the verifier
@ 2021-04-29 13:46 Lorenz Bauer
  2021-04-29 13:46 ` [PATCH bpf-next 1/3] bpf: verifier: improve function state reallocation Lorenz Bauer
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Lorenz Bauer @ 2021-04-29 13:46 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: kernel-team, Lorenz Bauer, netdev, bpf

github.com/cilium/ebpf runs integration tests with libbpf in a vm on CI.
I recently did some work to increase the code coverage from that, and
started experiencing OOM-kills in the VM. That led me down a rabbit
hole looking at verifier memory allocation patterns. I didn't figure out
what triggered the OOM-kills but refactored some often called memory
allocation code.

The key insight is that often times we don't need to do a full kfree /
kmalloc, but can instead just reallocate. The first patch adds two helpers
which do just that for the use cases in the verifier, which are sufficiently
different that they can't use stock krealloc_array and friends.

The series makes bpf_verif_scale about 10% faster in my VM set up, which
is especially noticeable when running with KASAN enabled.

Lorenz Bauer (3):
  bpf: verifier: improve function state reallocation
  bpf: verifier: use copy_array for jmp_history
  bpf: verifier: allocate idmap scratch in verifier env

 include/linux/bpf_verifier.h |   8 ++
 kernel/bpf/verifier.c        | 254 +++++++++++++++++------------------
 2 files changed, 128 insertions(+), 134 deletions(-)

-- 
2.27.0


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

end of thread, other threads:[~2021-05-11  0:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 13:46 [PATCH bpf-next 0/3] Reduce kmalloc / kfree churn in the verifier Lorenz Bauer
2021-04-29 13:46 ` [PATCH bpf-next 1/3] bpf: verifier: improve function state reallocation Lorenz Bauer
2021-04-29 13:46 ` [PATCH bpf-next 2/3] bpf: verifier: use copy_array for jmp_history Lorenz Bauer
2021-04-29 13:46 ` [PATCH bpf-next 3/3] bpf: verifier: allocate idmap scratch in verifier env Lorenz Bauer
2021-04-29 14:52   ` Edward Cree
2021-05-11  0:55 ` [PATCH bpf-next 0/3] Reduce kmalloc / kfree churn in the verifier Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).