]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: arena: populate vm_area without allocating memory
authorPuranjay Mohan <puranjay@kernel.org>
Mon, 22 Dec 2025 19:50:16 +0000 (11:50 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 23 Dec 2025 19:29:59 +0000 (11:29 -0800)
commitc336b0b327120052c331f6839ee60069065a7c74
tree4e4abd33e4d954f4a9cab7e76a670a43d449a573
parentac1c5bc7c4c7e20e2070e6eaa673fc3e11619dbb
bpf: arena: populate vm_area without allocating memory

vm_area_map_pages() may allocate memory while inserting pages into bpf
arena's vm_area. In order to make bpf_arena_alloc_pages() kfunc
non-sleepable change bpf arena to populate pages without
allocating memory:
- at arena creation time populate all page table levels except
  the last level
- when new pages need to be inserted call apply_to_page_range() again
  with apply_range_set_cb() which will only set_pte_at() those pages and
  will not allocate memory.
- when freeing pages call apply_to_existing_page_range with
  apply_range_clear_cb() to clear the pte for the page to be removed. This
  doesn't free intermediate page table levels.

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