From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y 1/3] bpf: Convert lpm_trie.c to rqspinlock
Date: Sat, 18 Jul 2026 17:50:19 -0400 [thread overview]
Message-ID: <20260718215021.3447372-1-sashal@kernel.org> (raw)
In-Reply-To: <2026071451-collision-embolism-f766@gregkh>
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
[ Upstream commit 47979314c0fe245ed54306e2f91b3f819c7c0f9f ]
Convert all LPM trie usage of raw_spinlock to rqspinlock.
Note that rcu_dereference_protected in trie_delete_elem is switched over
to plain rcu_dereference, the RCU read lock should be held from BPF
program side or eBPF syscall path, and the trie->lock is just acquired
before the dereference. It is not clear the reason the protected variant
was used from the commit history, but the above reasoning makes sense so
switch over.
Closes: https://lore.kernel.org/lkml/000000000000adb08b061413919e@google.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20250316040541.108729-22-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Stable-dep-of: 2f884d371faf ("bpf: Allow LPM map access from sleepable BPF programs")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/lpm_trie.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
index 37669d69886640..cdfa10b0c56b78 100644
--- a/kernel/bpf/lpm_trie.c
+++ b/kernel/bpf/lpm_trie.c
@@ -349,8 +349,7 @@ static int trie_update_elem(struct bpf_map *map,
*/
slot = &trie->root;
- while ((node = rcu_dereference_protected(*slot,
- lockdep_is_held(&trie->lock)))) {
+ while ((node = rcu_dereference(*slot))) {
matchlen = longest_prefix_match(trie, node, key);
if (node->prefixlen != matchlen ||
@@ -475,8 +474,7 @@ static int trie_delete_elem(struct bpf_map *map, void *_key)
trim = &trie->root;
trim2 = trim;
parent = NULL;
- while ((node = rcu_dereference_protected(
- *trim, lockdep_is_held(&trie->lock)))) {
+ while ((node = rcu_dereference(*trim))) {
matchlen = longest_prefix_match(trie, node, key);
if (node->prefixlen != matchlen ||
--
2.53.0
next prev parent reply other threads:[~2026-07-18 21:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 15:53 FAILED: patch "[PATCH] bpf: Allow LPM map access from sleepable BPF programs" failed to apply to 5.15-stable tree gregkh
2026-07-18 21:50 ` Sasha Levin [this message]
2026-07-18 21:50 ` [PATCH 5.15.y 2/3] bpf: Consistently use bpf_rcu_lock_held() everywhere Sasha Levin
2026-07-18 21:50 ` [PATCH 5.15.y 3/3] bpf: Allow LPM map access from sleepable BPF programs Sasha Levin
2026-07-19 12:43 ` [PATCH 5.15.y 1/3] bpf: Convert lpm_trie.c to rqspinlock Sasha Levin
2026-07-19 12:43 ` [PATCH 5.15.y 2/3] bpf: Consistently use bpf_rcu_lock_held() everywhere Sasha Levin
2026-07-19 12:43 ` [PATCH 5.15.y 3/3] bpf: Allow LPM map access from sleepable BPF programs Sasha Levin
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=20260718215021.3447372-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=ast@kernel.org \
--cc=memxor@gmail.com \
--cc=stable@vger.kernel.org \
/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