bpf: Adjust low/high watermarks in bpf_mem_cache
authorAlexei Starovoitov <ast@kernel.org>
Fri, 2 Sep 2022 21:10:50 +0000 (14:10 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 5 Sep 2022 13:33:06 +0000 (15:33 +0200)
commit7c266178aa51dd2d4fda1312c5990a8a82c83d70
tree836f9c901619e80222a96108acdd49ce7fe1f26f
parent0fd7c5d43339b783ee3301a05f925d1e52ac87c9
bpf: Adjust low/high watermarks in bpf_mem_cache

The same low/high watermarks for every bucket in bpf_mem_cache consume
significant amount of memory. Preallocating 64 elements of 4096 bytes each in
the free list is not efficient. Make low/high watermarks and batching value
dependent on element size. This change brings significant memory savings.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220902211058.60789-9-alexei.starovoitov@gmail.com
kernel/bpf/memalloc.c