All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
To: rostedt@goodmis.org, rob@landley.net
Cc: linux-kernel@vger.kernel.org, yrl.pp-manager.tt@hitachi.com,
	fweisbec@gmail.com, mingo@redhat.com, jolsa@redhat.com,
	lizf@cn.fujitsu.com
Subject: [PATCH -tip 0/4] tracing: make a snapshot feature available from userspace
Date: Tue, 02 Oct 2012 17:13:09 +0900	[thread overview]
Message-ID: <20121002081309.8661.37629.stgit@falsita> (raw)

Hi, Steven,

This patch series make a snapshot feature available from userspace
via debugfs.
(But I know that you are working for multi-buffer. If these
patches collide with your work much, I will resubmit my patches
after that. What would you think?)


If we set CONFIG_TRACER_SNAPSHOT, this snapshot feature becomes
available to all non latency tracers. (Latency tracers which
record max latency, such as "irqsoff" or "wakeup", can't use
this feature, since those are already using the snapshot
mechanism internally.)

Snapshot preserves a trace buffer at a particular point in time
without stopping tracing. Ftrace swaps the current buffer with a
spare buffer, and tracing continues in the (previous) spare
buffer.

The following debugfs files in "tracing" are related to this
feature:

  snapshot:

	This is used to take a snapshot and to read the output
	of the snapshot. Echo 1 into this file to allocate a
	spare buffer and to take a snapshot, then read the
	snapshot from the file in the same format as "trace".
	Both reads snapshot and tracing are executable in
	parallel. Echoing 0 erases the snapshot contents.

  snapshot_allocate:

	This is used to pre-allocate or free a spare buffer.
	Echo 1 into this file to pre-allocate a spare buffer if
	you don't want to fail in the next snapshot due to
	memory allocation failure, or if you don't want to lose
	older trace data while allocating buffer. Echo 0 to free
	the spare buffer when the snapshot becomes unnecessary.
	If you take the next snapshot again, you can reuse the
	buffer, then just erase the snapshot contents by echoing
	1 into the "snapshot" file, instead of freeing the
	buffer.

	Reads from this file display whether the spare buffer is
	allocated. When current_tracer is changed, the allocated
	spare buffer is freed. If the next tracer is one of the
	latency tracers, this value turns into 1 and can't be
	changed, or else the value starts with 0.


Here is an example of using the snapshot feature.

 # echo 1 > snapshot_allocate (if you want to pre-allocate the spare buffer)
 # echo 1 > events/sched/enable
 # echo 1 > snapshot
 # cat snapshot
# tracer: nop
#
# entries-in-buffer/entries-written: 71/71   #P:8
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
          <idle>-0     [005] d...  2440.603828: sched_switch: prev_comm=swapper/5 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2242 next_prio=120
           sleep-2242  [005] d...  2440.603846: sched_switch: prev_comm=snapshot-test-2 prev_pid=2242 prev_prio=120 prev_state=R ==> next_comm=kworker/5:1 next_pid=60 next_prio=120
[...]
          <idle>-0     [002] d...  2440.707230: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2229 next_prio=120
 # cat trace
# tracer: nop
#
# entries-in-buffer/entries-written: 77/77   #P:8
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
          <idle>-0     [007] d...  2440.707395: sched_switch: prev_comm=swapper/7 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2243 next_prio=120
 snapshot-test-2-2229  [002] d...  2440.707438: sched_switch: prev_comm=snapshot-test-2 prev_pid=2229 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120
[...]

---

Hiraku Toyooka (4):
      tracing: add description of snapshot to Documentation/trace/ftrace.txt
      tracing: make a snapshot feature available from userspace
      tracing: add a resize function for making one buffer equivalent to the other buffer
      tracing: change tracer's integer flags to bool


 Documentation/trace/ftrace.txt    |   97 +++++++++++++++
 include/linux/ftrace_event.h      |    3 
 kernel/trace/Kconfig              |   11 ++
 kernel/trace/trace.c              |  247 +++++++++++++++++++++++++++++++------
 kernel/trace/trace.h              |    5 -
 kernel/trace/trace_irqsoff.c      |   12 +-
 kernel/trace/trace_sched_wakeup.c |    8 +
 7 files changed, 332 insertions(+), 51 deletions(-)

-- 
Hiraku TOYOOKA
Linux Technology Center
Yokohama Research Laboratory
Hitachi Ltd.

             reply	other threads:[~2012-10-02  8:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02  8:13 Hiraku Toyooka [this message]
2012-10-02  8:27 ` [PATCH -tip 1/4] tracing: change tracer's integer flags to bool Hiraku Toyooka
2012-11-14  6:43   ` [tip:perf/core] tracing: Change " tip-bot for Hiraku Toyooka
2012-10-02  8:27 ` [PATCH -tip 2/4] tracing: add a resize function for making one buffer equivalent to the other buffer Hiraku Toyooka
2012-10-05 16:59   ` Steven Rostedt
2012-10-17  2:47     ` Hiraku Toyooka
2012-10-17  2:57       ` Steven Rostedt
2012-10-02  8:27 ` [PATCH -tip 3/4] tracing: make a snapshot feature available from userspace Hiraku Toyooka
2012-10-02  8:27 ` [PATCH -tip 4/4] tracing: add description of snapshot to Documentation/trace/ftrace.txt Hiraku Toyooka

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=20121002081309.8661.37629.stgit@falsita \
    --to=hiraku.toyooka.gu@hitachi.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@redhat.com \
    --cc=rob@landley.net \
    --cc=rostedt@goodmis.org \
    --cc=yrl.pp-manager.tt@hitachi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.