Skip to content

tracing: Clean up trigger code my merging structures

Steven Rostedt linux-trace-kernel lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v12 patches 3 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2tracing: Remove get_trigger_ops() and add count_func() from trigger opskernel/trace/trace.h kernel/trace/trace_eprobe.c kernel/trace/trace_events_hist.c +1 more+116 -2350 replies
2/2tracing: Merge struct event_trigger_ops into struct event_commandkernel/trace/trace.h kernel/trace/trace_eprobe.c kernel/trace/trace_events_hist.c +1 more+151 -2020 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchTom Zanussi
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] tracing: Clean up trigger code my merging structures

The struct event_command has a callback function called get_trigger_ops(). This callback returns the "trigger_ops" to use for the trigger. These ops define the trigger function, how to init the trigger, how to print the trigger and how to free it.

The only reason there's a callback function to get these ops is because some triggers have two types of operations. One is an "always on" operation, and the other is a "count down" operation. If a user passes in a parameter to say how many times the trigger should execute. For example:

echo stacktrace:5 > events/kmem/kmem_cache_alloc/trigger

It will trigger the stacktrace for the first 5 times the kmem_cache_alloc event is hit.

Instead of having two different trigger_ops since the only difference between them is the tigger itself (the print, init and free functions are all the same), just use a single ops that the event_command points to and add a function field to the trigger_ops to have a count_func.

When a trigger is added to an event, if there's a count attached to it and the trigger ops has the count_func field, the data allocated to represent this trigger will have a new flag set called COUNT.

Then when the trigger executes, it will check if the COUNT data flag is set, and if so, it will call the ops count_func(). If that returns false, it returns without executing the trigger.

After making the struct event_trigger_ops be mapped one to one with the struct event_command, merge the former into the latter.

Changes since v1: https://lore.kernel.org/linux-trace-kernel/[email protected]

- Removed duplicate declaration of trigger_hist_cmd (Tom Zanussi)

Steven Rostedt (2):
tracing: Remove get_trigger_ops() and add count_func() from trigger ops
tracing: Merge struct event_trigger_ops into struct event_command

----

 kernel/trace/trace.h                | 124 ++++++-------
 kernel/trace/trace_eprobe.c         |  19 +-
 kernel/trace/trace_events_hist.c    | 143 +++++----------
 kernel/trace/trace_events_trigger.c | 344 +++++++++++++-----------------------
 4 files changed, 230 insertions(+), 400 deletions(-)