aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/bpf/prog_tests
diff options
context:
space:
mode:
authorLorenz Bauer <lmb@cloudflare.com>2021-04-29 14:46:54 +0100
committerAlexei Starovoitov <ast@kernel.org>2021-05-10 16:13:01 -0700
commitc69431aab67a912836e5831f03d99a819c14c9c3 (patch)
treec7d1e311865974c2fe4555947ca51ca82ce7ebcc /tools/testing/selftests/bpf/prog_tests
parentMerge tag 'riscv-for-linus-5.13-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux (diff)
downloadwireguard-linux-c69431aab67a912836e5831f03d99a819c14c9c3.tar.xz
wireguard-linux-c69431aab67a912836e5831f03d99a819c14c9c3.zip
bpf: verifier: Improve function state reallocation
Resizing and copying stack and reference tracking state currently does a lot of kfree / kmalloc when the size of the tracked set changes. The logic in copy_*_state and realloc_*_state is also hard to follow. Refactor this into two core functions. copy_array copies from a source into a destination. It avoids reallocation by taking the allocated size of the destination into account via ksize(). The function is essentially krealloc_array, with the difference that the contents of dst are not preserved. realloc_array changes the size of an array and zeroes newly allocated items. Contrary to krealloc both functions don't free the destination if the size is zero. Instead we rely on free_func_state to clean up. realloc_stack_state is renamed to grow_stack_state to better convey that it never shrinks the stack state. Signed-off-by: Lorenz Bauer <lmb@cloudflare.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210429134656.122225-2-lmb@cloudflare.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests')
0 files changed, 0 insertions, 0 deletions