From: Namhyung Kim <namhyung@kernel.org>
To: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: rostedt@goodmis.org, tglx@linutronix.de, mhiramat@kernel.org,
linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: Re: [RFC][PATCH 00/21] tracing: Inter-event (e.g. latency) support
Date: Fri, 10 Feb 2017 13:16:17 +0900 [thread overview]
Message-ID: <20170210041617.GE599@sejong> (raw)
In-Reply-To: <cover.1486569306.git.tom.zanussi@linux.intel.com>
Hi Tom,
On Wed, Feb 08, 2017 at 11:24:56AM -0600, Tom Zanussi wrote:
> This patchset adds support for 'inter-event' quantities to the trace
> event subsystem. The most important example of inter-event quantities
> are latencies, or the time differences between two events.
>
> One of the main motivations for adding this capability is to provide a
> general-purpose base that existing existing tools such as the -RT
> latency_hist patchset can be built upon, while at the same time
> providing a simple way for users to track latencies (or any
> inter-event quantity) generically between any two events.
>
> Previous -RT latency_hist patchsets that take advantage of the trace
> event subsystem have been submitted, but they essentially hard-code
> special-case tracepoints and application logic in ways that can't be
> reused. It seemed to me that rather than providing a one-off patchset
> devoted specifically to generating the specific histograms in the
> latency_hist patchset, it should be possible to build the same
> functionality on top of a generic layer allowing users to do similar
> things for other non-latency_hist applications.
>
> In addition to preliminary patches that add some basic missing
> functionality such as a common ringbuffer-derived timestamp and
> dynamically-creatable tracepoints, the overall patchset is divided up
> into a few different areas that combine to produce the overall goal
> (The Documentation patch explains all the details):
Looks very nice!
>
> - variables and simple expressions required to calculate a latency
>
> In order to calculate a latency or any inter-event value,
> something from one event needs to be saved and later retrieved,
> and some operation such as subtraction or addition is performed on
> it. This means some minimal form of variables and expressions,
> which the first set of patches implements. Saving and retrieving
> events to use in a latency calculation is normally done using a
> hash table, and that's exactly what we have with trace event hist
> triggers, so that's where variables are instantiated, set, and
> retrieved. Basically, variables are set on one entry and
> retrieved and used by a 'matching' event.
>
> - 'synthetic' events, combining variables from other events
>
> The trace event interface is based on pseudo-files associated with
> individual events, so it wouldn't really make sense to have
> quantities derived from multiple events attached to any one of
> those events. For that reason, the patchset implements a means of
> combining variables from other events into a separate 'synthetic'
> event, which can be treated as if it were just like any other
> trace event in the system.
>
> - 'actions' generating synthetic events, among other things
>
> Variables and synthetic events provide the data and data structure
> for new events, but something still needs to actually generate an
> event using that data. 'Actions' are expanded to provide that
> capability. Though it hasn't been explicitly called as much
> before, the default 'action' currently for a hist trigger is to
> update the matching histogram entry's sum values. This patchset
> essentially expands that to provide a new 'onmatch.trace(event)'
> action that can be used to have one event generate another. The
> mechanism is extensible to other actions, and in fact the patchset
> also includes another, 'onmax(var).save(field,...)' that can be
> used to save context whenever a value exceeds the previous maximum
> (something also needed by latency_hist).
>
> I'm submitting the patchset (based on tracing/for-next) as an RFC not
> only to get comments, but because there are still some problems I
> haven't fixed yet...
>
> Here are some examples that should make things less abstract.
>
> ====
> Example - wakeup latency
> ====
>
> This basically implements the -RT latency_hist 'wakeup_latency'
> histogram using the synthetic events, variables, and actions
> described. The output below is from a run of cyclictest using the
> following command:
>
> # rt-tests/cyclictest -p 80 -n -s -t 2
>
> What we're measuring the latency of is the time between when a
> thread (of cyclictest) is awakened and when it's scheduled in. To
> do that we add triggers to sched_wakeup and sched_switch with the
> appropriate variables, and on a matching sched_switch event,
> generate a synthetic 'wakeup_latency' event. Since it's just
> another trace event like any other, we can also define a histogram
> on that event, the output of which is what we see displayed when
> reading the wakeup_latency 'hist' file.
>
> First, we create a synthetic event called wakeup_latency, that
> references 3 variables from other events:
>
> # echo 'wakeup_latency lat=sched_switch:wakeup_lat \
> pid=sched_switch:woken_pid \
> prio=sched_switch:woken_prio' >> \
> /sys/kernel/debug/tracing/synthetic_events
>
> Next we add a trigger to sched_wakeup, which saves the value of the
> 'common_timestamp' when that event is hit in a variable, ts0. Note
> that this happens only when 'comm==cyclictest'.
>
> Also, 'common_timestamp' is a new field defined on every event (if
> needed - if there are no users of timestamps in a trace, timestamps
> won't be saved and there's no additional overhead from that).
>
> # echo 'hist:keys=pid:ts0=common_timestamp.usecs if \
> comm=="cyclictest"' >> \
> /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger
>
> Next, we add a trigger to sched_switch. When the pid being switched
> to matches the pid woken up by a previous sched_wakeup event, this
> event grabs the ts0 saved on that event, takes the difference
> between it and the current sched_switch's common_timestamp, and
> assigns it to a new 'wakeup_lat' variable. It also saves a couple
> other variables and then invokes the onmatch().trace() action which
> generates a new wakeup_latency event using those variables.
>
> # echo 'hist:keys=woken_pid=next_pid:woken_prio=next_prio:\
> wakeup_lat=common_timestamp.usecs-ts0:onmatch().trace(wakeup_latency) \
> if next_comm=="cyclictest"' >> \
> /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
As Masami said, I think the syntax is a bit hard to understand. Also
it'd be nice to access an event field directly (i.e. not by adding a
field in a hist). Maybe we can use a prefix like '$' to identify hist
fields..
How about below?
# echo 'wakeup_latency \
lat=sched_switch.$wakeup_lat \
pid=sched_switch.next_pid \
prio=sched_switch.next_prio' >> \
/sys/kernel/debug/tracing/synthetic_events
# echo 'hist: \
keys=pid: \
ts0=common_timestamp.usec \
if comm=="cyclictest"' >> \
/sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger
# echo 'hist: \
keys=next_pid: \
wakeup_lat=common_timestamp.usec-$ts0: \
onmatch(sched_wakeup).trace(wakeup_latency) \
if next_comm=="cyclictest"' >> \
/sys/kernel/debug/tracing/events/sched/sched_switch/trigger
By passing an event name to 'onmatch', we can know where to find $ts0
easily IMHO.
Thanks,
Namhyung
next prev parent reply other threads:[~2017-02-10 4:16 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 17:24 [RFC][PATCH 00/21] tracing: Inter-event (e.g. latency) support Tom Zanussi
2017-02-08 17:24 ` [RFC][PATCH 01/21] tracing: Add hist_field_name() accessor Tom Zanussi
2017-02-08 20:09 ` Steven Rostedt
2017-02-08 17:24 ` [RFC][PATCH 02/21] tracing: Reimplement log2 Tom Zanussi
2017-02-08 20:13 ` Steven Rostedt
2017-02-08 20:25 ` Tom Zanussi
2017-02-08 17:24 ` [RFC][PATCH 03/21] ring-buffer: Add TIME_EXTEND_ABS ring buffer type Tom Zanussi
2017-02-08 20:32 ` Steven Rostedt
2017-02-08 20:55 ` Tom Zanussi
2017-02-09 14:54 ` Steven Rostedt
2017-02-10 6:04 ` Namhyung Kim
2017-02-10 14:28 ` Steven Rostedt
2017-02-08 17:25 ` [RFC][PATCH 04/21] tracing: Give event triggers access to ring_buffer_event Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 05/21] tracing: Add ring buffer event param to hist field functions Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 06/21] tracing: Increase tracing map KEYS_MAX size Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 07/21] tracing: Break out hist trigger assignment parsing Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 08/21] tracing: Make traceprobe parsing code reusable Tom Zanussi
2017-02-09 20:40 ` Steven Rostedt
2017-02-08 17:25 ` [RFC][PATCH 09/21] tracing: Add hist trigger timestamp support Tom Zanussi
2017-02-10 6:14 ` Namhyung Kim
2017-02-08 17:25 ` [RFC][PATCH 10/21] tracing: Add per-element variable support to tracing_map Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 11/21] tracing: Add variable support to hist triggers Tom Zanussi
2017-02-13 6:03 ` Namhyung Kim
2017-02-14 15:25 ` Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 12/21] tracing: Account for variables in named trigger compatibility Tom Zanussi
2017-02-13 6:04 ` Namhyung Kim
2017-02-14 15:26 ` Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 13/21] tracing: Add simple expression support to hist triggers Tom Zanussi
2017-02-14 2:37 ` Namhyung Kim
2017-02-14 15:29 ` Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 14/21] tracing: Add variable reference handling " Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 15/21] tracing: Add usecs modifier for hist trigger timestamps Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 16/21] tracing: Add support for dynamic tracepoints Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 17/21] tracing: Add hist trigger action hook Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 18/21] tracing: Add support for 'synthetic' events Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 19/21] tracing: Add 'onmatch' hist trigger action support Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 20/21] tracing: Add 'onmax' " Tom Zanussi
2017-02-08 17:25 ` [RFC][PATCH 21/21] tracing: Add inter-event hist trigger Documentation Tom Zanussi
2017-02-08 20:01 ` [RFC][PATCH 00/21] tracing: Inter-event (e.g. latency) support Steven Rostedt
2017-02-08 20:19 ` Tom Zanussi
2017-02-08 23:28 ` Tom Zanussi
2017-02-09 2:14 ` Steven Rostedt
2017-02-08 23:13 ` Masami Hiramatsu
2017-02-09 1:14 ` Tom Zanussi
2017-02-09 14:18 ` Masami Hiramatsu
2017-02-09 17:18 ` Tom Zanussi
2017-02-09 19:57 ` Steven Rostedt
2017-02-09 14:46 ` Frank Ch. Eigler
2017-02-09 18:43 ` Tom Zanussi
2017-02-10 4:16 ` Namhyung Kim [this message]
2017-02-10 9:34 ` Masami Hiramatsu
2017-02-10 18:58 ` Tom Zanussi
2017-02-13 1:04 ` Namhyung Kim
2017-02-14 9:37 ` Masami Hiramatsu
2017-02-14 15:27 ` Tom Zanussi
2017-02-10 18:43 ` Tom Zanussi
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=20170210041617.GE599@sejong \
--to=namhyung@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tom.zanussi@linux.intel.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.