All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Fleming <matt@readmodwrite.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@cloudflare.com,
	Matt Fleming <mfleming@cloudflare.com>
Subject: [PATCH] bpf: Call cond_resched() to avoid soft lockup in trie_free()
Date: Mon, 16 Jun 2025 10:55:32 +0100	[thread overview]
Message-ID: <20250616095532.47020-1-matt@readmodwrite.com> (raw)

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


             reply	other threads:[~2025-06-16  9:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16  9:55 Matt Fleming [this message]
2025-06-16 15:50 ` [PATCH] bpf: Call cond_resched() to avoid soft lockup in trie_free() 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

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=20250616095532.47020-1-matt@readmodwrite.com \
    --to=matt@readmodwrite.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@cloudflare.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mfleming@cloudflare.com \
    --cc=sdf@fomichev.me \
    --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 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.