[PATCH v10 00/15] tracing: Hist trigger snapshot and onchange additions

From: Tom Zanussi
Date: Fri Dec 21 2018 - 11:29:25 EST

From: Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx>


This is v10 of the hist trigger snapshot and onchange additions

It doesn't add anything new - it's just a rebase of v9 on top of the
latest ftrace/core with conflicts due to the new strncmp_prefix()



v9->v10 changes:

- Updated to use strncmp_prefix() for static strings

v8->v9 changes:

- Moved v8 patches 17-22 to a separate series
- Moved track_data.var_ref_idx removal into 'tracing: Generalize
hist trigger onmax and save action'
- Merged 'tracing: Add hist trigger handler.action documentation'
into 'tracing: Refactor hist trigger action code'
- Updated patches to change all strlen() to sizeof() for string
- Moved test cases to the end of the series

v7->v8 changes:

- Removed /dev/null redirection from test cases
- Replaced event disable with tracing_on disable instead
- New patch to remove hist_field.var_idx and track_data.var_ref_idx
- New patch to use var_refs[] array for reference checking
- New patch to remove open-coding of var_ref count manipulation
- New patch to use var_refs[] array to destroy var_refs
- New patch to remove synth_var_refs[] now that var_refs[] is used
- New patch to add comments to variable-related fields
- Added various new comments in the patches to clarify other things
- Replaced the convoluted logic mentioned by Namhyung in
update_track_val with wrappers and simpler check/save logic as
- Rebased to latest ftrace/core including Masami's dynamic event
framework changes

v6->v7 changes:

- Removed unnecessary HANDLER_ONMAX checks from onmax_print()/create()
- Moved handler assignment to acion_parse()
- Changed goto in ATION_TRACE case in action_create() to return
- Changed EINVAL to EEXIST in action_create() ACTION_SAVE case
- Made the return logic in create_actions() more consistent
- Merged 'tracing: Move hist trigger key printing into a separate
function' into 'tracing: Add hist trigger snapshot() action'
- Updated the new snapshot, onchange, and trace test cases to match
4.20 kselftest changes.
- Added new xfail test case that make sure certain unsupported
handler/action combinations fail as expected.
- While updating the test cases, realized that the other testcases
in the inter-event subdir needed SPDX license updates, so added

v5->v6 changes:

- Added new Documentation patch explaining handler.action
- Added new README patch explaining handler.action
- Added separate snapshot() Documentation
- Added new snapshot() test case
- Updated README with snapshote()
- Added separate onchange() Documentation
- Added separate onchange() test case
- Updated README with onchange()
- Added separate trace() test case
- Updated README with trace() and <synthetic_event>() syntax

v4->v5 changes:

- added 'trace' keyword test case
- added 'onchange' handler test case

v3->v4 changes:

- added 'trace' keyword for generating synthetic events
- fix elt_data leak
- changed cond_update to cond_update_fn_t

v2->v3 changes:

- fixed problem where trace actions were only being allowed for
onmatch handlers - now trace actions can be used with any handler.
- fixed problem where no action was being assigned to onmatch
handlers if save or snapshot actions were specified.

v1->v2 changes:

- added missing tracing_cond_snapshot_data() definition for when
- removed an unnecessary WARN_ON() in track_data_snapshot_print()

Original text:

This patchset adds some useful new functions to the hist
trigger code: a snapshot action and an onchange handler.

In order to make it easier to add these and in the process make the
code more generic, I separated the code into explicit 'handlers' and
'actions', handlers being things like 'onmax' and 'onchange', and
'actions' being things like 'take a snapshot' or 'save some fields'.

The first few patches do that basic refactoring, which make it easier
to add the subsequent changes that arbitrarily combine actions and

The fourth patch adds a 'conditional snapshot' capability that via a
new tracing_snaphot_cond() function extends the existing snapshot
code. It allows the caller to associate some user data with the
snapshot that can be checked and saved in an update() callback whose
return value determines whether the snapshot should be taken or not.

The remaining patches finally add the new snapshot action and onchange
handler functionality - please see those patches for details and some



The following changes since commit 05cd667ce570cb82a967af7166c54c610324861c:

tracing: Use strncmp_prefix() helper for histogram code (2018-12-20 11:37:17 -0500)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-trace.git ftrace/hist-snapshot-onchange-v10

Tom Zanussi (15):
tracing: Refactor hist trigger action code
tracing: Make hist trigger Documentation better reflect
tracing: Split up onmatch action data
tracing: Generalize hist trigger onmax and save action
tracing: Add conditional snapshot
tracing: Add hist trigger snapshot() action
tracing: Add hist trigger snapshot() action Documentation
tracing: Add hist trigger onchange() handler
tracing: Add hist trigger onchange() handler Documentation
tracing: Add alternative synthetic event trace action syntax
tracing: Add SPDX license GPL-2.0 license identifier to inter-event
tracing: Add hist trigger snapshot() action test case
tracing: Add hist trigger onchange() handler test case
tracing: Add alternative synthetic event trace action test case
tracing: Add hist trigger action 'expected fail' test case

Documentation/trace/histogram.rst | 285 ++++-
kernel/trace/trace.c | 177 +++-
kernel/trace/trace.h | 56 +-
kernel/trace/trace_events_hist.c | 1090 +++++++++++++++-----
kernel/trace/trace_events_trigger.c | 2 +-
kernel/trace/trace_sched_wakeup.c | 2 +-
.../inter-event/trigger-action-hist-xfail.tc | 30 +
.../inter-event/trigger-extended-error-support.tc | 1 +
.../inter-event/trigger-field-variable-support.tc | 1 +
.../trigger-inter-event-combined-hist.tc | 1 +
.../inter-event/trigger-multi-actions-accept.tc | 1 +
.../inter-event/trigger-onchange-action-hist.tc | 28 +
.../inter-event/trigger-onmatch-action-hist.tc | 1 +
.../trigger-onmatch-onmax-action-hist.tc | 1 +
.../inter-event/trigger-onmax-action-hist.tc | 1 +
.../inter-event/trigger-snapshot-action-hist.tc | 43 +
.../trigger-synthetic-event-createremove.tc | 1 +
.../inter-event/trigger-trace-action-hist.tc | 42 +
18 files changed, 1455 insertions(+), 308 deletions(-)
create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc
create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc