]> www.infradead.org Git - users/dwmw2/linux.git/commit
bpf: Reduce the scope of rcu_read_lock when updating fd map
authorHou Tao <houtao1@huawei.com>
Thu, 14 Dec 2023 04:30:09 +0000 (12:30 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 14 Dec 2023 04:49:11 +0000 (20:49 -0800)
commit8f82583f9527b3be9d70d9a5d1f33435e29d0480
treef295c8b23b7beead0a0bb9a2e880b7356299769d
parent2a0c6b41eec90c2a138ea8b574836744783c67ff
bpf: Reduce the scope of rcu_read_lock when updating fd map

There is no rcu-read-lock requirement for ops->map_fd_get_ptr() or
ops->map_fd_put_ptr(), so doesn't use rcu-read-lock for these two
callbacks.

For bpf_fd_array_map_update_elem(), accessing array->ptrs doesn't need
rcu-read-lock because array->ptrs must still be allocated. For
bpf_fd_htab_map_update_elem(), htab_map_update_elem() only requires
rcu-read-lock to be held to avoid the WARN_ON_ONCE(), so only use
rcu_read_lock() during the invocation of htab_map_update_elem().

Acked-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20231214043010.3458072-2-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/hashtab.c
kernel/bpf/syscall.c