[PATCH v7] tracing: Do not bother getting user space stacktraces for kernel threads
From: Steven Rostedt
Date: Mon Nov 30 2026 - 14:52:49 EST
From: Steven Rostedt <rostedt@xxxxxxxxxxx>
If a user space stacktrace is requested when running a kernel thread, just
return, as there's no point trying to get the user space stacktrace as
there is no user space.
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
Changes from v6: https://patch.msgid.link/20250828180356.546256287@xxxxxxxxxx
- Make a separate patch from the user stack trace series. This patch stands
on its own.
- Use the new "is_user_task()" helper function instead of open coding what
makes a task a kernel thread.
kernel/trace/trace.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 926a2eb247df..181b565786a9 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2280,6 +2280,10 @@ ftrace_trace_userstack(struct trace_array *tr,
if (!(tr->trace_flags & TRACE_ITER(USERSTACKTRACE)))
return;
+ /* No point doing user space stacktraces on kernel threads */
+ if (!is_user_task(current))
+ return;
+
/*
* NMIs can not handle page faults, even with fix ups.
* The save user stack can (and often does) fault.
--
2.53.0