From: Steven Rostedt <rostedt@goodmis.org>
To: pengdonglin <dolinux.peng@gmail.com>
Cc: mhiramat@kernel.org, dolinux.peng@gmai.com,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] ftrace: Fix preemption acounting for stacktrace trigger command
Date: Mon, 12 May 2025 10:16:08 -0400 [thread overview]
Message-ID: <20250512101608.3eb16e43@gandalf.local.home> (raw)
In-Reply-To: <20250512094246.1167956-1-dolinux.peng@gmail.com>
On Mon, 12 May 2025 17:42:45 +0800
pengdonglin <dolinux.peng@gmail.com> wrote:
> From: pengdonglin <pengdonglin@xiaomi.com>
>
> While using the stacktrace trigger command to trace syscalls/sys_enter_read,
> I noticed that the preemption count was consistently reported as 1, which seemed
> incorrect:
FYI, the change log should always be in "imperative mood". The above is
fine for cover letters, but for the change log that will live forever in
the git history, it should not reference "I" nor "This patch". That is, it
should state:
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.
>
> This patch uses tracing_gen_ctx_dec() to obtain the correct preemption
> count within the callback, resulting in accurate reporting:
Instead of "This patch ..."
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:
This is FYI for when you send new patches. You don't need to resend. I'll
update the change logs and take these patches (unless of course I find
something else wrong with them).
-- Steve
>
> 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
>
> Signed-off-by: pengdonglin <dolinux.peng@gmail.com>
> ---
> kernel/trace/trace_events_trigger.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
> index b66b6d235d91..6e87ae2a1a66 100644
> --- a/kernel/trace/trace_events_trigger.c
> +++ b/kernel/trace/trace_events_trigger.c
> @@ -1560,7 +1560,7 @@ stacktrace_trigger(struct event_trigger_data *data,
> struct trace_event_file *file = data->private_data;
>
> if (file)
> - __trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP);
> + __trace_stack(file->tr, tracing_gen_ctx_dec(), STACK_SKIP);
> else
> trace_dump_stack(STACK_SKIP);
> }
next prev parent reply other threads:[~2025-05-12 14:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 9:42 pengdonglin
2025-05-12 9:42 ` [PATCH 2/2] ftrace: Fix preemption acounting for stacktrace filter command pengdonglin
2025-05-12 14:16 ` Steven Rostedt [this message]
2025-05-12 14:31 ` [PATCH 1/2] ftrace: Fix preemption acounting for stacktrace trigger command Donglin Peng
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=20250512101608.3eb16e43@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=dolinux.peng@gmai.com \
--cc=dolinux.peng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@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
all inboxes | Powered by JetHome®