public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH] fgraph: Copy args in intermediate storage with entry
Date: Thu, 21 Aug 2025 08:59:39 -0400	[thread overview]
Message-ID: <aKcYO5xvRv3M0Ngf@laps> (raw)
In-Reply-To: <20250820195522.51d4a268@gandalf.local.home>

On Wed, Aug 20, 2025 at 07:55:22PM -0400, Steven Rostedt wrote:
>From: Steven Rostedt <rostedt@goodmis.org>
>
>The output of the function graph tracer has two ways to display its
>entries. One way for leaf functions with no events recorded within them,
>and the other is for functions with events recorded inside it. As function
>graph has an entry and exit event, to simplify the output of leaf
>functions it combines the two, where as non leaf functions are separate:
>
> 2)               |              invoke_rcu_core() {
> 2)               |                raise_softirq() {
> 2)   0.391 us    |                  __raise_softirq_irqoff();
> 2)   1.191 us    |                }
> 2)   2.086 us    |              }
>
>The __raise_softirq_irqoff() function above is really two events that were
>merged into one. Otherwise it would have looked like:
>
> 2)               |              invoke_rcu_core() {
> 2)               |                raise_softirq() {
> 2)               |                  __raise_softirq_irqoff() {
> 2)   0.391 us    |                  }
> 2)   1.191 us    |                }
> 2)   2.086 us    |              }
>
>In order to do this merge, the reading of the trace output file needs to
>look at the next event before printing. But since the pointer to the event
>is on the ring buffer, it needs to save the entry event before it looks at
>the next event as the next event goes out of focus as soon as a new event
>is read from the ring buffer. After it reads the next event, it will print
>the entry event with either the '{' (non leaf) or ';' and timestamps (leaf).
>
>The iterator used to read the trace file has storage for this event. The
>problem happens when the function graph tracer has arguments attached to
>the entry event as the entry now has a variable length "args" field. This
>field only gets set when funcargs option is used. But the args are not
>recorded in this temp data and garbage could be printed. The entry field
>is copied via:
>
>  data->ent = *curr;
>
>Where "curr" is the entry field. But this method only saves the non
>variable length fields from the structure.
>
>Add a helper structure to the iterator data that adds the max args size to
>the data storage in the iterator. Then simply copy the entire entry into
>this storage (with size protection).
>
>Reported-by: Sasha Levin <sashal@kernel.org>
>Closes: https://lore.kernel.org/all/aJaxRVKverIjF4a6@lappy/
>Fixes: ff5c9c576e75 ("ftrace: Add support for function argument to graph tracer")
>Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

	Tested-by: Sasha Levin <sashal@kernel.org>

Thanks for the fix!

-- 
Thanks,
Sasha

      reply	other threads:[~2025-08-21 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 23:55 [PATCH] fgraph: Copy args in intermediate storage with entry Steven Rostedt
2025-08-21 12:59 ` Sasha Levin [this message]

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=aKcYO5xvRv3M0Ngf@laps \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.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