]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Simplify bpf_prog_pack_[size|mask]
authorSong Liu <song@kernel.org>
Wed, 13 Jul 2022 20:49:50 +0000 (13:49 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 22 Jul 2022 20:08:27 +0000 (22:08 +0200)
commite881b21b18dbb0b9207cfd5f3324e052a3818d75
treee05b3cd0a679152dba31f3ca293b43626525555d
parent22c90ea5c9ece9d4e3a85804b0927876abb5c600
bpf: Simplify bpf_prog_pack_[size|mask]

Simplify the logic that selects bpf_prog_pack_size, and always use
(PMD_SIZE * num_possible_nodes()). This is a good tradeoff, as most of
the performance benefit observed is from less direct map fragmentation [0].

Also, module_alloc(4MB) may not allocate 4MB aligned memory. Therefore,
we cannot use (ptr & bpf_prog_pack_mask) to find the correct address of
bpf_prog_pack. Fix this by checking the header address falls in the range
of pack->ptr and (pack->ptr + bpf_prog_pack_size).

  [0] https://lore.kernel.org/bpf/20220707223546.4124919-1-song@kernel.org/

Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20220713204950.3015201-1-song@kernel.org
kernel/bpf/core.c