From: Li Jinyue <jinyue.li@linux.alibaba.com>
To: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
linux-kernel@vger.kernel.org
Subject: [PATCH bpf] bpf: Fix soft lockup in fd_array_map_free()
Date: Thu, 12 Nov 2026 12:20:15 +0000 [thread overview]
Message-ID: <20261112122015.3356106-1-jinyue.li@linux.alibaba.com> (raw)
fd_array_map_free() walks all map entries to assert that the map is
empty before its memory is freed. max_entries is not bounded, and the
free runs from the bpf_map_free_deferred work item, so with a large
max_entries the scan occupies the CPU for a long time without a
scheduling point:
watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [kworker/u8:5:8894]
Workqueue: events_unbound bpf_map_free_deferred
epc : fd_array_map_free+0x7c/0xea
Add cond_resched() to the loop, matching what commit 4406942e65ca
("bpf: Fix RCU stall in bpf_fd_array_map_clear()") did for
bpf_fd_array_map_clear().
Fixes: 04fd61ab36ec ("bpf: allow bpf programs to tail-call other bpf programs")
Signed-off-by: Li Jinyue <jinyue.li@linux.alibaba.com>
---
kernel/bpf/arraymap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 0ce26b538075..3c908373333e 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -924,8 +924,10 @@ static void fd_array_map_free(struct bpf_map *map)
int i;
/* make sure it's empty */
- for (i = 0; i < array->map.max_entries; i++)
+ for (i = 0; i < array->map.max_entries; i++) {
BUG_ON(array->ptrs[i] != NULL);
+ cond_resched();
+ }
bpf_map_area_free(array);
}
--
2.25.1
reply other threads:[~2026-11-12 12:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261112122015.3356106-1-jinyue.li@linux.alibaba.com \
--to=jinyue.li@linux.alibaba.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®