Merge branch 'Allow struct_ops maps with a large number of programs'
authorMartin KaFai Lau <martin.lau@kernel.org>
Thu, 29 Feb 2024 23:23:12 +0000 (15:23 -0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 4 Mar 2024 22:09:24 +0000 (14:09 -0800)
commit8f50d5c423551bfa259af792647a2f4799780ac5
treec3e977ac6a70cf40b315f9d84c42ad51b5d35799
parent01031fd473059bf69bb6edc6d51d4bd58ad92e50
parent93bc28d859e57f1a654d3b63600d14c85c5630a4
Merge branch 'Allow struct_ops maps with a large number of programs'

Kui-Feng Lee says:

====================
The BPF struct_ops previously only allowed for one page to be used for
the trampolines of all links in a map. However, we have recently run
out of space due to the large number of BPF program links. By
allocating additional pages when we exhaust an existing page, we can
accommodate more links in a single map.

The variable st_map->image has been changed to st_map->image_pages,
and its type has been changed to an array of pointers to buffers of
PAGE_SIZE. Additional pages are allocated when all existing pages are
exhausted.

The test case loads a struct_ops maps having 40 programs. Their
trampolines takes about 6.6k+ bytes over 1.5 pages on x86.
---
Major differences from v3:

 - Refactor buffer allocations to bpf_struct_ops_tramp_buf_alloc() and
   bpf_struct_ops_tramp_buf_free().

Major differences from v2:

 - Move image buffer allocation to bpf_struct_ops_prepare_trampoline().

Major differences from v1:

 - Always free pages if failing to update.

 - Allocate 8 pages at most.

v3: https://lore.kernel.org/all/20240224030302.1500343-1-thinker.li@gmail.com/
v2: https://lore.kernel.org/all/20240221225911.757861-1-thinker.li@gmail.com/
v1: https://lore.kernel.org/all/20240216182828.201727-1-thinker.li@gmail.com/
====================

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>