]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Select proper size for bpf_prog_pack
authorSong Liu <song@kernel.org>
Fri, 11 Mar 2022 20:11:35 +0000 (12:11 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 21 Mar 2022 02:07:14 +0000 (19:07 -0700)
commit1ca2b2ac2c7256cba10a147bb5d32ba606ac07c4
tree0aeb39efa44e717abe934c9ccdbd68459b337471
parentd32306beea072bc2e1efbe01eb09ddd5c4f8372e
bpf: Select proper size for bpf_prog_pack

Using HPAGE_PMD_SIZE as the size for bpf_prog_pack is not ideal in some
cases. Specifically, for NUMA systems, __vmalloc_node_range requires
PMD_SIZE * num_online_nodes() to allocate huge pages. Also, if the system
does not support huge pages (i.e., with cmdline option nohugevmalloc), it
is better to use PAGE_SIZE packs.

Add logic to select proper size for bpf_prog_pack. This solution is not
ideal, as it makes assumption about the behavior of module_alloc and
__vmalloc_node_range. However, it appears to be the easiest solution as
it doesn't require changes in module_alloc and vmalloc code.

Fixes: 95995d530f44 ("bpf: Introduce bpf_prog_pack allocator")
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220311201135.3573610-1-song@kernel.org
kernel/bpf/core.c