From: Tengda Wu <wutengda@huaweicloud.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@kernel.org>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
Tengda Wu <wutengda@huaweicloud.com>
Subject: [PATCH] tracing: Fix soft lockup when lseeking trace file
Date: Mon, 9 Feb 2026 17:31:01 +0800 [thread overview]
Message-ID: <20260209093101.1623454-1-wutengda@huaweicloud.com> (raw)
A soft lockup may occur when accessing trace file via lseek while
tracing is active and a large offset is provided. The call trace
is shown below:
watchdog: BUG: soft lockup - CPU#3 stuck for 26s! [poc:141]
CPU: 3 UID: 0 PID: 141 Comm: poc Not tainted 6.19.0 #1 PREEMPT(none)
Call Trace:
ring_buffer_iter_peek
peek_next_entry
__find_next_entry
trace_find_next_entry_inc
s_next
traverse.part.0
seq_lseek
tracing_lseek
__x64_sys_lseek
do_syscall_64
entry_SYSCALL_64_after_hwframe
The root cause is that the lseek implementation for trace files
is based on seq_lseek, which contains a loop that repeatedly calls
show() and next() functions until the position reaches the target
offset. Since no scheduling point is set within this loop, a large
offset can cause the CPU to be stuck in the loop for an extended
period, triggering the soft lockup detector.
Fixed by adding cond_resched() in s_next().
Fixes: bc0c38d139ec ("ftrace: latency tracer infrastructure")
Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>
---
kernel/trace/trace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8bd4ec08fb36..3afe148ef683 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3928,6 +3928,8 @@ static void *s_next(struct seq_file *m, void *v, loff_t *pos)
iter->pos = *pos;
+ cond_resched();
+
return ent;
}
--
2.34.1
next reply other threads:[~2026-02-09 9:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 9:31 Tengda Wu [this message]
2026-02-09 16:10 ` [PATCH] tracing: Fix soft lockup when lseeking trace file Steven Rostedt
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=20260209093101.1623454-1-wutengda@huaweicloud.com \
--to=wutengda@huaweicloud.com \
--cc=acme@ghostprotocols.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@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