]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: arena: use kmalloc_nolock() in place of kvcalloc()
authorPuranjay Mohan <puranjay@kernel.org>
Mon, 22 Dec 2025 19:50:17 +0000 (11:50 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 23 Dec 2025 19:29:59 +0000 (11:29 -0800)
commit360c35f8ffae0f184805d9eb7d126474345bac9b
treec6f2c0706ebf08c9d4ddc580e2d5ed2c82721662
parentc336b0b327120052c331f6839ee60069065a7c74
bpf: arena: use kmalloc_nolock() in place of kvcalloc()

To make arena_alloc_pages() safe to be called from any context, replace
kvcalloc() with kmalloc_nolock() so as it doesn't sleep or take any
locks. kmalloc_nolock() returns NULL for allocations larger than
KMALLOC_MAX_CACHE_SIZE, which is (PAGE_SIZE * 2) = 8KB on systems with
4KB pages. So, round down the allocation done by kmalloc_nolock to 1024
* 8 and reuse the array in a loop.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Link: https://lore.kernel.org/r/20251222195022.431211-3-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/arena.c