public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <zanussi@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH  0/1] tracing/boot: Add alloc_snapshot for instance option
Date: Sun, 11 Oct 2020 00:28:00 +0900	[thread overview]
Message-ID: <160234368056.400560.6282640165007466754.stgit@devnote2> (raw)

Hi,

Here is a patch to add ftrace[.instance.INSTANCE].alloc_snapshot option
to allocate snapshot buffer for specific isntance. Actually, this has
been described in Documentation/trace/boottime-trace.rst but I forgot
to implement it. (Maybe I confused it with kernel.alloc_snapshot)

Anyway, it is better to have this option with currnet ftrace implementation,
because if user sets ftrace.instance.X.event.*.*.actions = "snapshot" and
ftrace.instance.X.tracer at same bootconfig, the snapshot buffer always
removed (even if the tracer is not a max-tracer).
This seems buggy, but I'm not sure the reason why.

So if someone wants to use snapshot event action with e.g. function tracer,
they must use this option. For example,

ftrace.instance.foo {
	tracer = function
	event.signal.signal_deliver {
		enable
		actions = "snapshot if sig = 7"
	}
	alloc_snapshot
}

Steve and Tom, would you know why tracing_set_tracer() removes
snapshot buffer even if the tracer is not a max-tracer?

int tracing_set_tracer(struct trace_array *tr, const char *buf)
{
...
#ifdef CONFIG_TRACER_MAX_TRACE
        had_max_tr = tr->allocated_snapshot;

        if (had_max_tr && !t->use_max_tr) {
                /*
                 * We need to make sure that the update_max_tr sees that
                 * current_trace changed to nop_trace to keep it from
                 * swapping the buffers after we resize it.
                 * The update_max_tr is called from interrupts disabled
                 * so a synchronized_sched() is sufficient.
                 */
                synchronize_rcu();
                free_snapshot(tr);
        }
#endif
}

It seems had_max_tr is true even if the previous tracer is nop and
snapshot buffer was traced by snapshot trigger action.

This actually causes a problem except for the boot time tracing,
for example,

1) boot kernel with nop tracer
2) add snapshot trigger action to an event
   (snapshot buffer is allocated here)
3) set function tracer to current tracer
   (snapshot buffer is freed)
4) run the tracer
   -> the event trigger can not take a snapshot.


Thank you,

---

Masami Hiramatsu (1):
      tracing/boot: Add ftrace.instance.*.alloc_snapshot option


 kernel/trace/trace_boot.c |    6 ++++++
 1 file changed, 6 insertions(+)

--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>

             reply	other threads:[~2020-10-10 23:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-10 15:28 Masami Hiramatsu [this message]
2020-10-10 15:28 ` [PATCH 1/1] tracing/boot: Add ftrace.instance.*.alloc_snapshot option Masami Hiramatsu
2020-10-12 15:11   ` Steven Rostedt

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=160234368056.400560.6282640165007466754.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zanussi@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