]> www.infradead.org Git - users/dwmw2/linux.git/commit
bpf: Use raw_spinlock_t for LPM trie
authorHou Tao <houtao1@huawei.com>
Fri, 6 Dec 2024 11:06:20 +0000 (19:06 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 6 Dec 2024 17:14:26 +0000 (09:14 -0800)
commit6a5c63d43c0216d64915baa0e0eacf2beb66b271
treecddc403d30486d28765a4a4e706e28e31e4fc1eb
parent3d8dc43eb2a3d179809f5fc27c88c93a57ea123d
bpf: Use raw_spinlock_t for LPM trie

After switching from kmalloc() to the bpf memory allocator, there will be
no blocking operation during the update of LPM trie. Therefore, change
trie->lock from spinlock_t to raw_spinlock_t to make LPM trie usable in
atomic context, even on RT kernels.

The max value of prefixlen is 2048. Therefore, update or deletion
operations will find the target after at most 2048 comparisons.
Constructing a test case which updates an element after 2048 comparisons
under a 8 CPU VM, and the average time and the maximal time for such
update operation is about 210us and 900us.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20241206110622.1161752-8-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/lpm_trie.c