From: Puranjay Mohan <puranjay@kernel.org>
To: bpf@vger.kernel.org
Cc: Puranjay Mohan <puranjay@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>
Subject: [PATCH bpf-next 0/2] bpf: Support bpf_rcu_head in hash and LRU hash maps
Date: Thu, 24 Sep 2026 09:28:55 -0700 [thread overview]
Message-ID: <20260924162858.2435106-1-puranjay@kernel.org> (raw)
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
--
2.53.0-Meta
next reply other threads:[~2026-09-24 16:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 16:28 Puranjay Mohan [this message]
2026-09-24 16:28 ` [PATCH bpf-next 1/2] bpf: Support bpf_rcu_head in hash and LRU hash maps Puranjay Mohan
2026-09-24 16:52 ` sashiko-bot
2026-09-24 17:24 ` bot+bpf-ci
2026-09-25 1:05 ` Alexei Starovoitov
2026-09-24 16:28 ` [PATCH bpf-next 2/2] selftests/bpf: Add bpf_call_rcu tests for " Puranjay Mohan
2026-09-24 17:23 ` bot+bpf-ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924162858.2435106-1-puranjay@kernel.org \
--to=puranjay@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox