24 Feb, 2020

1 commit

  • [ Upstream commit 6722b23e7a2ace078344064a9735fb73e554e9ef ]

    if seq_file .next fuction does not change position index,
    read after some lseek can generate unexpected output.

    Without patch:
    # dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger
    dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset
    n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist
    # Available triggers:
    # traceon traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist
    6+1 records in
    6+1 records out
    206 bytes copied, 0.00027916 s, 738 kB/s

    Notice the printing of "# Available triggers:..." after the line.

    With the patch:
    # dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger
    dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset
    n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist
    2+1 records in
    2+1 records out
    88 bytes copied, 0.000526867 s, 167 kB/s

    It only prints the end of the file, and does not restart.

    Link: http://lkml.kernel.org/r/3c35ee24-dd3a-8119-9c19-552ed253388a@virtuozzo.com

    https://bugzilla.kernel.org/show_bug.cgi?id=206283
    Signed-off-by: Vasily Averin
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Sasha Levin

    Vasily Averin
     

29 Jan, 2020

1 commit

  • commit aeed8aa3874dc15b9d82a6fe796fd7cfbb684448 upstream.

    With CONFIG_PROVE_RCU_LIST, I had many suspicious RCU warnings
    when I ran ftracetest trigger testcases.

    -----
    # dmesg -c > /dev/null
    # ./ftracetest test.d/trigger
    ...
    # dmesg | grep "RCU-list traversed" | cut -f 2 -d ] | cut -f 2 -d " "
    kernel/trace/trace_events_hist.c:6070
    kernel/trace/trace_events_hist.c:1760
    kernel/trace/trace_events_hist.c:5911
    kernel/trace/trace_events_trigger.c:504
    kernel/trace/trace_events_hist.c:1810
    kernel/trace/trace_events_hist.c:3158
    kernel/trace/trace_events_hist.c:3105
    kernel/trace/trace_events_hist.c:5518
    kernel/trace/trace_events_hist.c:5998
    kernel/trace/trace_events_hist.c:6019
    kernel/trace/trace_events_hist.c:6044
    kernel/trace/trace_events_trigger.c:1500
    kernel/trace/trace_events_trigger.c:1540
    kernel/trace/trace_events_trigger.c:539
    kernel/trace/trace_events_trigger.c:584
    -----

    I investigated those warnings and found that the RCU-list
    traversals in event trigger and hist didn't need to use
    RCU version because those were called only under event_mutex.

    I also checked other RCU-list traversals related to event
    trigger list, and found that most of them were called from
    event_hist_trigger_func() or hist_unregister_trigger() or
    register/unregister functions except for a few cases.

    Replace these unneeded RCU-list traversals with normal list
    traversal macro and lockdep_assert_held() to check the
    event_mutex is held.

    Link: http://lkml.kernel.org/r/157680910305.11685.15110237954275915782.stgit@devnote2

    Cc: stable@vger.kernel.org
    Fixes: 30350d65ac567 ("tracing: Add variable support to hist triggers")
    Reviewed-by: Tom Zanussi
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     

13 Oct, 2019

1 commit

  • Added various checks on open tracefs calls to see if tracefs is in lockdown
    mode, and if so, to return -EPERM.

    Note, the event format files (which are basically standard on all machines)
    as well as the enabled_functions file (which shows what is currently being
    traced) are not lockde down. Perhaps they should be, but it seems counter
    intuitive to lockdown information to help you know if the system has been
    modified.

    Link: http://lkml.kernel.org/r/CAHk-=wj7fGPKUspr579Cii-w_y60PtRaiDgKuxVtBAMK0VNNkA@mail.gmail.com

    Suggested-by: Linus Torvalds
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

08 Apr, 2019

1 commit

  • Pass in the trace_array that represents the instance the filter being
    changed is in to create_event_filter(). This will allow for error messages
    that happen when writing to the filter can be displayed in the proper
    instance "error_log" file.

    Note, for calls to create_filter() (that was also modified to support
    create_event_filter()), that changes filters that do not exist in a instance
    (for perf for example), NULL may be passed in, which means that there will
    not be any message to log for that filter.

    Reviewed-by: Masami Hiramatsu
    Reviewed-by: Tom Zanussi
    Tested-by: Tom Zanussi
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

12 Dec, 2018

1 commit

  • When create_event_filter() fails in set_trigger_filter(), the filter may
    still be allocated and needs to be freed. The caller expects the
    data->filter to be updated with the new filter, even if the new filter
    failed (we could add an error message by setting set_str parameter of
    create_event_filter(), but that's another update).

    But because the error would just exit, filter was left hanging and
    nothing could free it.

    Found by kmemleak detector.

    Cc: stable@vger.kernel.org
    Fixes: bac5fb97a173a ("tracing: Add and use generic set_trigger_filter() implementation")
    Reviewed-by: Tom Zanussi
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

17 Aug, 2018

1 commit


11 Aug, 2018

1 commit

  • Now that some trace events can be protected by srcu_read_lock(tracepoint_srcu),
    we need to make sure all locations that depend on this are also protected.
    There were many places that did a synchronize_sched() thinking that it was
    enough to protect againts access to trace events. This use to be the case,
    but now that we use SRCU for _rcuidle() trace events, they may not be
    protected by synchronize_sched(), as they may be called in paths that RCU is
    not watching for preempt disable.

    Fixes: e6753f23d961d ("tracepoint: Make rcuidle tracepoint callers use SRCU")
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

26 Jul, 2018

2 commits

  • Nothing uses unregister_trigger() outside of trace_events_trigger.c file,
    thus it should be static. Not sure why this was ever converted, because
    its counter part, register_trigger(), was always static.

    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • There was a case that triggered a double free in event_trigger_callback()
    due to the called reg() function freeing the trigger_data and then it
    getting freed again by the error return by the caller. The solution there
    was to up the trigger_data ref count.

    Code inspection found that event_enable_trigger_func() has the same issue,
    but is not as easy to trigger (requires harder to trigger failures). It
    needs to be solved slightly different as it needs more to clean up when the
    reg() function fails.

    Link: http://lkml.kernel.org/r/20180725124008.7008e586@gandalf.local.home

    Cc: stable@vger.kernel.org
    Fixes: 7862ad1846e99 ("tracing: Add 'enable_event' and 'disable_event' event trigger commands")
    Reivewed-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

25 Jul, 2018

1 commit

  • Running the following:

    # cd /sys/kernel/debug/tracing
    # echo 500000 > buffer_size_kb
    [ Or some other number that takes up most of memory ]
    # echo snapshot > events/sched/sched_switch/trigger

    Triggers the following bug:

    ------------[ cut here ]------------
    kernel BUG at mm/slub.c:296!
    invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
    CPU: 6 PID: 6878 Comm: bash Not tainted 4.18.0-rc6-test+ #1066
    Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
    RIP: 0010:kfree+0x16c/0x180
    Code: 05 41 0f b6 72 51 5b 5d 41 5c 4c 89 d7 e9 ac b3 f8 ff 48 89 d9 48 89 da 41 b8 01 00 00 00 5b 5d 41 5c 4c 89 d6 e9 f4 f3 ff ff 0b 0f 0b 48 8b 3d d9 d8 f9 00 e9 c1 fe ff ff 0f 1f 40 00 0f 1f
    RSP: 0018:ffffb654436d3d88 EFLAGS: 00010246
    RAX: ffff91a9d50f3d80 RBX: ffff91a9d50f3d80 RCX: ffff91a9d50f3d80
    RDX: 00000000000006a4 RSI: ffff91a9de5a60e0 RDI: ffff91a9d9803500
    RBP: ffffffff8d267c80 R08: 00000000000260e0 R09: ffffffff8c1a56be
    R10: fffff0d404543cc0 R11: 0000000000000389 R12: ffffffff8c1a56be
    R13: ffff91a9d9930e18 R14: ffff91a98c0c2890 R15: ffffffff8d267d00
    FS: 00007f363ea64700(0000) GS:ffff91a9de580000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 000055c1cacc8e10 CR3: 00000000d9b46003 CR4: 00000000001606e0
    Call Trace:
    event_trigger_callback+0xee/0x1d0
    event_trigger_write+0xfc/0x1a0
    __vfs_write+0x33/0x190
    ? handle_mm_fault+0x115/0x230
    ? _cond_resched+0x16/0x40
    vfs_write+0xb0/0x190
    ksys_write+0x52/0xc0
    do_syscall_64+0x5a/0x160
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x7f363e16ab50
    Code: 73 01 c3 48 8b 0d 38 83 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 79 db 2c 00 00 75 10 b8 01 00 00 00 0f 05 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 1e e3 01 00 48 89 04 24
    RSP: 002b:00007fff9a4c6378 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
    RAX: ffffffffffffffda RBX: 0000000000000009 RCX: 00007f363e16ab50
    RDX: 0000000000000009 RSI: 000055c1cacc8e10 RDI: 0000000000000001
    RBP: 000055c1cacc8e10 R08: 00007f363e435740 R09: 00007f363ea64700
    R10: 0000000000000073 R11: 0000000000000246 R12: 0000000000000009
    R13: 0000000000000001 R14: 00007f363e4345e0 R15: 00007f363e4303c0
    Modules linked in: ip6table_filter ip6_tables snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_seq snd_seq_device i915 snd_pcm snd_timer i2c_i801 snd soundcore i2c_algo_bit drm_kms_helper
    86_pkg_temp_thermal video kvm_intel kvm irqbypass wmi e1000e
    ---[ end trace d301afa879ddfa25 ]---

    The cause is because the register_snapshot_trigger() call failed to
    allocate the snapshot buffer, and then called unregister_trigger()
    which freed the data that was passed to it. Then on return to the
    function that called register_snapshot_trigger(), as it sees it
    failed to register, it frees the trigger_data again and causes
    a double free.

    By calling event_trigger_init() on the trigger_data (which only ups
    the reference counter for it), and then event_trigger_free() afterward,
    the trigger_data would not get freed by the registering trigger function
    as it would only up and lower the ref count for it. If the register
    trigger function fails, then the event_trigger_free() called after it
    will free the trigger data normally.

    Link: http://lkml.kernel.org/r/20180724191331.738eb819@gandalf.local.home

    Cc: stable@vger.kerne.org
    Fixes: 93e31ffbf417 ("tracing: Add 'snapshot' event trigger command")
    Reported-by: Masami Hiramatsu
    Reviewed-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

29 May, 2018

2 commits

  • Trace event triggers can be called before or after the event has been
    committed. If it has been called after the commit, there's a possibility
    that the event no longer exists. Currently, the two post callers is the
    trigger to disable tracing (traceoff) and the one that will record a stack
    dump (stacktrace). Neither of them reference the trace event entry record,
    as that would lead to a race condition that could pass in corrupted data.

    To prevent any other users of the post data triggers from using the trace
    event record, pass in NULL to the post call trigger functions for the event
    record, as they should never need to use them in the first place.

    This does not fix any bug, but prevents bugs from happening by new post call
    trigger users.

    Reviewed-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • The snapshot trigger currently only affects the main ring buffer, even when
    it is used by the instances. This can be confusing as the snapshot trigger
    is listed in the instance.

    > # cd /sys/kernel/tracing
    > # mkdir instances/foo
    > # echo snapshot > instances/foo/events/syscalls/sys_enter_fchownat/trigger
    > # echo top buffer > trace_marker
    > # echo foo buffer > instances/foo/trace_marker
    > # touch /tmp/bar
    > # chown rostedt /tmp/bar
    > # cat instances/foo/snapshot
    # tracer: nop
    #
    #
    # * Snapshot is freed *
    #
    # Snapshot commands:
    # echo 0 > snapshot : Clears and frees snapshot buffer
    # echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.
    # Takes a snapshot of the main buffer.
    # echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)
    # (Doesn't have to be '2' works with any number that
    # is not a '0' or '1')

    > # cat snapshot
    # tracer: nop
    #
    # _-----=> irqs-off
    # / _----=> need-resched
    # | / _---=> hardirq/softirq
    # || / _--=> preempt-depth
    # ||| / delay
    # TASK-PID CPU# |||| TIMESTAMP FUNCTION
    # | | | |||| | |
    bash-1189 [000] .... 111.488323: tracing_mark_write: top buffer

    Not only did the snapshot occur in the top level buffer, but the instance
    snapshot buffer should have been allocated, and it is still free.

    Cc: stable@vger.kernel.org
    Fixes: 85f2b08268c01 ("tracing: Add basic event trigger framework")
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

28 May, 2018

1 commit

  • If a instance has an event trigger enabled when it is freed, it could cause
    an access of free memory. Here's the case that crashes:

    # cd /sys/kernel/tracing
    # mkdir instances/foo
    # echo snapshot > instances/foo/events/initcall/initcall_start/trigger
    # rmdir instances/foo

    Would produce:

    general protection fault: 0000 [#1] PREEMPT SMP PTI
    Modules linked in: tun bridge ...
    CPU: 5 PID: 6203 Comm: rmdir Tainted: G W 4.17.0-rc4-test+ #933
    Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
    RIP: 0010:clear_event_triggers+0x3b/0x70
    RSP: 0018:ffffc90003783de0 EFLAGS: 00010286
    RAX: 0000000000000000 RBX: 6b6b6b6b6b6b6b2b RCX: 0000000000000000
    RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8800c7130ba0
    RBP: ffffc90003783e00 R08: ffff8801131993f8 R09: 0000000100230016
    R10: ffffc90003783d80 R11: 0000000000000000 R12: ffff8800c7130ba0
    R13: ffff8800c7130bd8 R14: ffff8800cc093768 R15: 00000000ffffff9c
    FS: 00007f6f4aa86700(0000) GS:ffff88011eb40000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007f6f4a5aed60 CR3: 00000000cd552001 CR4: 00000000001606e0
    Call Trace:
    event_trace_del_tracer+0x2a/0xc5
    instance_rmdir+0x15c/0x200
    tracefs_syscall_rmdir+0x52/0x90
    vfs_rmdir+0xdb/0x160
    do_rmdir+0x16d/0x1c0
    __x64_sys_rmdir+0x17/0x20
    do_syscall_64+0x55/0x1a0
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    This was due to the call the clears out the triggers when an instance is
    being deleted not removing the trigger from the link list.

    Cc: stable@vger.kernel.org
    Fixes: 85f2b08268c01 ("tracing: Add basic event trigger framework")
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

11 Mar, 2018

2 commits

  • Add the necessary infrastructure to allow the variables defined on one
    event to be referenced in another. This allows variables set by a
    previous event to be referenced and used in expressions combining the
    variable values saved by that previous event and the event fields of
    the current event. For example, here's how a latency can be
    calculated and saved into yet another variable named 'wakeup_lat':

    # echo 'hist:keys=pid,prio:ts0=common_timestamp ...
    # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ...

    In the first event, the event's timetamp is saved into the variable
    ts0. In the next line, ts0 is subtracted from the second event's
    timestamp to produce the latency.

    Further users of variable references will be described in subsequent
    patches, such as for instance how the 'wakeup_lat' variable above can
    be displayed in a latency histogram.

    Link: http://lkml.kernel.org/r/b1d3e6975374e34d501ff417c20189c3f9b2c7b8.1516069914.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Signed-off-by: Steven Rostedt (VMware)

    Tom Zanussi
     
  • The ring_buffer event can provide a timestamp that may be useful to
    various triggers - pass it into the handlers for that purpose.

    Link: http://lkml.kernel.org/r/6de592683b59fa70ffa5d43d0109896623fc1367.1516069914.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Signed-off-by: Steven Rostedt (VMware)

    Tom Zanussi
     

24 Jan, 2018

1 commit


02 Mar, 2017

1 commit


23 Sep, 2016

1 commit

  • Call traceoff trigger after the event is recorded.
    Since current traceoff trigger is called before recording
    the event, we can not know what event stopped tracing.

    Typical usecase of traceoff/traceon trigger is tracing
    function calls and trace events between a pair of events.
    For example, trace function calls between syscall entry/exit.
    In that case, it is useful if we can see the return code
    of the target syscall.

    Link: http://lkml.kernel.org/r/147335074530.12462.4526186083406015005.stgit@devbox

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

20 Apr, 2016

3 commits

  • Named triggers are sets of triggers that share a common set of trigger
    data. An example of functionality that could benefit from this type
    of capability would be a set of inlined probes that would each
    contribute event counts, for example, to a shared counter data
    structure.

    The first named trigger registered with a given name owns the common
    trigger data that the others subsequently registered with the same
    name will reference. The functions defined here allow users to add,
    delete, and find named triggers.

    It also adds functions to pause and unpause named triggers; since
    named triggers act upon common data, they should also be paused and
    unpaused as a group.

    Link: http://lkml.kernel.org/r/c09ff648360f65b10a3e321eddafe18060b4a04f.1457029949.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • Similar to enable_event/disable_event triggers, these triggers enable
    and disable the aggregation of events into maps rather than enabling
    and disabling their writing into the trace buffer.

    They can be used to automatically start and stop hist triggers based
    on a matching filter condition.

    If there's a paused hist trigger on system:event, the following would
    start it when the filter condition was hit:

    # echo enable_hist:system:event [ if filter] > event/trigger

    And the following would disable a running system:event hist trigger:

    # echo disable_hist:system:event [ if filter] > event/trigger

    See Documentation/trace/events.txt for real examples.

    Link: http://lkml.kernel.org/r/f812f086e52c8b7c8ad5443487375e03c96a601f.1457029949.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • 'hist' triggers allow users to continually aggregate trace events,
    which can then be viewed afterwards by simply reading a 'hist' file
    containing the aggregation in a human-readable format.

    The basic idea is very simple and boils down to a mechanism whereby
    trace events, rather than being exhaustively dumped in raw form and
    viewed directly, are automatically 'compressed' into meaningful tables
    completely defined by the user.

    This is done strictly via single-line command-line commands and
    without the aid of any kind of programming language or interpreter.

    A surprising number of typical use cases can be accomplished by users
    via this simple mechanism. In fact, a large number of the tasks that
    users typically do using the more complicated script-based tracing
    tools, at least during the initial stages of an investigation, can be
    accomplished by simply specifying a set of keys and values to be used
    in the creation of a hash table.

    The Linux kernel trace event subsystem happens to provide an extensive
    list of keys and values ready-made for such a purpose in the form of
    the event format files associated with each trace event. By simply
    consulting the format file for field names of interest and by plugging
    them into the hist trigger command, users can create an endless number
    of useful aggregations to help with investigating various properties
    of the system. See Documentation/trace/events.txt for examples.

    hist triggers are implemented on top of the existing event trigger
    infrastructure, and as such are consistent with the existing triggers
    from a user's perspective as well.

    The basic syntax follows the existing trigger syntax. Users start an
    aggregation by writing a 'hist' trigger to the event of interest's
    trigger file:

    # echo hist:keys=xxx [ if filter] > event/trigger

    Once a hist trigger has been set up, by default it continually
    aggregates every matching event into a hash table using the event key
    and a value field named 'hitcount'.

    To view the aggregation at any point in time, simply read the 'hist'
    file in the same directory as the 'trigger' file:

    # cat event/hist

    The detailed syntax provides additional options for user control, and
    is described exhaustively in Documentation/trace/events.txt and in the
    virtual tracing/README file in the tracing subsystem.

    Link: http://lkml.kernel.org/r/72d263b5e1853fe9c314953b65833c3aa75479f2.1457029949.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     

09 Mar, 2016

6 commits

  • gcc isn't known for handling bool in structures. Instead of using bool, use
    an integer mask and use bit flags instead.

    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     
  • Add a new unreg_all() callback that can be used to remove all
    command-specific triggers from an event and arrange to have it called
    whenever a trigger file is opened with O_TRUNC set.

    Commands that don't want truncate semantics, or existing commands that
    don't implement this function simply do nothing and their triggers
    remain intact.

    Link: http://lkml.kernel.org/r/2b7d62854d01f28c19185e1bbb8f826f385edfba.1449767187.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • Add a new needs_rec flag for triggers that require unconditional
    access to trace records in order to function.

    Normally a trigger requires access to the contents of a trace record
    only if it has a filter associated with it (since filters need the
    contents of a record in order to make a filtering decision). Some
    types of triggers, such as 'hist' triggers, require access to trace
    record contents independent of the presence of filters, so add a new
    flag for those triggers.

    Link: http://lkml.kernel.org/r/7be8fa38f9b90fdb6c47ca0f98d20a07b9fd512b.1449767187.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • Add a simple per-trigger 'paused' flag, allowing individual triggers
    to pause. We could leave it to individual triggers that need this
    functionality to do it themselves, but we also want to allow other
    events to control pausing, so add it to the trigger data.

    Link: http://lkml.kernel.org/r/fed37e4879684d7dcc57fe00ce0cbf170032b06d.1449767187.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • Some triggers may need access to the trace event, so pass it in. Also
    fix up the existing trigger funcs and their callers.

    Link: http://lkml.kernel.org/r/543e31e9fc445ef61077421ab219033401c39846.1449767187.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     
  • Make various event trigger utility functions available outside of
    trace_events_trigger.c so that new triggers can be defined outside of
    that file.

    Link: http://lkml.kernel.org/r/4a40c1695dd43cac6cd475d72e13ffe30ba84bff.1449767187.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Tested-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     

13 Jan, 2016

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Not much new with tracing for this release. Mostly just clean ups and
    minor fixes.

    Here's what else is new:

    - A new TRACE_EVENT_FN_COND macro, combining both _FN and _COND for
    those that want both.

    - New selftest to test the instance create and delete

    - Better debug output when ftrace fails"

    * tag 'trace-v4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (24 commits)
    ftrace: Fix the race between ftrace and insmod
    ftrace: Add infrastructure for delayed enabling of module functions
    x86: ftrace: Fix the comments for ftrace_modify_code_direct()
    tracing: Fix comment to use tracing_on over tracing_enable
    metag: ftrace: Fix the comments for ftrace_modify_code
    sh: ftrace: Fix the comments for ftrace_modify_code()
    ia64: ftrace: Fix the comments for ftrace_modify_code()
    ftrace: Clean up ftrace_module_init() code
    ftrace: Join functions ftrace_module_init() and ftrace_init_module()
    tracing: Introduce TRACE_EVENT_FN_COND macro
    tracing: Use seq_buf_used() in seq_buf_to_user() instead of len
    bpf: Constify bpf_verifier_ops structure
    ftrace: Have ftrace_ops_get_func() handle RCU and PER_CPU flags too
    ftrace: Remove use of control list and ops
    ftrace: Fix output of enabled_functions for showing tramp
    ftrace: Fix a typo in comment
    ftrace: Show all tramps registered to a record on ftrace_bug()
    ftrace: Add variable ftrace_expected for archs to show expected code
    ftrace: Add new type to distinguish what kind of ftrace_bug()
    tracing: Update cond flag when enabling or disabling a trigger
    ...

    Linus Torvalds
     

04 Jan, 2016

1 commit


26 Nov, 2015

1 commit

  • When a trigger is enabled, the cond flag should be set beforehand,
    otherwise a trigger that's expecting to process a trace record
    (e.g. one with post_trigger set) could be invoked without one.

    Likewise a trigger's cond flag should be reset after it's disabled,
    not before.

    Link: http://lkml.kernel.org/r/a420b52a67b1c2d3cab017914362d153255acb99.1448303214.git.tom.zanussi@linux.intel.com

    Signed-off-by: Tom Zanussi
    Signed-off-by: Daniel Wagner
    Reviewed-by: Masami Hiramatsu
    Reviewed-by: Namhyung Kim
    Tested-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Tom Zanussi
     

14 May, 2015

4 commits


14 Nov, 2014

2 commits

  • Printing a single character to a seqfile might as well be done with
    seq_putc instead of seq_puts; this avoids a strlen() call and a memory
    access. It also shaves another few bytes off the generated code.

    Link: http://lkml.kernel.org/r/1415479332-25944-4-git-send-email-linux@rasmusvillemoes.dk

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Steven Rostedt

    Rasmus Villemoes
     
  • Using seq_printf to print a simple string or a single character is a
    lot more expensive than it needs to be, since seq_puts and seq_putc
    exist.

    These patches do

    seq_printf(m, s) -> seq_puts(m, s)
    seq_printf(m, "%s", s) -> seq_puts(m, s)
    seq_printf(m, "%c", c) -> seq_putc(m, c)

    Subsequent patches will simplify further.

    Link: http://lkml.kernel.org/r/1415479332-25944-2-git-send-email-linux@rasmusvillemoes.dk

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Steven Rostedt

    Rasmus Villemoes
     

03 May, 2014

1 commit

  • As trace event triggers are now part of the mainline kernel, I added
    my trace event trigger tests to my test suite I run on all my kernels.
    Now these tests get run under different config options, and one of
    those options is CONFIG_PROVE_RCU, which checks under lockdep that
    the rcu locking primitives are being used correctly. This triggered
    the following splat:

    ===============================
    [ INFO: suspicious RCU usage. ]
    3.15.0-rc2-test+ #11 Not tainted
    -------------------------------
    kernel/trace/trace_events_trigger.c:80 suspicious rcu_dereference_check() usage!

    other info that might help us debug this:

    rcu_scheduler_active = 1, debug_locks = 0
    4 locks held by swapper/1/0:
    #0: ((&(&j_cdbs->work)->timer)){..-...}, at: [] call_timer_fn+0x5/0x1be
    #1: (&(&pool->lock)->rlock){-.-...}, at: [] __queue_work+0x140/0x283
    #2: (&p->pi_lock){-.-.-.}, at: [] try_to_wake_up+0x2e/0x1e8
    #3: (&rq->lock){-.-.-.}, at: [] try_to_wake_up+0x1a0/0x1e8

    stack backtrace:
    CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.15.0-rc2-test+ #11
    Hardware name: /DG965MQ, BIOS MQ96510J.86A.0372.2006.0605.1717 06/05/2006
    0000000000000001 ffff88007e083b98 ffffffff819f53a5 0000000000000006
    ffff88007b0942c0 ffff88007e083bc8 ffffffff81081307 ffff88007ad96d20
    0000000000000000 ffff88007af2d840 ffff88007b2e701c ffff88007e083c18
    Call Trace:
    [] dump_stack+0x4f/0x7c
    [] lockdep_rcu_suspicious+0x107/0x110
    [] event_triggers_call+0x99/0x108
    [] ftrace_event_buffer_commit+0x42/0xa4
    [] ftrace_raw_event_sched_wakeup_template+0x71/0x7c
    [] ttwu_do_wakeup+0x7f/0xff
    [] ttwu_do_activate.constprop.126+0x5c/0x61
    [] try_to_wake_up+0x1ac/0x1e8
    [] wake_up_process+0x36/0x3b
    [] wake_up_worker+0x24/0x26
    [] insert_work+0x5c/0x65
    [] __queue_work+0x26c/0x283
    [] ? __queue_work+0x283/0x283
    [] delayed_work_timer_fn+0x1e/0x20
    [] call_timer_fn+0xdf/0x1be^M
    [] ? call_timer_fn+0x5/0x1be
    [] ? __queue_work+0x283/0x283
    [] run_timer_softirq+0x1a4/0x22f^M
    [] __do_softirq+0x17b/0x31b^M
    [] irq_exit+0x42/0x97
    [] smp_apic_timer_interrupt+0x37/0x44
    [] apic_timer_interrupt+0x6f/0x80
    [] ? default_idle+0x21/0x32
    [] ? default_idle+0x1f/0x32
    [] arch_cpu_idle+0xf/0x11
    [] cpu_startup_entry+0x1a3/0x213
    [] start_secondary+0x212/0x219

    The cause is that the triggers are protected by rcu_read_lock_sched() but
    the data is dereferenced with rcu_dereference() which expects it to
    be protected with rcu_read_lock(). The proper reference should be
    rcu_dereference_sched().

    Cc: Tom Zanussi
    Cc: stable@vger.kernel.org # 3.14+
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

09 Apr, 2014

1 commit

  • Register/unregister tracepoint probes with struct tracepoint pointer
    rather than tracepoint name.

    This change, which vastly simplifies tracepoint.c, has been proposed by
    Steven Rostedt. It also removes 8.8kB (mostly of text) to the vmlinux
    size.

    From this point on, the tracers need to pass a struct tracepoint pointer
    to probe register/unregister. A probe can now only be connected to a
    tracepoint that exists. Moreover, tracers are responsible for
    unregistering the probe before the module containing its associated
    tracepoint is unloaded.

    text data bss dec hex filename
    10443444 4282528 10391552 25117524 17f4354 vmlinux.orig
    10434930 4282848 10391552 25109330 17f2352 vmlinux

    Link: http://lkml.kernel.org/r/1396992381-23785-2-git-send-email-mathieu.desnoyers@efficios.com

    CC: Ingo Molnar
    CC: Frederic Weisbecker
    CC: Andrew Morton
    CC: Frank Ch. Eigler
    CC: Johannes Berg
    Signed-off-by: Mathieu Desnoyers
    [ SDR - fixed return val in void func in tracepoint_module_going() ]
    Signed-off-by: Steven Rostedt

    Mathieu Desnoyers
     

10 Jan, 2014

2 commits

  • Currently there's no way to know what triggers exist on a kernel without
    looking at the source of the kernel or randomly trying out triggers.
    Instead of creating another file in the debugfs system, simply show
    what available triggers are there when cat'ing the trigger file when
    it has no events:

    [root /sys/kernel/debug/tracing]# cat events/sched/sched_switch/trigger
    # Available triggers:
    # traceon traceoff snapshot stacktrace enable_event disable_event

    This stays consistent with other debugfs files where meta data like
    this is always proceeded with a '#' at the start of the line so that
    tools can strip these out.

    Link: http://lkml.kernel.org/r/20140107103548.0a84536d@gandalf.local.home

    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     
  • The counters for the traceon and traceoff are only suppose to decrement
    when the trigger enables or disables tracing. It is not suppose to decrement
    every time the event is hit.

    Only decrement the counter if the trigger actually did something.

    Link: http://lkml.kernel.org/r/20140106223124.0e5fd0b4@gandalf.local.home

    Acked-by: Tom Zanussi
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)