bpf: Support bpf_rcu_head in hash and LRU hash maps
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: Support bpf_rcu_head in hash and LRU hash mapsinclude/ kernel/ kernel/ +1 more | +214 | 1 reply | |
| 2/2 | selftests/bpf: Add bpf_call_rcu tests for hash and LRU hash mapstools/ tools/ | +526 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf-next 0/2] bpf: Support bpf_rcu_head in hash and LRU hash maps
bpf_call_rcu() currently only takes a bpf_rcu_head in an array, because an array element is never freed while the map is alive. Hash elements are recycled, and an RCU callback cannot be cancelled, so a delete racing a queued callback would hand the element back to the allocator underneath it.
This keeps the element alive until the callback has run. The map claims the head before releasing an element; if a callback is queued or running, the element is unlinked but not returned to the allocator, and the callback returns it through a new map_release_elem(). Patch 1 also covers the two places a hash recycles an element without freeing it: the per-CPU spare a preallocated htab uses on update, and LRU eviction.
Patch 2 adds tests for the delete, replace, recycle and eviction paths. Each was checked against a kernel with the corresponding hunk reverted.
Puranjay Mohan (2):
bpf: Support bpf_rcu_head in hash and LRU hash maps selftests/bpf: Add bpf_call_rcu tests for hash and LRU hash maps
include/linux/bpf.h | 5 + kernel/bpf/hashtab.c | 104 ++++++- kernel/bpf/helpers.c | 117 +++++++- kernel/bpf/syscall.c | 14 +- .../selftests/bpf/prog_tests/call_rcu.c | 254 +++++++++++++++- tools/testing/selftests/bpf/progs/call_rcu.c | 274 ++++++++++++++++++ 6 files changed, 740 insertions(+), 28 deletions(-)
base-commit: 4f3a5eae895b9995e93425a75235d8f1f3268caa
Signature · 1 line
2.53.0-Meta