Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Check map->record at the beginning of check_and_free_fields()

When there are no special fields in the map value, there is no need to
invoke bpf_obj_free_fields(). Therefore, checking the validity of
map->record in advance.

After the change, the benchmark result of the per-cpu update case in
map_perf_test increased by 40% under a 16-CPU VM.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20250315150930.1511727-1-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Hou Tao and committed by
Alexei Starovoitov
bb2243f4 8c10109a

+3
+3
kernel/bpf/hashtab.c
··· 787 787 static void check_and_free_fields(struct bpf_htab *htab, 788 788 struct htab_elem *elem) 789 789 { 790 + if (IS_ERR_OR_NULL(htab->map.record)) 791 + return; 792 + 790 793 if (htab_is_percpu(htab)) { 791 794 void __percpu *pptr = htab_elem_get_ptr(elem, htab->map.key_size); 792 795 int cpu;