All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: Call cond_resched() to avoid soft lockup in trie_free()
@ 2025-06-16  9:55 Matt Fleming
  2025-06-16 15:50 ` Song Liu
  0 siblings, 1 reply; 14+ messages in thread
From: Matt Fleming @ 2025-06-16  9:55 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	bpf, linux-kernel, kernel-team, Matt Fleming

From: Matt Fleming <mfleming@cloudflare.com>

Calls to kfree() in trie_free() can be expensive for KASAN-enabled
kernels. This can cause soft lockup warnings when traversing large maps,

  watchdog: BUG: soft lockup - CPU#41 stuck for 76s! [kworker/u518:14:1158211]

Avoid an unbounded loop and periodically check whether we should reschedule.

Signed-off-by: Matt Fleming <mfleming@cloudflare.com>
---
 kernel/bpf/lpm_trie.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
index be66d7e520e0..a35619cd99f6 100644
--- a/kernel/bpf/lpm_trie.c
+++ b/kernel/bpf/lpm_trie.c
@@ -646,6 +646,8 @@ static void trie_free(struct bpf_map *map)
 			RCU_INIT_POINTER(*slot, NULL);
 			break;
 		}
+
+		cond_resched();
 	}
 
 out:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-07-03 11:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16  9:55 [PATCH] bpf: Call cond_resched() to avoid soft lockup in trie_free() Matt Fleming
2025-06-16 15:50 ` Song Liu
2025-06-17  9:42   ` Matt Fleming
2025-06-17 15:55     ` Alexei Starovoitov
2025-06-18 12:29       ` Matt Fleming
2025-06-18 14:01         ` Alexei Starovoitov
2025-06-18 14:27           ` Ignat Korchagin
2025-06-18 14:50             ` Alexei Starovoitov
2025-06-27 13:20               ` Matt Fleming
2025-06-27 19:36                 ` Alexei Starovoitov
2025-06-30 13:28                   ` Matt Fleming
2025-07-01 16:25                     ` Alexei Starovoitov
2025-07-01 16:41                       ` Ignat Korchagin
2025-07-03 11:00                       ` Matt Fleming

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.