Skip to content

Commit e30cf54

Browse files
pengdonglinvijay-suman
authored andcommitted
ftrace: Fix preemption accounting for stacktrace trigger command
commit e333332657f615ac2b55aa35565c4a882018bbe9 upstream. When using the stacktrace trigger command to trace syscalls, the preemption count was consistently reported as 1 when the system call event itself had 0 ("."). For example: root@ubuntu22-vm:/sys/kernel/tracing/events/syscalls/sys_enter_read $ echo stacktrace > trigger $ echo 1 > enable sshd-416 [002] ..... 232.864910: sys_read(fd: a, buf: 556b1f3221d0, count: 8000) sshd-416 [002] ...1. 232.864913: <stack trace> => ftrace_syscall_enter => syscall_trace_enter => do_syscall_64 => entry_SYSCALL_64_after_hwframe The root cause is that the trace framework disables preemption in __DO_TRACE before invoking the trigger callback. Use the tracing_gen_ctx_dec() that will accommodate for the increase of the preemption count in __DO_TRACE when calling the callback. The result is the accurate reporting of: sshd-410 [004] ..... 210.117660: sys_read(fd: 4, buf: 559b725ba130, count: 40000) sshd-410 [004] ..... 210.117662: <stack trace> => ftrace_syscall_enter => syscall_trace_enter => do_syscall_64 => entry_SYSCALL_64_after_hwframe Cc: [email protected] Fixes: ce33c84 ("tracing: Dump stacktrace trigger to the corresponding instance") Link: https://lore.kernel.org/[email protected] Signed-off-by: pengdonglin <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit deea40f26b9ded46a9e6e50103dc103453725f56) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 12fddae commit e30cf54

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/trace/trace_events_trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ stacktrace_trigger(struct event_trigger_data *data,
12441244
struct trace_event_file *file = data->private_data;
12451245

12461246
if (file)
1247-
__trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP);
1247+
__trace_stack(file->tr, tracing_gen_ctx_dec(), STACK_SKIP);
12481248
else
12491249
trace_dump_stack(STACK_SKIP);
12501250
}

0 commit comments

Comments
 (0)