[PATCH 0/2] trace-cmd reset: Add option to preserve specific events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We may want to preserve some of the dynamic events (e.g., kprobes)
during a "trace-cmd reset" in some cases as discussed at [1]. Thus,
introduce a new command line option to "trace-cmd reset" to permit
sustaining specified events across reset.

To implement the necessary support, address a corner case in command
line option parsing handler in "trace-cmd reset" first. Because all
dynamic events gets destroyed even if the user passes an invalid
parameter to "trace-cmd reset".

Here is an example usage with the new command line option (-k):

    # trace-cmd reset -h

    trace-cmd version 3.3.0 (e4047ab9dfe261402e487a825bf79d04f10f5544+)

    usage:
     trace-cmd reset [-b size][-B buf][-k event][-a][-d][-t]
              Disables the tracer (may reset trace file)
              Used in conjunction with start
              -b change the kernel buffer size (in kilobytes per CPU)
              -d delete the previous specified instance
              -B reset the given buffer instance (may specify multiple -B)
              -a reset all instances (except top one)
              -t reset the top level instance (useful with -B or -a)
              -k keep dynamic event during reset. Valid values:
                  'kprobe', 'kretprobe', 'uprobe', 'uretprobe',
                  'eprobe', 'synth' and 'all'.

    # Add kprobe and kretprobe for sys_open():
    $ echo 'p do_sys_open' > /sys/kernel/tracing/kprobe_events
    $ echo 1 > /sys/kernel/tracing/events/kprobes/p_do_sys_open_0/enable
    $ echo 'r do_sys_open' >> /sys/kernel/tracing/kprobe_events
    $ echo 1 > /sys/kernel/tracing/events/kprobes/r_do_sys_open_0/enable
    $ cat /sys/kernel/tracing/kprobe_events
    p:kprobes/p_do_sys_open_0 do_sys_open
    r128:kprobes/r_do_sys_open_0 do_sys_open

    # Issue reset, but keep kprobes and kretprobes ('-k all' would keep
    # all existing dynamic events):
    $ trace-cmd reset -k kprobe -k kretprobe
    $ cat /sys/kernel/tracing/kprobe_events
    p:kprobes/p_do_sys_open_0 do_sys_open
    r128:kprobes/r_do_sys_open_0 do_sys_open

    # Issue reset, but this time only keep kretprobes:
    $ trace-cmd reset -k kretprobe
    $ cat /sys/kernel/tracing/kprobe_events
    r128:kprobes/r_do_sys_open_0 do_sys_open

    # Don't preserve any dynamic event:
    $ trace-cmd reset
    $ cat /sys/kernel/tracing/kprobe_events
    $

[1] https://bugzilla.kernel.org/show_bug.cgi?id=219302

Metin Kaya (2):
  trace-cmd reset: Bail out immediately if user provides an invalid
    option
  trace-cmd reset: Add option to preserve specific dynamic events

 tracecmd/trace-record.c | 62 +++++++++++++++++++++++++++++++++++++----
 tracecmd/trace-usage.c  |  5 +++-
 2 files changed, 60 insertions(+), 7 deletions(-)

-- 
2.34.1





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux