tracing: Make synthetic events a separate option
v2 cover tracing: Make synthetic events a separate option
Hi Steve,
These are the same patches as v1, but after posting v1 I realized that if you applied them on top of the other patchset I posted awhile back ("[PATCH 0/3] tracing: histogram internals doc, hist_debug, and misc") [1], you wouldn't be able to apply these.
So assuming you apply the other patchset first, these should apply cleanly on top of those.
Thanks,
Tom
[1] https://lore.kernel.org/lkml/[email protected]/
v1 text:
Since synthetic events can now be used separately from hist triggers, it makes sense to actually separate them into different options. It also makes sense in terms of file bloat - trace_events_hist.c was getting very large and this makes it smaller and easier to follow.
Thanks,
Tom
The following changes since commit 77914c22b0ba493d9783c53bbfbc6087d6a7e1b1:
tracing: Add hist_debug trace event files for histogram debugging (2020-04-03 13:46:05 -0500)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-trace.git ftrace/separate-synth-v2
Tom Zanussi (2):
tracing: Move synthetic events to a separate file selftests/ftrace: Distinguish between hist and synthetic event checks
kernel/trace/Kconfig | 20 +- kernel/trace/Makefile | 1 + kernel/trace/trace_events_hist.c | 2071 ++--------------- kernel/trace/trace_events_synth.c | 1789 ++++++++++++++ kernel/trace/trace_synth.h | 36 + .../trigger-field-variable-support.tc | 5 + .../trigger-inter-event-combined-hist.tc | 5 + .../trigger-multi-actions-accept.tc | 5 + .../trigger-onmatch-action-hist.tc | 5 + .../trigger-onmatch-onmax-action-hist.tc | 5 + .../inter-event/trigger-onmax-action-hist.tc | 5 + .../trigger-snapshot-action-hist.tc | 5 + .../inter-event/trigger-trace-action-hist.tc | 5 + 13 files changed, 2029 insertions(+), 1928 deletions(-) create mode 100644 kernel/trace/trace_events_synth.c create mode 100644 kernel/trace/trace_synth.h
Signature · 1 line
2.17.1
PATCH v2 2/2 selftests/ftrace: Distinguish between hist and synthetic event checks
With synthetic events now a separate config item as a result of 'tracing: Move synthetic events to a separate file', tests that use both need to explicitly check for hist trigger support rather than relying on hist triggers to pull in synthetic events.
Add an additional hist trigger check to all the trigger tests that now require it, otherwise they'll fail if synthetic events but not hist triggers are enabled.
--- .../trigger/inter-event/trigger-field-variable-support.tc | 5 +++++ .../trigger/inter-event/trigger-inter-event-combined-hist.tc | 5 +++++ .../trigger/inter-event/trigger-multi-actions-accept.tc | 5 +++++ .../trigger/inter-event/trigger-onmatch-action-hist.tc | 5 +++++ .../trigger/inter-event/trigger-onmatch-onmax-action-hist.tc | 5 +++++ .../test.d/trigger/inter-event/trigger-onmax-action-hist.tc | 5 +++++ .../trigger/inter-event/trigger-snapshot-action-hist.tc | 5 +++++ .../test.d/trigger/inter-event/trigger-trace-action-hist.tc | 5 +++++ 8 files changed, 40 insertions(+)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test field variable support" echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'waking_latency u64 lat pid_t pid' > synthetic_events
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test multiple actions on hist trigger" echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events TRIGGER1=events/sched/sched_wakeup/trigger
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc +5 -0
@@ -12,6 +12,11 @@ if [ ! -f set_event ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + if [ ! -f snapshot ]; then echo "snapshot is not supported" exit_unsupported
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc +5 -0
@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + grep -q "trace(<synthetic_event>" README || exit_unsupported # version issue echo "Test create synthetic event"
Signature · 1 line
2.17.1
PATCH v2 1/2 tracing: Move synthetic events to a separate file
In reply to Tom ZanussiWith the addition of the in-kernel synthetic event API, synthetic events are no longer specifically tied to the histogram triggers.
The synthetic event code is also making trace_event_hist.c very bloated, so for those reasons, move it to a separate file, trace_events_synth.c, along with a new trace_synth.h header file.
Because synthetic events are now independent from hist triggers, add a new CONFIG_SYNTH_EVENTS config option, and have CONFIG_HIST_TRIGGERS select it, and have CONFIG_SYNTH_EVENT_GEN_TEST depend on it.
--- kernel/trace/Kconfig | 20 +- kernel/trace/Makefile | 1 + kernel/trace/trace_events_hist.c | 2071 ++--------------------------- kernel/trace/trace_events_synth.c | 1789 +++++++++++++++++++++++++ kernel/trace/trace_synth.h | 36 + 5 files changed, 1989 insertions(+), 1928 deletions(-) create mode 100644 kernel/trace/trace_events_synth.c create mode 100644 kernel/trace/trace_synth.h
kernel/trace/Kconfig +19 -1
@@ -624,12 +624,30 @@ config TRACING_MAP generally used outside of that context, and is normally selected by tracers that use it. +config SYNTH_EVENTS + bool "Synthetic trace events" + select TRACING + select DYNAMIC_EVENTS + default n + help + Synthetic events are user-defined trace events that can be + used to combine data from other trace events or in fact any + data source. Synthetic events can be generated indirectly + via the trace() action of histogram triggers or directly + by way of an in-kernel API. + + See Documentation/trace/events.rst or + Documentation/trace/histogram.rst for details and examples. + + If in doubt, say N. + config HIST_TRIGGERS bool "Histogram triggers" depends on ARCH_HAVE_NMI_SAFE_CMPXCHG select TRACING_MAP select TRACING select DYNAMIC_EVENTS + select SYNTH_EVENTS default n help Hist triggers allow one or more arbitrary trace event fields
@@ -825,7 +843,7 @@ config PREEMPTIRQ_DELAY_TEST config SYNTH_EVENT_GEN_TEST tristate "Test module for in-kernel synthetic event generation" - depends on HIST_TRIGGERS + depends on SYNTH_EVENTS help This option creates a test module to check the base functionality of in-kernel synthetic event definition and
kernel/trace/Makefile +1 -0
@@ -72,6 +72,7 @@ endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_EVENT_TRACING) += trace_events_trigger.o obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o +obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o
kernel/trace/trace_events_hist.c +144 -1927
2,145 lines not on this page · raw message
kernel/trace/trace_events_synth.c new file +1789 -0
810 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 2/2] selftests/ftrace: Distinguish between hist and synthetic event checks
In reply to Tom ZanussiHi Tom,
Quoted 8 lines · On Thu, 28 May 2020 14:32:38 -0500 Tom Zanussi <[email protected]> wrote:
With synthetic events now a separate config item as a result of 'tracing: Move synthetic events to a separate file', tests that use both need to explicitly check for hist trigger support rather than relying on hist triggers to pull in synthetic events.
Add an additional hist trigger check to all the trigger tests that now require it, otherwise they'll fail if synthetic events but not hist triggers are enabled.
OK, this looks good to me. And if you don't want to repeat it, you can also put the check function into the test.d/functions.
Thank you,
Quoted 144 lines
Signed-off-by Tom Zanussi <[email protected]>--- .../trigger/inter-event/trigger-field-variable-support.tc | 5 +++++ .../trigger/inter-event/trigger-inter-event-combined-hist.tc | 5 +++++ .../trigger/inter-event/trigger-multi-actions-accept.tc | 5 +++++ .../trigger/inter-event/trigger-onmatch-action-hist.tc | 5 +++++ .../trigger/inter-event/trigger-onmatch-onmax-action-hist.tc | 5 +++++ .../test.d/trigger/inter-event/trigger-onmax-action-hist.tc | 5 +++++ .../trigger/inter-event/trigger-snapshot-action-hist.tc | 5 +++++ .../test.d/trigger/inter-event/trigger-trace-action-hist.tc | 5 +++++ 8 files changed, 40 insertions(+)tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test field variable support" echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_eventstools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'waking_latency u64 lat pid_t pid' > synthetic_eventstools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test multiple actions on hist trigger" echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events TRIGGER1=events/sched/sched_wakeup/triggertools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_eventstools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_eventstools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_eventstools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc +5
-0@@ -12,6 +12,11 @@ if [ ! -f set_event ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + if [ ! -f snapshot ]; then echo "snapshot is not supported" exit_unsupportedtools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc +5
-0@@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi +if [ ! -f events/sched/sched_process_fork/hist ]; then + echo "hist trigger is not supported" + exit_unsupported +fi + grep -q "trace(<synthetic_event>" README || exit_unsupported # version issue echo "Test create synthetic event"Signature · 1 line
2.17.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
Steven Rostedt
maintainerRe: [PATCH v2 2/2] selftests/ftrace: Distinguish between hist and synthetic event checks
Quoted 10 lines · On Fri, 29 May 2020 23:38:45 +0900 Masami Hiramatsu <[email protected]> wrote:
Hi Tom,
Quoted 5 lines · On Thu, 28 May 2020 14:32:38 -0500 Tom Zanussi <[email protected]> wrote:
With synthetic events now a separate config item as a result of 'tracing: Move synthetic events to a separate file', tests that use both need to explicitly check for hist trigger support rather than relying on hist triggers to pull in synthetic events.
Quoted 8 lines
Quoted 3 lines
Add an additional hist trigger check to all the trigger tests that now require it, otherwise they'll fail if synthetic events but not hist triggers are enabled.
OK, this looks good to me. And if you don't want to repeat it, you can also put the check function into the test.d/functions.
Acked-by Masami Hiramatsu <[email protected]>
Thanks Tom and Masami. I'm running tests on these now.
-- Steve