Skip to content

Commit 039b379

Browse files
ftrace: Fix preemption accounting for stacktrace filter command
JIRA: https://issues.redhat.com/browse/RHEL-115358 commit 11aff32 Author: pengdonglin <[email protected]> Date: Mon May 12 17:42:46 2025 +0800 ftrace: Fix preemption accounting for stacktrace filter command The preemption count of the stacktrace filter command to trace ksys_read is consistently incorrect: $ echo ksys_read:stacktrace > set_ftrace_filter <...>-453 [004] ...1. 38.308956: <stack trace> => ksys_read => do_syscall_64 => entry_SYSCALL_64_after_hwframe The root cause is that the trace framework disables preemption when invoking the filter command callback in function_trace_probe_call: preempt_disable_notrace(); probe_ops->func(ip, parent_ip, probe_opsbe->tr, probe_ops, probe->data); preempt_enable_notrace(); Use tracing_gen_ctx_dec() to account for the preempt_disable_notrace(), which will output the correct preemption count: $ echo ksys_read:stacktrace > set_ftrace_filter <...>-410 [006] ..... 31.420396: <stack trace> => ksys_read => do_syscall_64 => entry_SYSCALL_64_after_hwframe Cc: [email protected] Fixes: 36590c5 ("tracing: Merge irqflags + preempt counter.") Link: https://lore.kernel.org/[email protected] Signed-off-by: pengdonglin <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Jerome Marchand <[email protected]>
1 parent d9cd55f commit 039b379

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

kernel/trace/trace_functions.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,7 @@ ftrace_traceoff(unsigned long ip, unsigned long parent_ip,
574574

575575
static __always_inline void trace_stack(struct trace_array *tr)
576576
{
577-
unsigned int trace_ctx;
578-
579-
trace_ctx = tracing_gen_ctx();
580-
581-
__trace_stack(tr, trace_ctx, FTRACE_STACK_SKIP);
577+
__trace_stack(tr, tracing_gen_ctx_dec(), FTRACE_STACK_SKIP);
582578
}
583579

584580
static void

0 commit comments

Comments
 (0)